mirror of
https://github.com/curl/curl.git
synced 2026-07-24 15:37:16 +03:00
cmake: replace check_library_exists_concat()
The idea of `check_library_exists_concat()` is that it detects an optional component and adds it to the list of libs that we also use in subsequent component checks. This caused problems when detecting components with unnecessary dependencies that were not yet built. CMake offers the `CMAKE_REQUIRED_LIBRARIES` variable to set libs used for component checks, which we already use in most cases. That left 4 uses of `check_library_exists_concat()`. Only one of these actually needed the 'concat' feature (ldap/lber). Delete this function and replace it with standard `check_library_exists()` and manual management of our `CURL_LIBS` list we use when linking build targets. And special logic to handle the ldap/lber case. (We have a similar function for headers: `check_include_file_concat()`. It works, but problematic for performance reasons and because it hides the actual headers required in `check_symbol_exists()` calls.) Ref: #11537 #11558 Fixes #11285 Fixes #11648 Closes #12070
This commit is contained in:
parent
b1b7552803
commit
84a6579132
2 changed files with 16 additions and 17 deletions
|
|
@ -23,19 +23,6 @@
|
|||
###########################################################################
|
||||
#File defines convenience macros for available feature testing
|
||||
|
||||
# This macro checks if the symbol exists in the library and if it
|
||||
# does, it prepends library to the list. It is intended to be called
|
||||
# multiple times with a sequence of possibly dependent libraries in
|
||||
# order of least-to-most-dependent. Some libraries depend on others
|
||||
# to link correctly.
|
||||
macro(check_library_exists_concat LIBRARY SYMBOL VARIABLE)
|
||||
check_library_exists("${LIBRARY};${CURL_LIBS}" ${SYMBOL} "${CMAKE_LIBRARY_PATH}"
|
||||
${VARIABLE})
|
||||
if(${VARIABLE})
|
||||
set(CURL_LIBS ${LIBRARY} ${CURL_LIBS})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Check if header file exists and add it to the list.
|
||||
# This macro is intended to be called multiple times with a sequence of
|
||||
# possibly dependent header files. Some headers depend on others to be
|
||||
|
|
|
|||
|
|
@ -378,7 +378,10 @@ if(ENABLE_THREADED_RESOLVER)
|
|||
endif()
|
||||
|
||||
# Check for all needed libraries
|
||||
check_library_exists_concat("socket" connect HAVE_LIBSOCKET)
|
||||
check_library_exists("socket" "connect" "" HAVE_LIBSOCKET)
|
||||
if(HAVE_LIBSOCKET)
|
||||
set(CURL_LIBS "socket;${CURL_LIBS}")
|
||||
endif()
|
||||
|
||||
check_function_exists(gethostname HAVE_GETHOSTNAME)
|
||||
|
||||
|
|
@ -751,8 +754,12 @@ if(NOT CURL_DISABLE_LDAP)
|
|||
if(NOT USE_WIN32_LDAP)
|
||||
# Check for LDAP
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES})
|
||||
check_library_exists_concat(${CMAKE_LDAP_LIB} ldap_init HAVE_LIBLDAP)
|
||||
check_library_exists_concat(${CMAKE_LBER_LIB} ber_init HAVE_LIBLBER)
|
||||
check_library_exists("${CMAKE_LDAP_LIB}" "ldap_init" "" HAVE_LIBLDAP)
|
||||
if(HAVE_LIBLDAP)
|
||||
check_library_exists("${CMAKE_LDAP_LIB};${CMAKE_LBER_LIB}" "ber_init" "" HAVE_LIBLBER)
|
||||
else()
|
||||
check_library_exists("${CMAKE_LBER_LIB}" "ber_init" "" HAVE_LIBLBER)
|
||||
endif()
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES_BAK ${CMAKE_REQUIRED_INCLUDES})
|
||||
set(CMAKE_LDAP_INCLUDE_DIR "" CACHE STRING "Path to LDAP include directory")
|
||||
|
|
@ -791,8 +798,10 @@ if(NOT CURL_DISABLE_LDAP)
|
|||
|
||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DLDAP_DEPRECATED=1)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LDAP_LIB})
|
||||
set(CURL_LIBS "${CMAKE_LDAP_LIB};${CURL_LIBS}")
|
||||
if(HAVE_LIBLBER)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LBER_LIB})
|
||||
set(CURL_LIBS "${CMAKE_LBER_LIB};${CURL_LIBS}")
|
||||
endif()
|
||||
|
||||
check_c_source_compiles("
|
||||
|
|
@ -839,7 +848,10 @@ endif()
|
|||
# Check for idn2
|
||||
option(USE_LIBIDN2 "Use libidn2 for IDN support" ON)
|
||||
if(USE_LIBIDN2)
|
||||
check_library_exists_concat("idn2" idn2_lookup_ul HAVE_LIBIDN2)
|
||||
check_library_exists("idn2" "idn2_lookup_ul" "" HAVE_LIBIDN2)
|
||||
if(HAVE_LIBIDN2)
|
||||
set(CURL_LIBS "idn2;${CURL_LIBS}")
|
||||
endif()
|
||||
else()
|
||||
set(HAVE_LIBIDN2 OFF)
|
||||
endif()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue