Skip to content

Commit a2245e8

Browse files
authored
Merge pull request #611 from libtom/fix-mpi-pkgconfig
update `Libs` part of pkg-config file with configured MPI providers
2 parents 93dc29a + 4767558 commit a2245e8

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

CMakeLists.txt

+19
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ include(sources.cmake)
3333
# Options
3434
#-----------------------------------------------------------------------------
3535
option(WITH_LTM "Build with support for libtommath" TRUE)
36+
option(WITH_TFM "Build with support for tomsfastmath" FALSE)
3637
option(WITH_GMP "Build with support for GNU Multi Precision Arithmetic Library" FALSE)
3738
set(MPI_PROVIDER "LTM" CACHE STRING "Build tests and demos against 'LTM', 'TFM' or 'GMP', default is LTM")
3839
option(BUILD_SHARED_LIBS "Build shared library and only the shared library if \"ON\", default is static" OFF)
@@ -136,6 +137,20 @@ if(WITH_LTM)
136137
target_compile_definitions(${PROJECT_NAME} PUBLIC USE_LTM)
137138
endif()
138139
target_link_libraries(${PROJECT_NAME} PUBLIC libtommath)
140+
list(APPEND LTC_MPI_PROVIDERS_CFLAGS -DLTM_DESC)
141+
list(APPEND LTC_MPI_PROVIDERS_LIBS -ltommath)
142+
endif()
143+
# tomsfastmath
144+
if(WITH_TFM)
145+
find_package(tomsfastmath 0.13.1 REQUIRED)
146+
147+
target_compile_definitions(${PROJECT_NAME} PUBLIC TFM_DESC)
148+
if(MPI_PROVIDER MATCHES "TFM")
149+
target_compile_definitions(${PROJECT_NAME} PUBLIC USE_TFM)
150+
endif()
151+
target_link_libraries(${PROJECT_NAME} PUBLIC tomsfastmath)
152+
list(APPEND LTC_MPI_PROVIDERS_CFLAGS -DTFM_DESC)
153+
list(APPEND LTC_MPI_PROVIDERS_LIBS -ltfm)
139154
endif()
140155
# GNU MP
141156
if(WITH_GMP)
@@ -146,8 +161,12 @@ if(WITH_GMP)
146161
target_compile_definitions(${PROJECT_NAME} PUBLIC USE_GMP)
147162
endif()
148163
target_link_libraries(${PROJECT_NAME} PUBLIC ${GMP_LIBRARIES})
164+
list(APPEND LTC_MPI_PROVIDERS_CFLAGS -DGMP_DESC)
165+
list(APPEND LTC_MPI_PROVIDERS_LIBS -lgmp)
149166
endif()
150167

168+
list(JOIN LTC_MPI_PROVIDERS_CFLAGS " " MPI_PROVIDERS_CFLAGS)
169+
list(JOIN LTC_MPI_PROVIDERS_LIBS " " MPI_PROVIDERS_LIBS)
151170

152171
#-----------------------------------------------------------------------------
153172
# demos&test targets

libtomcrypt.pc.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/@PROJECT_NAME@
66
Name: LibTomCrypt
77
Description: public domain open source cryptographic toolkit
88
Version: @PROJECT_VERSION@
9-
Libs: -L${libdir} -ltomcrypt
10-
Cflags: -I${includedir}
9+
Libs: -L${libdir} -ltomcrypt @MPI_PROVIDERS_LIBS@
10+
Cflags: -I${includedir} @MPI_PROVIDERS_CFLAGS@

makefile.shared

+15-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ endif
5454

5555
include makefile_include.mk
5656

57+
ifneq ($(findstring -DLTM_DESC,$(LTC_CFLAGS)),)
58+
LTC_MPI_PROVIDERS_CFLAGS += -DLTM_DESC
59+
LTC_MPI_PROVIDERS_LIBS += -ltommath
60+
endif
61+
ifneq ($(findstring -DTFM_DESC,$(LTC_CFLAGS)),)
62+
LTC_MPI_PROVIDERS_CFLAGS += -DTFM_DESC
63+
LTC_MPI_PROVIDERS_LIBS += -ltfm
64+
endif
65+
ifneq ($(findstring -DGMP_DESC,$(LTC_CFLAGS)),)
66+
LTC_MPI_PROVIDERS_CFLAGS += -DGMP_DESC
67+
LTC_MPI_PROVIDERS_LIBS += -lgmp
68+
endif
5769

5870
#ciphers come in two flavours... enc+dec and enc
5971
src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
@@ -80,7 +92,9 @@ $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
8092

8193
install: $(call print-help,install,Installs the library + headers + pkg-config file) .common_install
8294
sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION_PC),' -e 's,@CMAKE_INSTALL_LIBDIR@,lib,' \
83-
-e 's,@CMAKE_INSTALL_INCLUDEDIR@/@PROJECT_NAME@,include/tomcrypt,' libtomcrypt.pc.in > libtomcrypt.pc
95+
-e 's,@CMAKE_INSTALL_INCLUDEDIR@/@PROJECT_NAME@,include/tomcrypt,' \
96+
-e 's,@MPI_PROVIDERS_LIBS@,$(LTC_MPI_PROVIDERS_LIBS),' \
97+
-e 's,@MPI_PROVIDERS_CFLAGS@,$(LTC_MPI_PROVIDERS_CFLAGS),' libtomcrypt.pc.in > libtomcrypt.pc
8498
install -p -d $(DESTDIR)$(LIBPATH)/pkgconfig
8599
install -p -m 644 libtomcrypt.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
86100

0 commit comments

Comments
 (0)