Skip to content

Commit

Permalink
Merge pull request #611 from libtom/fix-mpi-pkgconfig
Browse files Browse the repository at this point in the history
update `Libs` part of pkg-config file with configured MPI providers
  • Loading branch information
sjaeckel committed Jun 19, 2023
2 parents 93dc29a + 4767558 commit a2245e8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ include(sources.cmake)
# Options
#-----------------------------------------------------------------------------
option(WITH_LTM "Build with support for libtommath" TRUE)
option(WITH_TFM "Build with support for tomsfastmath" FALSE)
option(WITH_GMP "Build with support for GNU Multi Precision Arithmetic Library" FALSE)
set(MPI_PROVIDER "LTM" CACHE STRING "Build tests and demos against 'LTM', 'TFM' or 'GMP', default is LTM")
option(BUILD_SHARED_LIBS "Build shared library and only the shared library if \"ON\", default is static" OFF)
Expand Down Expand Up @@ -136,6 +137,20 @@ if(WITH_LTM)
target_compile_definitions(${PROJECT_NAME} PUBLIC USE_LTM)
endif()
target_link_libraries(${PROJECT_NAME} PUBLIC libtommath)
list(APPEND LTC_MPI_PROVIDERS_CFLAGS -DLTM_DESC)
list(APPEND LTC_MPI_PROVIDERS_LIBS -ltommath)
endif()
# tomsfastmath
if(WITH_TFM)
find_package(tomsfastmath 0.13.1 REQUIRED)

target_compile_definitions(${PROJECT_NAME} PUBLIC TFM_DESC)
if(MPI_PROVIDER MATCHES "TFM")
target_compile_definitions(${PROJECT_NAME} PUBLIC USE_TFM)
endif()
target_link_libraries(${PROJECT_NAME} PUBLIC tomsfastmath)
list(APPEND LTC_MPI_PROVIDERS_CFLAGS -DTFM_DESC)
list(APPEND LTC_MPI_PROVIDERS_LIBS -ltfm)
endif()
# GNU MP
if(WITH_GMP)
Expand All @@ -146,8 +161,12 @@ if(WITH_GMP)
target_compile_definitions(${PROJECT_NAME} PUBLIC USE_GMP)
endif()
target_link_libraries(${PROJECT_NAME} PUBLIC ${GMP_LIBRARIES})
list(APPEND LTC_MPI_PROVIDERS_CFLAGS -DGMP_DESC)
list(APPEND LTC_MPI_PROVIDERS_LIBS -lgmp)
endif()

list(JOIN LTC_MPI_PROVIDERS_CFLAGS " " MPI_PROVIDERS_CFLAGS)
list(JOIN LTC_MPI_PROVIDERS_LIBS " " MPI_PROVIDERS_LIBS)

#-----------------------------------------------------------------------------
# demos&test targets
Expand Down
4 changes: 2 additions & 2 deletions libtomcrypt.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/@PROJECT_NAME@
Name: LibTomCrypt
Description: public domain open source cryptographic toolkit
Version: @PROJECT_VERSION@
Libs: -L${libdir} -ltomcrypt
Cflags: -I${includedir}
Libs: -L${libdir} -ltomcrypt @MPI_PROVIDERS_LIBS@
Cflags: -I${includedir} @MPI_PROVIDERS_CFLAGS@
16 changes: 15 additions & 1 deletion makefile.shared
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ endif

include makefile_include.mk

ifneq ($(findstring -DLTM_DESC,$(LTC_CFLAGS)),)
LTC_MPI_PROVIDERS_CFLAGS += -DLTM_DESC
LTC_MPI_PROVIDERS_LIBS += -ltommath
endif
ifneq ($(findstring -DTFM_DESC,$(LTC_CFLAGS)),)
LTC_MPI_PROVIDERS_CFLAGS += -DTFM_DESC
LTC_MPI_PROVIDERS_LIBS += -ltfm
endif
ifneq ($(findstring -DGMP_DESC,$(LTC_CFLAGS)),)
LTC_MPI_PROVIDERS_CFLAGS += -DGMP_DESC
LTC_MPI_PROVIDERS_LIBS += -lgmp
endif

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

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

Expand Down

0 comments on commit a2245e8

Please sign in to comment.