From 24c30d90e73ef4ff386b7f840fd12f1d4ebd575f Mon Sep 17 00:00:00 2001 From: suzuki toshiya Date: Thu, 8 Feb 2024 13:00:46 +0900 Subject: [PATCH 1/2] Add "Libs.private: -m" to wolfssl.pc.in for a static linking --- support/wolfssl.pc.in | 1 + 1 file changed, 1 insertion(+) diff --git a/support/wolfssl.pc.in b/support/wolfssl.pc.in index e8cb694fd..df7d387b9 100644 --- a/support/wolfssl.pc.in +++ b/support/wolfssl.pc.in @@ -7,4 +7,5 @@ Name: wolfssl Description: wolfssl C library. Version: @VERSION@ Libs: -L${libdir} -lwolfssl +Libs.private: -lm Cflags: -I${includedir} From e4b1e5423525fdc45a928bea84154c0bb8de8b23 Mon Sep 17 00:00:00 2001 From: suzuki toshiya Date: Fri, 9 Feb 2024 13:58:28 +0900 Subject: [PATCH 2/2] configure or cmake sets LIBM variable if required, and write it in wolfssl.pc. --- CMakeLists.txt | 10 ++++++++++ configure.ac | 1 + support/wolfssl.pc.in | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a71ece122..bb57c3e7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2576,6 +2576,16 @@ if(WOLFSSL_INSTALL) set(includedir "\${prefix}/include") set(VERSION ${PROJECT_VERSION}) + # Setting libm in Libs.private of wolfssl.pc. + # See "Link Libraries" in above about `m` insertion to LINK_LIBRARIES + get_target_property(_wolfssl_dep_libs wolfssl LINK_LIBRARIES) + list(FIND _wolfssl_dep_libs m _dep_libm) + if ("${_dep_libm}" GREATER -1) + set(LIBM -lm) + else() + set(LIBM) + endif() + configure_file(support/wolfssl.pc.in ${CMAKE_CURRENT_BINARY_DIR}/support/wolfssl.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/support/wolfssl.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) diff --git a/configure.ac b/configure.ac index dbb7c5977..d505dd67c 100644 --- a/configure.ac +++ b/configure.ac @@ -9172,6 +9172,7 @@ AC_SUBST([AM_LDFLAGS]) AC_SUBST([AM_CCASFLAGS]) AC_SUBST([LIB_ADD]) AC_SUBST([LIB_STATIC_ADD]) +AC_SUBST([LIBM]) # FINAL AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) diff --git a/support/wolfssl.pc.in b/support/wolfssl.pc.in index df7d387b9..19aa4431c 100644 --- a/support/wolfssl.pc.in +++ b/support/wolfssl.pc.in @@ -7,5 +7,5 @@ Name: wolfssl Description: wolfssl C library. Version: @VERSION@ Libs: -L${libdir} -lwolfssl -Libs.private: -lm +Libs.private: @LIBM@ Cflags: -I${includedir}