FindCURL: Add CURL_VERSION variable to match upstream cmake package

`find_package(CURL CONFIG)` provides `CURL_VERSION` from the upstream
cmake package version file.

Upstream curl commit `699ac9430c` (cmake: publish/check supported
protocols/features via `CURLConfig.cmake`, 2024-12-29) extends the
upstream cmake package to provide our old `CURL_VERSION_STRING`.
Provide both names from CMake's own module to aid transition.

Fixes: #26634
This commit is contained in:
Brad King
2025-01-28 09:45:18 -05:00
parent aeff709a27
commit d039da1c24
3 changed files with 21 additions and 3 deletions

View File

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