Skip to content

Commit

Permalink
cmake: fix curl-config --static-libs
Browse files Browse the repository at this point in the history
Libraries for `curl-config --static-libs` are required to have the form
-ldl. Assume library paths like /usr/lib/libssl.so and map it to "ssl"
for curl-config.

This removes the confusing messag "Static linking is broken" which was
printed because curl-config --static-libs was disfunctional while the
static libcurl.a is fine.

Fixes curl#841
  • Loading branch information
Lekensteyn committed Jun 1, 2016
1 parent 6dbc23c commit 4192146
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1133,9 +1133,7 @@ set(CURL_CA_BUNDLE "")
set(CURLVERSION "${CURL_VERSION}")
set(ENABLE_SHARED "yes")
if(CURL_STATICLIB)
# Broken: LIBCURL_LIBS below; .a lib is not built
message(WARNING "Static linking is broken!")
set(ENABLE_STATIC "no")
set(ENABLE_STATIC "yes")
else()
set(ENABLE_STATIC "no")
endif()
Expand All @@ -1144,9 +1142,9 @@ set(includedir "\${prefix}/include")
set(LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
set(LIBCURL_LIBS "")
set(libdir "${CMAKE_INSTALL_PREFIX}/lib")
# TODO CURL_LIBS also contains absolute paths which don't work with static -l...
foreach(_lib ${CMAKE_C_IMPLICIT_LINK_LIBRARIES} ${CURL_LIBS})
set(LIBCURL_LIBS "${LIBCURL_LIBS} -l${_lib}")
string(REGEX REPLACE "^.*/lib(.+)\\.so$" "\\1" _libname "${_lib}")
set(LIBCURL_LIBS "${LIBCURL_LIBS} -l${_libname}")
endforeach()
# "a" (Linux) or "lib" (Windows)
string(REPLACE "." "" libext "${CMAKE_STATIC_LIBRARY_SUFFIX}")
Expand Down

0 comments on commit 4192146

Please sign in to comment.