I have built Curl from source and it's installed in /usr/local/lib/libcurl.so
I am now trying to instruct CMake to statically link this version with my application (if dynamic is easier, that's fine).
From other Stackoverflow questions I tried this:
option(CURL_STATICLIB "Set to ON to build libcurl with static linking." ON)
option(LIBCURL_ENABLE "Enable or disable the requirement of libcurl" ON)
set(CURL_LIBRARY "-lcurl")
set(CURL_PATH "/usr/local/lib")
find_library(LIB_CURL NAMES libcurl PATHS ${CURL_PATH})
include_directories(${CURL_INCLUDE_DIR})
message(STATUS "LIB_CURL: " ${LIB_CURL})
add_definitions(-DCURL_STATICLIB)
target_link_libraries(my_project PRIVATE ${OPENSSL_LIBRARIES} ${CURL_LIBRARIES})
but it cannot find libcurl.so
:
LIB_CURL: LIB_CURL-NOTFOUND
(My CMake knowledge is basic, any additional tips to improve the above are welcome)
option(CURL_STATICLIB "Set to ON to build libcurl with static linking." ON)
option(LIBCURL_ENABLE "Enable or disable the requirement of libcurl" ON)
option
is used wrongly. curl is not configured in that CMakeLists, therefore option
should be removed.
Try
find_library(LIB_CURL NAMES curl PATHS ${CURL_PATH})
It's unclear, you define -DCURL_STATICLIB
but look for libcurl.so