|
30 | 30 | # ``CURL_VERSION_STRING``
|
31 | 31 | # The version of curl found.
|
32 | 32 |
|
33 |
| -# Look for the header file. |
34 |
| -find_path(CURL_INCLUDE_DIR NAMES curl/curl.h) |
35 |
| -mark_as_advanced(CURL_INCLUDE_DIR) |
| 33 | +# First, prefer config scripts |
| 34 | +set(_q "") |
| 35 | +if(CURL_FIND_QUIETLY) |
| 36 | + set(_q QUIET) |
| 37 | +endif() |
| 38 | +find_package(CURL ${CURL_FIND_VERSION} CONFIG ${_q}) |
36 | 39 |
|
37 |
| -if(NOT CURL_LIBRARY) |
38 |
| - # Look for the library (sorted from most current/relevant entry to least). |
39 |
| - find_library(CURL_LIBRARY_RELEASE NAMES |
40 |
| - curl |
41 |
| - # Windows MSVC prebuilts: |
42 |
| - curllib |
43 |
| - libcurl_imp |
44 |
| - curllib_static |
45 |
| - # Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip): |
46 |
| - libcurl |
47 |
| - # Static library on Windows |
48 |
| - libcurl_a |
49 |
| - ) |
50 |
| - mark_as_advanced(CURL_LIBRARY_RELEASE) |
| 40 | +if(NOT CURL_FIND_QUIETLY) |
| 41 | + if (NOT CURL_FOUND) |
| 42 | + message(STATUS "Falling back to MODULE search for CURL...") |
| 43 | + else() |
| 44 | + message(STATUS "CURL found in ${CURL_DIR}") |
| 45 | + endif() |
| 46 | +endif() |
51 | 47 |
|
52 |
| - find_library(CURL_LIBRARY_DEBUG NAMES |
53 |
| - # Windows MSVC CMake builds in debug configuration on vcpkg: |
54 |
| - libcurl-d_imp |
55 |
| - libcurl-d |
56 |
| - # Static library on Windows, compiled in debug mode |
57 |
| - libcurl_a_debug |
58 |
| - ) |
59 |
| - mark_as_advanced(CURL_LIBRARY_DEBUG) |
| 48 | +if (NOT CURL_FOUND) |
60 | 49 |
|
61 |
| - include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations_SLIC3R.cmake) |
62 |
| - select_library_configurations_SLIC3R(CURL) |
63 |
| -endif() |
| 50 | + # Look for the header file. |
| 51 | + find_path(CURL_INCLUDE_DIR NAMES curl/curl.h) |
| 52 | + mark_as_advanced(CURL_INCLUDE_DIR) |
64 | 53 |
|
65 |
| -if(CURL_INCLUDE_DIR) |
66 |
| - foreach(_curl_version_header curlver.h curl.h) |
67 |
| - if(EXISTS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}") |
68 |
| - file(STRINGS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}" curl_version_str REGEX "^#define[\t ]+LIBCURL_VERSION[\t ]+\".*\"") |
| 54 | + if(NOT CURL_LIBRARY) |
| 55 | + # Look for the library (sorted from most current/relevant entry to least). |
| 56 | + find_library(CURL_LIBRARY_RELEASE NAMES |
| 57 | + curl |
| 58 | + # Windows MSVC prebuilts: |
| 59 | + curllib |
| 60 | + libcurl_imp |
| 61 | + curllib_static |
| 62 | + # Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip): |
| 63 | + libcurl |
| 64 | + # Static library on Windows |
| 65 | + libcurl_a |
| 66 | + ) |
| 67 | + mark_as_advanced(CURL_LIBRARY_RELEASE) |
69 | 68 |
|
70 |
| - string(REGEX REPLACE "^#define[\t ]+LIBCURL_VERSION[\t ]+\"([^\"]*)\".*" "\\1" CURL_VERSION_STRING "${curl_version_str}") |
71 |
| - unset(curl_version_str) |
72 |
| - break() |
73 |
| - endif() |
74 |
| - endforeach() |
75 |
| -endif() |
| 69 | + find_library(CURL_LIBRARY_DEBUG NAMES |
| 70 | + # Windows MSVC CMake builds in debug configuration on vcpkg: |
| 71 | + libcurl-d_imp |
| 72 | + libcurl-d |
| 73 | + # Static library on Windows, compiled in debug mode |
| 74 | + libcurl_a_debug |
| 75 | + ) |
| 76 | + mark_as_advanced(CURL_LIBRARY_DEBUG) |
76 | 77 |
|
77 |
| -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs_SLIC3R.cmake) |
78 |
| -FIND_PACKAGE_HANDLE_STANDARD_ARGS_SLIC3R(CURL |
79 |
| - REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR |
80 |
| - VERSION_VAR CURL_VERSION_STRING) |
| 78 | + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations_SLIC3R.cmake) |
| 79 | + select_library_configurations_SLIC3R(CURL) |
| 80 | + endif() |
81 | 81 |
|
82 |
| -if(CURL_FOUND) |
83 |
| - set(CURL_LIBRARIES ${CURL_LIBRARY}) |
84 |
| - set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR}) |
| 82 | + if(CURL_INCLUDE_DIR) |
| 83 | + foreach(_curl_version_header curlver.h curl.h) |
| 84 | + if(EXISTS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}") |
| 85 | + file(STRINGS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}" curl_version_str REGEX "^#define[\t ]+LIBCURL_VERSION[\t ]+\".*\"") |
85 | 86 |
|
86 |
| - if(NOT TARGET CURL::libcurl) |
87 |
| - add_library(CURL::libcurl UNKNOWN IMPORTED) |
88 |
| - set_target_properties(CURL::libcurl PROPERTIES |
89 |
| - INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}") |
| 87 | + string(REGEX REPLACE "^#define[\t ]+LIBCURL_VERSION[\t ]+\"([^\"]*)\".*" "\\1" CURL_VERSION_STRING "${curl_version_str}") |
| 88 | + unset(curl_version_str) |
| 89 | + break() |
| 90 | + endif() |
| 91 | + endforeach() |
| 92 | + endif() |
90 | 93 |
|
91 |
| - if(EXISTS "${CURL_LIBRARY}") |
92 |
| - set_target_properties(CURL::libcurl PROPERTIES |
93 |
| - IMPORTED_LINK_INTERFACE_LANGUAGES "C" |
94 |
| - IMPORTED_LOCATION "${CURL_LIBRARY}") |
95 |
| - endif() |
96 |
| - if(CURL_LIBRARY_RELEASE) |
97 |
| - set_property(TARGET CURL::libcurl APPEND PROPERTY |
98 |
| - IMPORTED_CONFIGURATIONS RELEASE) |
99 |
| - set_target_properties(CURL::libcurl PROPERTIES |
100 |
| - IMPORTED_LINK_INTERFACE_LANGUAGES "C" |
101 |
| - IMPORTED_LOCATION_RELEASE "${CURL_LIBRARY_RELEASE}") |
102 |
| - endif() |
103 |
| - if(CURL_LIBRARY_DEBUG) |
104 |
| - set_property(TARGET CURL::libcurl APPEND PROPERTY |
105 |
| - IMPORTED_CONFIGURATIONS DEBUG) |
| 94 | + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs_SLIC3R.cmake) |
| 95 | + FIND_PACKAGE_HANDLE_STANDARD_ARGS_SLIC3R(CURL |
| 96 | + REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR |
| 97 | + VERSION_VAR CURL_VERSION_STRING) |
| 98 | + |
| 99 | + if(CURL_FOUND) |
| 100 | + set(CURL_LIBRARIES ${CURL_LIBRARY}) |
| 101 | + set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR}) |
| 102 | + |
| 103 | + if(NOT TARGET CURL::libcurl) |
| 104 | + add_library(CURL::libcurl UNKNOWN IMPORTED) |
106 | 105 | set_target_properties(CURL::libcurl PROPERTIES
|
107 |
| - IMPORTED_LINK_INTERFACE_LANGUAGES "C" |
108 |
| - IMPORTED_LOCATION_DEBUG "${CURL_LIBRARY_DEBUG}") |
| 106 | + INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}") |
| 107 | + |
| 108 | + if(EXISTS "${CURL_LIBRARY}") |
| 109 | + set_target_properties(CURL::libcurl PROPERTIES |
| 110 | + IMPORTED_LINK_INTERFACE_LANGUAGES "C" |
| 111 | + IMPORTED_LOCATION "${CURL_LIBRARY}") |
| 112 | + endif() |
| 113 | + if(CURL_LIBRARY_RELEASE) |
| 114 | + set_property(TARGET CURL::libcurl APPEND PROPERTY |
| 115 | + IMPORTED_CONFIGURATIONS RELEASE) |
| 116 | + set_target_properties(CURL::libcurl PROPERTIES |
| 117 | + IMPORTED_LINK_INTERFACE_LANGUAGES "C" |
| 118 | + IMPORTED_LOCATION_RELEASE "${CURL_LIBRARY_RELEASE}") |
| 119 | + endif() |
| 120 | + if(CURL_LIBRARY_DEBUG) |
| 121 | + set_property(TARGET CURL::libcurl APPEND PROPERTY |
| 122 | + IMPORTED_CONFIGURATIONS DEBUG) |
| 123 | + set_target_properties(CURL::libcurl PROPERTIES |
| 124 | + IMPORTED_LINK_INTERFACE_LANGUAGES "C" |
| 125 | + IMPORTED_LOCATION_DEBUG "${CURL_LIBRARY_DEBUG}") |
| 126 | + endif() |
109 | 127 | endif()
|
110 | 128 | endif()
|
111 |
| -endif() |
| 129 | + |
| 130 | +endif (NOT CURL_FOUND) |
0 commit comments