diff options
author | Hiroshi Miura <miurahr@linux.com> | 2018-06-27 17:02:54 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-07-03 17:40:49 (GMT) |
commit | 59b3e78451a1b19b95f7cb40fbd19454ace7f483 (patch) | |
tree | b93f3d3135c9f3d79dc3ca03ec7be189bdc15875 /Modules/FindCURL.cmake | |
parent | 6a9fe250a7a56f98d6af081ca172cfc28d127206 (diff) | |
download | CMake-59b3e78451a1b19b95f7cb40fbd19454ace7f483.zip CMake-59b3e78451a1b19b95f7cb40fbd19454ace7f483.tar.gz CMake-59b3e78451a1b19b95f7cb40fbd19454ace7f483.tar.bz2 |
FindCURL: Find debug and release variants separately
Fixes: #17887
Diffstat (limited to 'Modules/FindCURL.cmake')
-rw-r--r-- | Modules/FindCURL.cmake | 56 |
1 files changed, 43 insertions, 13 deletions
diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake index 0bd47f7..60ddf7b 100644 --- a/Modules/FindCURL.cmake +++ b/Modules/FindCURL.cmake @@ -34,17 +34,29 @@ find_path(CURL_INCLUDE_DIR NAMES curl/curl.h) mark_as_advanced(CURL_INCLUDE_DIR) -# Look for the library (sorted from most current/relevant entry to least). -find_library(CURL_LIBRARY NAMES - curl - # Windows MSVC prebuilts: - curllib - libcurl_imp - curllib_static - # Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip): - libcurl -) -mark_as_advanced(CURL_LIBRARY) +if(NOT CURL_LIBRARY) + # Look for the library (sorted from most current/relevant entry to least). + find_library(CURL_LIBRARY_RELEASE NAMES + curl + # Windows MSVC prebuilts: + curllib + libcurl_imp + curllib_static + # Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip): + libcurl + ) + mark_as_advanced(CURL_LIBRARY_RELEASE) + + find_library(CURL_LIBRARY_DEBUG NAMES + # Windows MSVC CMake builds in debug configuration on vcpkg: + libcurl-d_imp + libcurl-d + ) + mark_as_advanced(CURL_LIBRARY_DEBUG) + + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + select_library_configurations(CURL) +endif() if(CURL_INCLUDE_DIR) foreach(_curl_version_header curlver.h curl.h) @@ -71,7 +83,25 @@ if(CURL_FOUND) add_library(CURL::libcurl UNKNOWN IMPORTED) set_target_properties(CURL::libcurl PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}") - set_property(TARGET CURL::libcurl PROPERTY - IMPORTED_LOCATION "${CURL_LIBRARY}") + + if(EXISTS "${CURL_LIBRARY}") + set_target_properties(CURL::libcurl PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${CURL_LIBRARY}") + endif() + if(CURL_LIBRARY_RELEASE) + set_property(TARGET CURL::libcurl APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(CURL::libcurl PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION_RELEASE "${CURL_LIBRARY_RELEASE}") + endif() + if(CURL_LIBRARY_DEBUG) + set_property(TARGET CURL::libcurl APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(CURL::libcurl PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION_DEBUG "${CURL_LIBRARY_DEBUG}") + endif() endif() endif() |