summaryrefslogtreecommitdiff
path: root/CMake/curl-config.cmake.in
blob: 73e04c606efb76271defeca176f00e23ff727533 (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
63
64

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()

include(CMakeFindDependencyMacro)
if(CURL_FIND_REQUIRED_libcurl)
    find_dependency(OpenSSL "@OPENSSL_VERSION_MAJOR@")
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)