mirror of
https://github.com/curl/curl.git
synced 2026-01-26 06:57:57 +00:00
cmake: enable binutils ld workaround for all toolchains at build-time
To make it available for GCC if used when consuming libcurl. Also add comment to `curl-config.cmake` explaining why these odd targets are defined there. Bug: https://github.com/curl/curl/pull/20382#discussion_r2716660108 Follow-up to 3e841630ece59c04e26058a761302f38370fd0cc #20427 Follow-up to ef3101d1819928a7799309a16cc531818778e5c7 #20382 Follow-up to 16f073ef49f94412000218c9f6ad04e3fd7e4d01 #16973 Closes #20434
This commit is contained in:
parent
3e841630ec
commit
795433b923
@ -39,6 +39,7 @@ if("@USE_OPENSSL@")
|
||||
else()
|
||||
find_dependency(OpenSSL)
|
||||
endif()
|
||||
# Define lib duplicate to fixup lib order for GCC binutils ld in static builds
|
||||
if(TARGET OpenSSL::Crypto AND NOT TARGET CURL::OpenSSL_Crypto)
|
||||
add_library(CURL::OpenSSL_Crypto INTERFACE IMPORTED)
|
||||
get_target_property(_curl_libname OpenSSL::Crypto LOCATION)
|
||||
@ -47,6 +48,7 @@ if("@USE_OPENSSL@")
|
||||
endif()
|
||||
if("@HAVE_LIBZ@")
|
||||
find_dependency(ZLIB "@ZLIB_VERSION_MAJOR@")
|
||||
# Define lib duplicate to fixup lib order for GCC binutils ld in static builds
|
||||
if(TARGET ZLIB::ZLIB AND NOT TARGET CURL::ZLIB)
|
||||
add_library(CURL::ZLIB INTERFACE IMPORTED)
|
||||
get_target_property(_curl_libname ZLIB::ZLIB LOCATION)
|
||||
@ -148,6 +150,7 @@ endif()
|
||||
|
||||
set(CMAKE_MODULE_PATH ${_curl_cmake_module_path_save})
|
||||
|
||||
# Define lib duplicate to fixup lib order for GCC binutils ld in static builds
|
||||
if(WIN32 AND NOT TARGET CURL::win32_winsock)
|
||||
add_library(CURL::win32_winsock INTERFACE IMPORTED)
|
||||
set_target_properties(CURL::win32_winsock PROPERTIES INTERFACE_LINK_LIBRARIES "ws2_32")
|
||||
|
||||
@ -1812,24 +1812,24 @@ endif()
|
||||
# list on the linker command-line for some reason. This makes them appear
|
||||
# before dependencies detected via curl's custom Find modules, and breaks
|
||||
# linkers sensitive to lib order. There must be a better solution to this.
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
if(USE_OPENSSL AND TARGET OpenSSL::Crypto)
|
||||
add_library(CURL::OpenSSL_Crypto INTERFACE IMPORTED)
|
||||
get_target_property(_curl_libname OpenSSL::Crypto LOCATION)
|
||||
set_target_properties(CURL::OpenSSL_Crypto PROPERTIES INTERFACE_LINK_LIBRARIES "${_curl_libname}")
|
||||
list(APPEND CURL_LIBS CURL::OpenSSL_Crypto)
|
||||
endif()
|
||||
if(HAVE_LIBZ AND TARGET ZLIB::ZLIB)
|
||||
add_library(CURL::ZLIB INTERFACE IMPORTED)
|
||||
get_target_property(_curl_libname ZLIB::ZLIB LOCATION)
|
||||
set_target_properties(CURL::ZLIB PROPERTIES INTERFACE_LINK_LIBRARIES "${_curl_libname}")
|
||||
list(APPEND CURL_LIBS CURL::ZLIB)
|
||||
endif()
|
||||
if(WIN32)
|
||||
add_library(CURL::win32_winsock INTERFACE IMPORTED)
|
||||
set_target_properties(CURL::win32_winsock PROPERTIES INTERFACE_LINK_LIBRARIES "ws2_32")
|
||||
list(APPEND CURL_LIBS CURL::win32_winsock)
|
||||
endif()
|
||||
# Enable the workaround for all compilers, to make it available when using GCC
|
||||
# to consume libcurl, regardless of the compiler used to build libcurl itself.
|
||||
if(USE_OPENSSL AND TARGET OpenSSL::Crypto)
|
||||
add_library(CURL::OpenSSL_Crypto INTERFACE IMPORTED)
|
||||
get_target_property(_curl_libname OpenSSL::Crypto LOCATION)
|
||||
set_target_properties(CURL::OpenSSL_Crypto PROPERTIES INTERFACE_LINK_LIBRARIES "${_curl_libname}")
|
||||
list(APPEND CURL_LIBS CURL::OpenSSL_Crypto)
|
||||
endif()
|
||||
if(HAVE_LIBZ AND TARGET ZLIB::ZLIB)
|
||||
add_library(CURL::ZLIB INTERFACE IMPORTED)
|
||||
get_target_property(_curl_libname ZLIB::ZLIB LOCATION)
|
||||
set_target_properties(CURL::ZLIB PROPERTIES INTERFACE_LINK_LIBRARIES "${_curl_libname}")
|
||||
list(APPEND CURL_LIBS CURL::ZLIB)
|
||||
endif()
|
||||
if(WIN32)
|
||||
add_library(CURL::win32_winsock INTERFACE IMPORTED)
|
||||
set_target_properties(CURL::win32_winsock PROPERTIES INTERFACE_LINK_LIBRARIES "ws2_32")
|
||||
list(APPEND CURL_LIBS CURL::win32_winsock)
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") # MSVC but exclude clang-cl
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user