forked from ouster-lidar/ouster-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindCURL.cmake
45 lines (38 loc) · 1.25 KB
/
FindCURL.cmake
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
# Define forwards-compatible imported target for old platforms
# Note: curl from VCPKG appears to completely ignore curl find modules despite
# CMAKE_MODULE_PATH settings
include(FindPackageHandleStandardArgs)
# Prefer package config if it exists
find_package(CURL CONFIG QUIET)
if(CURL_FOUND)
find_package_handle_standard_args(CURL CONFIG_MODE)
return()
endif()
# Trying to find with pkg-config
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(pkg_curl QUIET libcurl)
if(pkg_curl_FOUND)
set(CURL_VERSION_STRING ${pkg_curl_VERSION})
endif()
endif()
find_path(CURL_INCLUDE_DIRS
NAMES curl/curl.h
HINTS ${pkg_curl_INCLUDE_DIRS})
mark_as_advanced(CURL_INCLUDE_DIRS)
# Linux/macos only
find_library(CURL_LIBRARIES NAMES
curl
HINTS ${pkg_curl_LIBRARY_DIRS})
mark_as_advanced(CURL_LIBRARIES)
# Check that we have everything that we need
find_package_handle_standard_args(CURL
REQUIRED_VARS CURL_INCLUDE_DIRS CURL_LIBRARIES
VERSION_VAR CURL_VERSION_STRING)
if(NOT TARGET CURL::libcurl)
add_library(CURL::libcurl UNKNOWN IMPORTED)
set_target_properties(CURL::libcurl PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${CURL_LIBRARIES}")
endif()