]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: make system libraries `dl`, `m`, `pthread` customizable
authorViktor Szakats <commit@vsz.me>
Wed, 1 Jan 2025 21:55:07 +0000 (22:55 +0100)
committerViktor Szakats <commit@vsz.me>
Thu, 2 Jan 2025 11:55:50 +0000 (12:55 +0100)
via `DL_LIBRARY`, `MATH_LIBRARY`, `PTHREAD_LIBRARY` variables.

They are used in Rustls, wolfSSL Find modules.

Also:
- always use `NAMES` keyword in `find_library()` calls.
- respect `find_library()` results for `dl`, `m`, `pthread`.
- formatting.

Closes #15892

CMake/FindRustls.cmake
CMake/FindWolfSSL.cmake
CMakeLists.txt
docs/INSTALL-CMAKE.md

index faf178ad3b88e5ab7d9ebb9e8c554721eea9d3c2..8a231fc7e1d9c3e572e52d180006622b8d276a2b 100644 (file)
@@ -72,35 +72,35 @@ else()
 endif()
 
 if(APPLE)
-  find_library(SECURITY_FRAMEWORK "Security")
+  find_library(SECURITY_FRAMEWORK NAMES "Security")
   mark_as_advanced(SECURITY_FRAMEWORK)
   if(NOT SECURITY_FRAMEWORK)
     message(FATAL_ERROR "Security framework not found")
   endif()
   list(APPEND RUSTLS_LIBRARIES "-framework Security")
 
-  find_library(FOUNDATION_FRAMEWORK "Foundation")
+  find_library(FOUNDATION_FRAMEWORK NAMES "Foundation")
   mark_as_advanced(FOUNDATION_FRAMEWORK)
   if(NOT FOUNDATION_FRAMEWORK)
     message(FATAL_ERROR "Foundation framework not found")
   endif()
   list(APPEND RUSTLS_LIBRARIES "-framework Foundation")
 elseif(NOT WIN32)
-  find_library(_pthread_library "pthread")
-  if(_pthread_library)
-    list(APPEND RUSTLS_LIBRARIES "pthread")
+  find_library(PTHREAD_LIBRARY NAMES "pthread")
+  if(PTHREAD_LIBRARY)
+    list(APPEND RUSTLS_LIBRARIES ${PTHREAD_LIBRARY})
   endif()
-  mark_as_advanced(_pthread_library)
+  mark_as_advanced(PTHREAD_LIBRARY)
 
-  find_library(_dl_library "dl")
-  if(_dl_library)
-    list(APPEND RUSTLS_LIBRARIES "dl")
+  find_library(DL_LIBRARY NAMES "dl")
+  if(DL_LIBRARY)
+    list(APPEND RUSTLS_LIBRARIES ${DL_LIBRARY})
   endif()
-  mark_as_advanced(_dl_library)
+  mark_as_advanced(DL_LIBRARY)
 
-  find_library(_math_library "m")
-  if(_math_library)
-    list(APPEND RUSTLS_LIBRARIES "m")
+  find_library(MATH_LIBRARY NAMES "m")
+  if(MATH_LIBRARY)
+    list(APPEND RUSTLS_LIBRARIES ${MATH_LIBRARY})
   endif()
-  mark_as_advanced(_math_library)
+  mark_as_advanced(MATH_LIBRARY)
 endif()
index 577a34c33aa366ccb7ffeaf8aa74d71a72b3090b..9fdad66d2c56fe3dd09c98e86bfad24c13568251 100644 (file)
@@ -91,9 +91,9 @@ else()
 endif()
 
 if(NOT WIN32)
-  find_library(_math_library "m")
-  if(_math_library)
-    list(APPEND WOLFSSL_LIBRARIES "m")  # for log and pow
+  find_library(MATH_LIBRARY NAMES "m")
+  if(MATH_LIBRARY)
+    list(APPEND WOLFSSL_LIBRARIES ${MATH_LIBRARY})  # for log and pow
   endif()
-  mark_as_advanced(_math_library)
+  mark_as_advanced(MATH_LIBRARY)
 endif()
index 5fd8b71368cba412379e6e75be879df52e8b3051..a424863fd270286aabc5f374d3f847d29698c0b3 100644 (file)
@@ -469,12 +469,11 @@ if(ENABLE_IPV6 AND NOT WIN32)
   if(APPLE AND NOT ENABLE_ARES)
     set(_use_core_foundation_and_core_services ON)
 
-    find_library(SYSTEMCONFIGURATION_FRAMEWORK "SystemConfiguration")
+    find_library(SYSTEMCONFIGURATION_FRAMEWORK NAMES "SystemConfiguration")
     mark_as_advanced(SYSTEMCONFIGURATION_FRAMEWORK)
     if(NOT SYSTEMCONFIGURATION_FRAMEWORK)
       message(FATAL_ERROR "SystemConfiguration framework not found")
     endif()
