blob: 6411a92915b8035ff5465e6731348341a273435a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#.rst:
# FindCurl
# --------
# Finds the Curl library
#
# This will define the following variables::
#
# CURL_FOUND - system has Curl
# CURL_INCLUDE_DIRS - the Curl include directory
# CURL_LIBRARIES - the Curl libraries
# CURL_DEFINITIONS - the Curl definitions
#
# and the following imported targets::
#
# Curl::Curl - The Curl library
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_CURL libcurl QUIET)
endif()
find_path(CURL_INCLUDE_DIR NAMES curl/curl.h
PATHS ${PC_CURL_INCLUDEDIR})
find_library(CURL_LIBRARY NAMES curl libcurl libcurl_imp
PATHS ${PC_CURL_LIBDIR})
set(CURL_VERSION ${PC_CURL_VERSION})
set(CURL_LIB_TYPE SHARED)
set(CURL_LDFLAGS ${PC_CURL_LDFLAGS})
# check if curl is statically linked
if(${CURL_LIBRARY} MATCHES ".+\.a$" AND PC_CURL_STATIC_LDFLAGS)
set(CURL_LIB_TYPE STATIC)
set(CURL_LDFLAGS ${PC_CURL_STATIC_LDFLAGS})
pkg_check_modules(PC_NGHTTP2 libnghttp2 QUIET)
find_library(NGHTTP2_LIBRARY NAMES libnghttp2 nghttp2
PATHS ${PC_NGHTTP2_LIBDIR})
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Curl
REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR
VERSION_VAR CURL_VERSION)
if(CURL_FOUND)
set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})
set(CURL_LIBRARIES ${CURL_LIBRARY} ${NGHTTP2_LIBRARY})
if(NOT TARGET Curl::Curl)
add_library(Curl::Curl ${CURL_LIB_TYPE} IMPORTED)
set_target_properties(Curl::Curl PROPERTIES
IMPORTED_LOCATION "${CURL_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIR}")
if(HAS_CURL_STATIC)
set_target_properties(Curl::Curl PROPERTIES
INTERFACE_COMPILE_DEFINITIONS HAS_CURL_STATIC=1)
endif()
endif()
endif()
mark_as_advanced(CURL_INCLUDE_DIR CURL_LIBRARY CURL_LDFLAGS)
|