cmake: publish/check supported protocols/features via CURLConfig.cmake
Via these variables, as lists: - `CURL_SUPPORTED_PROTOCOLS` - `CURL_SUPPORTED_FEATURES` As individual flags: - `CURL_SUPPORTS_<protocol/feature>` = `TRUE` Also: - set `CURL_VERSION_STRING` which was missing when using `find_package(CURL CONFIG)` or `find_package(CURL NO_MODULE)`. - set `CURL_<prototol/feature>_FOUND` for compatibility. - show full list of missing but required `COMPONENTS`. Assisted-by: Derek Huang Fixes #15854 Closes #15858
This commit is contained in:
parent
f62be9cfb6
commit
699ac9430c
@ -39,7 +39,6 @@ if("@HAVE_LIBZ@")
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
|
||||||
check_required_components("@PROJECT_NAME@")
|
|
||||||
|
|
||||||
# Alias for either shared or static library
|
# Alias for either shared or static library
|
||||||
if(NOT TARGET @PROJECT_NAME@::libcurl)
|
if(NOT TARGET @PROJECT_NAME@::libcurl)
|
||||||
@ -47,5 +46,32 @@ if(NOT TARGET @PROJECT_NAME@::libcurl)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# For compatibility with CMake's FindCURL.cmake
|
# For compatibility with CMake's FindCURL.cmake
|
||||||
|
set(CURL_VERSION_STRING "@CURLVERSION@")
|
||||||
set(CURL_LIBRARIES @PROJECT_NAME@::libcurl)
|
set(CURL_LIBRARIES @PROJECT_NAME@::libcurl)
|
||||||
set_and_check(CURL_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
|
set_and_check(CURL_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
|
||||||
|
|
||||||
|
set(CURL_SUPPORTED_PROTOCOLS "@CURL_SUPPORTED_PROTOCOLS_LIST@")
|
||||||
|
set(CURL_SUPPORTED_FEATURES "@CURL_SUPPORTED_FEATURES_LIST@")
|
||||||
|
|
||||||
|
foreach(_item IN LISTS CURL_SUPPORTED_PROTOCOLS CURL_SUPPORTED_FEATURES)
|
||||||
|
set(CURL_SUPPORTS_${_item} TRUE)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(_missing_req "")
|
||||||
|
foreach(_item IN LISTS CURL_FIND_COMPONENTS)
|
||||||
|
if(CURL_SUPPORTS_${_item})
|
||||||
|
set(CURL_${_item}_FOUND TRUE)
|
||||||
|
elseif(CURL_FIND_REQUIRED_${_item})
|
||||||
|
list(APPEND _missing_req ${_item})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(_missing_req)
|
||||||
|
string(REPLACE ";" " " _missing_req "${_missing_req}")
|
||||||
|
if(CURL_FIND_REQUIRED)
|
||||||
|
message(FATAL_ERROR "CURL: missing required components: ${_missing_req}")
|
||||||
|
endif()
|
||||||
|
unset(_missing_req)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
check_required_components("@PROJECT_NAME@")
|
||||||
|
|||||||
@ -2042,6 +2042,7 @@ curl_add_if("WSS" NOT CURL_DISABLE_WEBSOCKETS AND _ssl_enabled)
|
|||||||
if(_items)
|
if(_items)
|
||||||
list(SORT _items)
|
list(SORT _items)
|
||||||
endif()
|
endif()
|
||||||
|
set(CURL_SUPPORTED_PROTOCOLS_LIST "${_items}")
|
||||||
string(REPLACE ";" " " SUPPORT_PROTOCOLS "${_items}")
|
string(REPLACE ";" " " SUPPORT_PROTOCOLS "${_items}")
|
||||||
string(TOLOWER "${SUPPORT_PROTOCOLS}" _support_protocols_lower)
|
string(TOLOWER "${SUPPORT_PROTOCOLS}" _support_protocols_lower)
|
||||||
message(STATUS "Protocols: ${_support_protocols_lower}")
|
message(STATUS "Protocols: ${_support_protocols_lower}")
|
||||||
@ -2095,6 +2096,7 @@ if(_items)
|
|||||||
list(SORT _items)
|
list(SORT _items)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
set(CURL_SUPPORTED_FEATURES_LIST "${_items}")
|
||||||
string(REPLACE ";" " " SUPPORT_FEATURES "${_items}")
|
string(REPLACE ";" " " SUPPORT_FEATURES "${_items}")
|
||||||
message(STATUS "Features: ${SUPPORT_FEATURES}")
|
message(STATUS "Features: ${SUPPORT_FEATURES}")
|
||||||
|
|
||||||
@ -2349,10 +2351,13 @@ if(NOT CURL_DISABLE_INSTALL)
|
|||||||
${_generated_version_config}")
|
${_generated_version_config}")
|
||||||
|
|
||||||
# Consumed custom variables:
|
# Consumed custom variables:
|
||||||
|
# CURLVERSION
|
||||||
# LIB_SELECTED
|
# LIB_SELECTED
|
||||||
# TARGETS_EXPORT_NAME
|
# TARGETS_EXPORT_NAME
|
||||||
# USE_OPENSSL
|
# USE_OPENSSL
|
||||||
# HAVE_LIBZ
|
# HAVE_LIBZ
|
||||||
|
# CURL_SUPPORTED_FEATURES_LIST
|
||||||
|
# CURL_SUPPORTED_PROTOCOLS_LIST
|
||||||
configure_package_config_file("CMake/curl-config.cmake.in"
|
configure_package_config_file("CMake/curl-config.cmake.in"
|
||||||
"${_project_config}"
|
"${_project_config}"
|
||||||
INSTALL_DESTINATION ${_install_cmake_dir}
|
INSTALL_DESTINATION ${_install_cmake_dir}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user