summaryrefslogtreecommitdiff
path: root/Utilities/cmcurl/CMake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-01-24 14:17:42 -0500
committerBrad King <brad.king@kitware.com>2018-01-24 14:18:16 -0500
commitcd8e31a1bf7429514078c2923a1a9580113f9d4f (patch)
tree6a0b8a01e3e0e52bb4b3abb66ce9e992614af6a7 /Utilities/cmcurl/CMake
parente9c8ea75575afdb4e87b262641ee4071ef42b4c6 (diff)
parentaf9e654045f11028e50dac4781e297834129a749 (diff)
downloadcmake-cd8e31a1bf7429514078c2923a1a9580113f9d4f.tar.gz
Merge branch 'upstream-curl' into update-curl
* upstream-curl: curl 2018-01-23 (d6c21c8e)
Diffstat (limited to 'Utilities/cmcurl/CMake')
-rw-r--r--Utilities/cmcurl/CMake/curl-config.cmake59
1 files changed, 59 insertions, 0 deletions
diff --git a/Utilities/cmcurl/CMake/curl-config.cmake b/Utilities/cmcurl/CMake/curl-config.cmake
new file mode 100644
index 0000000000..119332cddb
--- /dev/null
+++ b/Utilities/cmcurl/CMake/curl-config.cmake
@@ -0,0 +1,59 @@
+
+get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+if(NOT CURL_FIND_COMPONENTS)
+ set(CURL_FIND_COMPONENTS curl libcurl)
+ if(CURL_FIND_REQUIRED)
+ set(CURL_FIND_REQUIRED_curl TRUE)
+ set(CURL_FIND_REQUIRED_libcurl TRUE)
+ endif()
+endif()
+
+set(_curl_missing_components)
+foreach(_comp ${CURL_FIND_COMPONENTS})
+ if(EXISTS "${_DIR}/${_comp}-target.cmake")
+ include("${_DIR}/${_comp}-target.cmake")
+ set(CURL_${_comp}_FOUND TRUE)
+ else()
+ set(CURL_${_comp}_FOUND FALSE)
+ if(CURL_FIND_REQUIRED_${_comp})
+ set(CURL_FOUND FALSE)
+ list(APPEND _curl_missing_components ${_comp})
+ endif()
+ endif()
+endforeach()
+
+if(_curl_missing_components)
+ set(CURL_NOT_FOUND_MESSAGE "Following required components not found: " ${_curl_missing_components})
+else()
+ if(TARGET CURL::libcurl)
+ string(TOUPPER "${CMAKE_BUILD_TYPE}" _curl_current_config)
+ if(NOT _curl_current_config)
+ set(_curl_current_config "NOCONFIG")
+ endif()
+ get_target_property(_curl_configurations CURL::libcurl IMPORTED_CONFIGURATIONS)
+ list(FIND _curl_configurations "${_curl_current_config}" _i)
+ if(_i LESS 0)
+ set(_curl_config "RELEASE")
+ list(FIND _curl_configurations "${_curl_current_config}" _i)
+ if(_i LESS 0)
+ set(_curl_config "NOCONFIG")
+ list(FIND _curl_configurations "${_curl_current_config}" _i)
+ endif()
+ endif()
+
+ if(_i LESS 0)
+ set(_curl_current_config "") # let CMake pick config at random
+ else()
+ set(_curl_current_config "_${_curl_current_config}")
+ endif()
+
+ get_target_property(CURL_INCLUDE_DIRS CURL::libcurl INTERFACE_INCLUDE_DIRECTORIES)
+ get_target_property(CURL_LIBRARIES CURL::libcurl "LOCATION${_curl_current_config}")
+ set(_curl_current_config)
+ set(_curl_configurations)
+ set(_i)
+ endif()
+endif()
+
+unset(_curl_missing_components)