summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-12-07 13:29:43 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-12-07 13:31:37 (GMT)
commit05f1d7a4627e2bbebaa5a80ee3aaa98467f184b3 (patch)
tree1e2d19024c959791f1f76400fbabf42e7ba431fb /Modules
parent1cb7ea61134536d803a64d5fb64fe37bccdcdb2f (diff)
parent5085a984e1ac4d49d68f02058383be21633a3fbf (diff)
downloadCMake-05f1d7a4627e2bbebaa5a80ee3aaa98467f184b3.zip
CMake-05f1d7a4627e2bbebaa5a80ee3aaa98467f184b3.tar.gz
CMake-05f1d7a4627e2bbebaa5a80ee3aaa98467f184b3.tar.bz2
Merge topic 'FindCURL-components'
5085a984e1 Help: Add notes for topic 'FindCURL-components' 8e5db11fd9 FindCURL: add test for component fc5afbe970 FindCURL: support COMPONENTS to check features Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2677
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindCURL.cmake77
1 files changed, 73 insertions, 4 deletions
diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake
index a4b238d..d28dfea 100644
--- a/Modules/FindCURL.cmake
+++ b/Modules/FindCURL.cmake
@@ -7,6 +7,14 @@ FindCURL
Find the native CURL headers and libraries.
+This module accept optional COMPONENTS to check supported features and
+protocols::
+
+ PROTOCOLS: ICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS LDAP LDAPS POP3
+ POP3S RTMP RTSP SCP SFTP SMB SMBS SMTP SMTPS TELNET TFTP
+ FEATURES: SSL IPv6 UnixSockets libz AsynchDNS IDN GSS-API PSL SPNEGO
+ Kerberos NTLM NTLM_WB TLS-SRP HTTP2 HTTPS-proxy
+
IMPORTED Targets
^^^^^^^^^^^^^^^^
@@ -31,8 +39,20 @@ This module defines the following variables:
The version of curl found.
#]=======================================================================]
+find_package(PkgConfig QUIET)
+if(PKG_CONFIG_FOUND)
+ pkg_check_modules(PC_CURL QUIET libcurl)
+ if(PC_CURL_FOUND)
+ set(CURL_VERSION_STRING ${PC_CURL_VERSION})
+ pkg_get_variable(CURL_SUPPORTED_PROTOCOLS libcurl supported_protocols)
+ pkg_get_variable(CURL_SUPPORTED_FEATURES libcurl supported_features)
+ endif()
+endif()
+
# Look for the header file.
-find_path(CURL_INCLUDE_DIR NAMES curl/curl.h)
+find_path(CURL_INCLUDE_DIR
+ NAMES curl/curl.h
+ HINTS ${PC_CURL_INCLUDE_DIRS})
mark_as_advanced(CURL_INCLUDE_DIR)
if(NOT CURL_LIBRARY)
@@ -45,6 +65,7 @@ if(NOT CURL_LIBRARY)
curllib_static
# Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip):
libcurl
+ HINTS ${PC_CURL_LIBRARY_DIRS}
)
mark_as_advanced(CURL_LIBRARY_RELEASE)
@@ -52,6 +73,7 @@ if(NOT CURL_LIBRARY)
# Windows MSVC CMake builds in debug configuration on vcpkg:
libcurl-d_imp
libcurl-d
+ HINTS ${PC_CURL_LIBRARY_DIRS}
)
mark_as_advanced(CURL_LIBRARY_DEBUG)
@@ -59,7 +81,7 @@ if(NOT CURL_LIBRARY)
select_library_configurations(CURL)
endif()
-if(CURL_INCLUDE_DIR)
+if(CURL_INCLUDE_DIR AND NOT CURL_VERSION_STRING)
foreach(_curl_version_header curlver.h curl.h)
if(EXISTS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}")
file(STRINGS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}" curl_version_str REGEX "^#define[\t ]+LIBCURL_VERSION[\t ]+\".*\"")
@@ -71,10 +93,57 @@ if(CURL_INCLUDE_DIR)
endforeach()
endif()
+if(CURL_FIND_COMPONENTS)
+ set(CURL_KNOWN_PROTOCOLS ICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS LDAP LDAPS POP3 POP3S RTMP RTSP SCP SFTP SMB SMBS SMTP SMTPS TELNET TFTP)
+ set(CURL_KNOWN_FEATURES SSL IPv6 UnixSockets libz AsynchDNS IDN GSS-API PSL SPNEGO Kerberos NTLM NTLM_WB TLS-SRP HTTP2 HTTPS-proxy)
+ foreach(component IN LISTS CURL_KNOWN_PROTOCOLS CURL_KNOWN_FEATURES)
+ set(CURL_${component}_FOUND FALSE)
+ endforeach()
+ if(NOT PC_CURL_FOUND)
+ find_program(CURL_CONFIG_EXECUTABLE NAMES curl-config)
+ if(CURL_CONFIG_EXECUTABLE)
+ execute_process(COMMAND ${CURL_CONFIG_EXECUTABLE} --version
+ OUTPUT_VARIABLE CURL_CONFIG_VERSION_STRING
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ execute_process(COMMAND ${CURL_CONFIG_EXECUTABLE} --feature
+ OUTPUT_VARIABLE CURL_CONFIG_FEATURES_STRING
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REPLACE "\n" ";" CURL_CONFIG_FEATURES "${CURL_CONFIG_FEATURES_STRING}")
+ execute_process(COMMAND ${CURL_CONFIG_EXECUTABLE} --protocols
+ OUTPUT_VARIABLE CURL_CONFIG_PROTOCOLS_STRING
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REPLACE "\n" ";" CURL_CONFIG_PROTOCOLS "${CURL_CONFIG_PROTOCOLS_STRING}")
+ endif()
+
+ endif()
+ foreach(component IN LISTS CURL_FIND_COMPONENTS)
+ list(FIND CURL_KNOWN_PROTOCOLS ${component} _found)
+ if(_found)
+ list(FIND CURL_SUPPORTED_PROTOCOLS ${component} _found)
+ if(_found)
+ set(CURL_${component}_FOUND TRUE)
+ elseif(CURL_FIND_REQUIRED)
+ message(FATAL_ERROR "CURL: Required protocol ${component} is not found")
+ endif()
+ else()
+ list(FIND CURL_SUPPORTED_FEATURES ${component} _found)
+ if(_found)
+ set(CURL_${component}_FOUND TRUE)
+ elseif(CURL_FIND_REQUIRED)
+ message(FATAL_ERROR "CURL: Required feature ${component} is not found")
+ endif()
+ endif()
+ endforeach()
+endif()
+
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(CURL
+find_package_handle_standard_args(CURL
REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR
- VERSION_VAR CURL_VERSION_STRING)
+ VERSION_VAR CURL_VERSION_STRING
+ HANDLE_COMPONENTS)
if(CURL_FOUND)
set(CURL_LIBRARIES ${CURL_LIBRARY})