mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-13 12:59:55 -05:00
Merge topic 'FindCURL-version-var'
d039da1c24 FindCURL: Add CURL_VERSION variable to match upstream cmake package
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10250
This commit is contained in:
5
Help/release/dev/FindCURL-version-var.rst
Normal file
5
Help/release/dev/FindCURL-version-var.rst
Normal file
@@ -0,0 +1,5 @@
|
||||
FindCURL-version-var
|
||||
--------------------
|
||||
|
||||
* The :module:`FindCURL` module now provides a ``CURL_VERSION`` result
|
||||
variable to match upstream cURL's CMake package.
|
||||
@@ -40,8 +40,15 @@ This module defines the following variables:
|
||||
``CURL_LIBRARIES``
|
||||
List of libraries when using ``curl``.
|
||||
|
||||
``CURL_VERSION``
|
||||
.. versionadded:: 4.0
|
||||
|
||||
The version of ``curl`` found.
|
||||
This supersedes ``CURL_VERSION_STRING``.
|
||||
|
||||
``CURL_VERSION_STRING``
|
||||
The version of ``curl`` found.
|
||||
Superseded by ``CURL_VERSION``.
|
||||
|
||||
.. versionadded:: 3.13
|
||||
Debug and Release variants are found separately.
|
||||
@@ -147,7 +154,8 @@ if(CURL_INCLUDE_DIR)
|
||||
if(EXISTS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}")
|
||||
file(STRINGS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}" curl_version_str REGEX "^#define[\t ]+LIBCURL_VERSION[\t ]+\".*\"")
|
||||
|
||||
string(REGEX REPLACE "^#define[\t ]+LIBCURL_VERSION[\t ]+\"([^\"]*)\".*" "\\1" CURL_VERSION_STRING "${curl_version_str}")
|
||||
string(REGEX REPLACE "^#define[\t ]+LIBCURL_VERSION[\t ]+\"([^\"]*)\".*" "\\1" CURL_VERSION "${curl_version_str}")
|
||||
set(CURL_VERSION_STRING "${CURL_VERSION}")
|
||||
unset(curl_version_str)
|
||||
break()
|
||||
endif()
|
||||
@@ -202,7 +210,7 @@ endif()
|
||||
|
||||
find_package_handle_standard_args(CURL
|
||||
REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR
|
||||
VERSION_VAR CURL_VERSION_STRING
|
||||
VERSION_VAR CURL_VERSION
|
||||
HANDLE_COMPONENTS)
|
||||
|
||||
if(CURL_FOUND)
|
||||
|
||||
@@ -4,7 +4,12 @@ include(CTest)
|
||||
|
||||
find_package(CURL REQUIRED COMPONENTS HTTP)
|
||||
|
||||
add_definitions(-DCMAKE_EXPECTED_CURL_VERSION="${CURL_VERSION_STRING}")
|
||||
if(NOT CURL_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.|$)")
|
||||
message(FATAL_ERROR "CURL_VERSION not set")
|
||||
endif()
|
||||
if(NOT CURL_VERSION_STRING MATCHES "^[0-9]+\\.[0-9]+(\\.|$)")
|
||||
message(FATAL_ERROR "CURL_VERSION_STRING not set")
|
||||
endif()
|
||||
|
||||
add_executable(test_tgt main.c)
|
||||
target_link_libraries(test_tgt CURL::libcurl)
|
||||
|
||||
Reference in New Issue
Block a user