2017-10-25 14:57:25 +00:00
|
|
|
if(NOT CMAKE_CROSSCOMPILING)
|
|
|
|
find_package(PkgConfig QUIET)
|
|
|
|
pkg_check_modules(PC_CURL libcurl)
|
|
|
|
endif()
|
2017-02-28 23:51:22 +00:00
|
|
|
|
2017-10-24 10:10:46 +00:00
|
|
|
set_extra_dirs_lib(CURL curl)
|
2017-02-28 23:51:22 +00:00
|
|
|
find_library(CURL_LIBRARY
|
|
|
|
NAMES curl
|
2017-07-31 16:30:24 +00:00
|
|
|
HINTS ${HINTS_CURL_LIBDIR} ${PC_CURL_LIBDIR} ${PC_CURL_LIBRARY_DIRS}
|
|
|
|
PATHS ${PATHS_CURL_LIBDIR}
|
2017-10-25 14:57:25 +00:00
|
|
|
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
|
2017-02-28 23:51:22 +00:00
|
|
|
)
|
2017-10-24 10:10:46 +00:00
|
|
|
set_extra_dirs_include(CURL curl "${CURL_LIBRARY}")
|
|
|
|
find_path(CURL_INCLUDEDIR curl/curl.h
|
|
|
|
HINTS ${HINTS_CURL_INCLUDEDIR} ${PC_CURL_INCLUDEDIR} ${PC_CURL_INCLUDE_DIRS}
|
|
|
|
PATHS ${PATHS_CURL_INCLUDEDIR}
|
2017-10-25 14:57:25 +00:00
|
|
|
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
|
2017-10-24 10:10:46 +00:00
|
|
|
)
|
2017-02-23 13:16:32 +00:00
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
2017-02-28 23:51:22 +00:00
|
|
|
find_package_handle_standard_args(Curl DEFAULT_MSG CURL_LIBRARY CURL_INCLUDEDIR)
|
|
|
|
|
|
|
|
mark_as_advanced(CURL_LIBRARY CURL_INCLUDEDIR)
|
|
|
|
|
2017-10-24 13:29:53 +00:00
|
|
|
is_bundled(IS_BUNDLED "${CURL_LIBRARY}")
|
|
|
|
|
2017-02-28 23:51:22 +00:00
|
|
|
set(CURL_LIBRARIES ${CURL_LIBRARY})
|
|
|
|
set(CURL_INCLUDE_DIRS ${CURL_INCLUDEDIR})
|
2017-10-24 13:29:53 +00:00
|
|
|
if(IS_BUNDLED AND TARGET_OS STREQUAL "linux")
|
|
|
|
find_library(CURL_LIBRARY_SSL
|
|
|
|
NAMES ssl
|
|
|
|
HINTS ${EXTRA_CURL_LIBDIR}
|
|
|
|
)
|
|
|
|
find_library(CURL_LIBRARY_CRYPTO
|
|
|
|
NAMES crypto
|
|
|
|
HINTS ${EXTRA_CURL_LIBDIR}
|
|
|
|
)
|
|
|
|
# If we don't add `dl`, we get a missing reference to `dlclose`:
|
|
|
|
# ```
|
|
|
|
# /usr/bin/ld: ../ddnet-libs/curl/linux/lib64/libcrypto.a(dso_dlfcn.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
|
|
|
|
# ```
|
|
|
|
#
|
|
|
|
# Order matters, SSL needs to be linked before CRYPTO, otherwise we also get
|
|
|
|
# undefined symbols.
|
|
|
|
list(APPEND CURL_LIBRARIES ${CURL_LIBRARY_SSL} ${CURL_LIBRARY_CRYPTO} dl)
|
|
|
|
endif()
|
2017-03-07 14:24:08 +00:00
|
|
|
|
2017-10-24 13:29:53 +00:00
|
|
|
if(IS_BUNDLED AND TARGET_OS STREQUAL "windows")
|
2017-03-07 14:24:08 +00:00
|
|
|
set(CURL_COPY_FILES
|
2017-07-21 21:43:01 +00:00
|
|
|
"${EXTRA_CURL_LIBDIR}/libcurl.dll"
|
2017-03-07 14:24:08 +00:00
|
|
|
)
|
|
|
|
else()
|
|
|
|
set(CURL_COPY_FILES)
|
|
|
|
endif()
|