• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
3
4if(NOT CURL_FIND_COMPONENTS)
5    set(CURL_FIND_COMPONENTS curl libcurl)
6    if(CURL_FIND_REQUIRED)
7        set(CURL_FIND_REQUIRED_curl TRUE)
8        set(CURL_FIND_REQUIRED_libcurl TRUE)
9    endif()
10endif()
11
12set(_curl_missing_components)
13foreach(_comp ${CURL_FIND_COMPONENTS})
14    if(EXISTS "${_DIR}/${_comp}-target.cmake")
15        include("${_DIR}/${_comp}-target.cmake")
16        set(CURL_${_comp}_FOUND TRUE)
17    else()
18        set(CURL_${_comp}_FOUND FALSE)
19        if(CURL_FIND_REQUIRED_${_comp})
20            set(CURL_FOUND FALSE)
21            list(APPEND _curl_missing_components ${_comp})
22        endif()
23    endif()
24endforeach()
25
26if(_curl_missing_components)
27    set(CURL_NOT_FOUND_MESSAGE "Following required components not found: " ${_curl_missing_components})
28else()
29    if(TARGET CURL::libcurl)
30        string(TOUPPER "${CMAKE_BUILD_TYPE}" _curl_current_config)
31        if(NOT _curl_current_config)
32            set(_curl_current_config "NOCONFIG")
33        endif()
34        get_target_property(_curl_configurations CURL::libcurl IMPORTED_CONFIGURATIONS)
35        list(FIND _curl_configurations "${_curl_current_config}" _i)
36        if(_i LESS 0)
37            set(_curl_config "RELEASE")
38            list(FIND _curl_configurations "${_curl_current_config}" _i)
39            if(_i LESS 0)
40                set(_curl_config "NOCONFIG")
41                list(FIND _curl_configurations "${_curl_current_config}" _i)
42            endif()
43        endif()
44
45        if(_i LESS 0)
46            set(_curl_current_config "") # let CMake pick config at random
47        else()
48	    set(_curl_current_config "_${_curl_current_config}")
49        endif()
50
51        get_target_property(CURL_INCLUDE_DIRS CURL::libcurl INTERFACE_INCLUDE_DIRECTORIES)
52        get_target_property(CURL_LIBRARIES CURL::libcurl "LOCATION${_curl_current_config}")
53        set(_curl_current_config)
54        set(_curl_configurations)
55        set(_i)
56    endif()
57endif()
58
59unset(_curl_missing_components)
60