← Commit list

795433b923

Viktor Szakats
Viktor Szakats
2026-01-25
SUCCESS Duration: 351s

Subject

cmake: enable binutils ld workaround for all toolchains at build-time

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

CMake/curl-config.in.cmake+3 -0
@@ -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")
CMakeLists.txt+18 -18
@@ -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