Browse Source

Add correct MPI provider defines to pkg-config cflags

Signed-off-by: Steffen Jaeckel <[email protected]>
Steffen Jaeckel 2 years ago
parent
commit
4767558fd0
3 changed files with 18 additions and 9 deletions
  1. 8 3
      CMakeLists.txt
  2. 2 2
      libtomcrypt.pc.in
  3. 8 4
      makefile.shared

+ 8 - 3
CMakeLists.txt

@@ -137,7 +137,8 @@ if(WITH_LTM)
         target_compile_definitions(${PROJECT_NAME} PUBLIC USE_LTM)
     endif()
     target_link_libraries(${PROJECT_NAME} PUBLIC libtommath)
-    list(APPEND MPI_PROVIDERS -ltommath)
+    list(APPEND LTC_MPI_PROVIDERS_CFLAGS -DLTM_DESC)
+    list(APPEND LTC_MPI_PROVIDERS_LIBS -ltommath)
 endif()
 # tomsfastmath
 if(WITH_TFM)
@@ -148,7 +149,8 @@ if(WITH_TFM)
         target_compile_definitions(${PROJECT_NAME} PUBLIC USE_TFM)
     endif()
     target_link_libraries(${PROJECT_NAME} PUBLIC tomsfastmath)
-    list(APPEND MPI_PROVIDERS -ltfm)
+    list(APPEND LTC_MPI_PROVIDERS_CFLAGS -DTFM_DESC)
+    list(APPEND LTC_MPI_PROVIDERS_LIBS -ltfm)
 endif()
 # GNU MP
 if(WITH_GMP)
@@ -159,9 +161,12 @@ if(WITH_GMP)
         target_compile_definitions(${PROJECT_NAME} PUBLIC USE_GMP)
     endif()
     target_link_libraries(${PROJECT_NAME} PUBLIC ${GMP_LIBRARIES})
-    list(APPEND MPI_PROVIDERS -lgmp)
+    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

+ 2 - 2
libtomcrypt.pc.in

@@ -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 @MPI_PROVIDERS@
-Cflags: -I${includedir}
+Libs: -L${libdir} -ltomcrypt @MPI_PROVIDERS_LIBS@
+Cflags: -I${includedir} @MPI_PROVIDERS_CFLAGS@

+ 8 - 4
makefile.shared

@@ -55,13 +55,16 @@ endif
 include makefile_include.mk
 
 ifneq ($(findstring -DLTM_DESC,$(LTC_CFLAGS)),)
-LTC_MPI_PROVIDERS += -ltommath
+LTC_MPI_PROVIDERS_CFLAGS += -DLTM_DESC
+LTC_MPI_PROVIDERS_LIBS += -ltommath
 endif
 ifneq ($(findstring -DTFM_DESC,$(LTC_CFLAGS)),)
-LTC_MPI_PROVIDERS += -ltfm
+LTC_MPI_PROVIDERS_CFLAGS += -DTFM_DESC
+LTC_MPI_PROVIDERS_LIBS += -ltfm
 endif
 ifneq ($(findstring -DGMP_DESC,$(LTC_CFLAGS)),)
-LTC_MPI_PROVIDERS += -lgmp
+LTC_MPI_PROVIDERS_CFLAGS += -DGMP_DESC
+LTC_MPI_PROVIDERS_LIBS += -lgmp
 endif
 
 #ciphers come in two flavours... enc+dec and enc
@@ -90,7 +93,8 @@ $(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,' \
-		-e 's,@MPI_PROVIDERS@,$(LTC_MPI_PROVIDERS),' libtomcrypt.pc.in > libtomcrypt.pc
+		-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/