-
     list(APPEND CURL_LIBS "-framework SystemConfiguration")
   endif()
 endif()
@@ -656,15 +655,15 @@ endif()
 if(CURL_USE_SECTRANSP)
   set(_use_core_foundation_and_core_services ON)
 
-  find_library(SECURITY_FRAMEWORK "Security")
+  find_library(SECURITY_FRAMEWORK NAMES "Security")
   mark_as_advanced(SECURITY_FRAMEWORK)
   if(NOT SECURITY_FRAMEWORK)
     message(FATAL_ERROR "Security framework not found")
   endif()
+  list(APPEND CURL_LIBS "-framework Security")
 
   set(_ssl_enabled ON)
   set(USE_SECTRANSP ON)
-  list(APPEND CURL_LIBS "-framework Security")
 
   if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "secure-transport")
     set(_valid_default_ssl_backend TRUE)
@@ -674,19 +673,19 @@ if(CURL_USE_SECTRANSP)
 endif()
 
 if(_use_core_foundation_and_core_services)
-  find_library(COREFOUNDATION_FRAMEWORK "CoreFoundation")
+  find_library(COREFOUNDATION_FRAMEWORK NAMES "CoreFoundation")
   mark_as_advanced(COREFOUNDATION_FRAMEWORK)
-  find_library(CORESERVICES_FRAMEWORK "CoreServices")
-  mark_as_advanced(CORESERVICES_FRAMEWORK)
-
   if(NOT COREFOUNDATION_FRAMEWORK)
     message(FATAL_ERROR "CoreFoundation framework not found")
   endif()
+  list(APPEND CURL_LIBS "-framework CoreFoundation")
+
+  find_library(CORESERVICES_FRAMEWORK NAMES "CoreServices")
+  mark_as_advanced(CORESERVICES_FRAMEWORK)
   if(NOT CORESERVICES_FRAMEWORK)
     message(FATAL_ERROR "CoreServices framework not found")
   endif()
-
-  list(APPEND CURL_LIBS "-framework CoreFoundation" "-framework CoreServices")
+  list(APPEND CURL_LIBS "-framework CoreServices")
 endif()
 
 if(CURL_USE_OPENSSL)
index 61c2f1cd60e677f739506e862965ff473278d033..1cdde97c2cc2f3fedc3ae834fbe5cc22502c029c 100644 (file)
@@ -317,6 +317,7 @@ Details via CMake
 - `BROTLIDEC_LIBRARY`:                      Path to `brotlidec` library.
 - `CARES_INCLUDE_DIR`:                      The c-ares include directory.
 - `CARES_LIBRARY`:                          Path to `cares` library.
+- `DL_LIBRARY`:                             Path to `dl` library. (for Rustls)
 - `GSS_ROOT_DIR`:                           Set this variable to the root installation of GSS. (also supported as environment)
 - `LDAP_LIBRARY`:                           Name or full path to `ldap` library. Default: `ldap`
 - `LDAP_LBER_LIBRARY`:                      Name or full path to `lber` library. Default: `lber`
@@ -335,12 +336,13 @@ Details via CMake
 - `LIBSSH2_LIBRARY`:                        Path to `libssh2` library.
 - `LIBUV_INCLUDE_DIR`:                      The libuv include directory.
 - `LIBUV_LIBRARY`:                          Path to `libuv` library.
-- `MSH3_INCLUDE_DIR`:                       The msh3 include directory.
-- `MSH3_LIBRARY`:                           Path to `msh3` library.
+- `MATH_LIBRARY`:                           Path to `m` library. (for Rustls, wolfSSL)
 - `MBEDTLS_INCLUDE_DIR`:                    The mbedTLS include directory.
 - `MBEDTLS_LIBRARY`:                        Path to `mbedtls` library.
 - `MBEDX509_LIBRARY`:                       Path to `mbedx509` library.
 - `MBEDCRYPTO_LIBRARY`:                     Path to `mbedcrypto` library.
+- `MSH3_INCLUDE_DIR`:                       The msh3 include directory.
+- `MSH3_LIBRARY`:                           Path to `msh3` library.
 - `NGHTTP2_INCLUDE_DIR`:                    The nghttp2 include directory.
 - `NGHTTP2_LIBRARY`:                        Path to `nghttp2` library.
 - `NGHTTP3_INCLUDE_DIR`:                    The nghttp3 include directory.
@@ -349,6 +351,7 @@ Details via CMake
 - `NGTCP2_LIBRARY`:                         Path to `ngtcp2` library.
 - `NETTLE_INCLUDE_DIR`:                     The nettle include directory.
 - `NETTLE_LIBRARY`:                         Path to `nettle` library.
+- `PTHREAD_LIBRARY`:                        Path to `pthread` library. (for Rustls)
 - `QUICHE_INCLUDE_DIR`:                     The quiche include directory.
 - `QUICHE_LIBRARY`:                         Path to `quiche` library.
 - `RUSTLS_INCLUDE_DIR`:                     The Rustls include directory.