diff options
author | Brad King <brad.king@kitware.com> | 2024-08-13 18:02:07 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-08-13 18:14:10 (GMT) |
commit | 1a74f95656e9c66632ff9f5cc18b027852311340 (patch) | |
tree | 0bdd6cc530d2e3b425e63a42c0c1eb8fd2783f99 /Source | |
parent | d88682dff6bf053e5bbdc10accf5d6825303e656 (diff) | |
download | CMake-1a74f95656e9c66632ff9f5cc18b027852311340.zip CMake-1a74f95656e9c66632ff9f5cc18b027852311340.tar.gz CMake-1a74f95656e9c66632ff9f5cc18b027852311340.tar.bz2 |
file(DOWNLOAD): Fix User-Agent to use run-time curl version
If CMake is linked to a system-provided curl shared library, the version
at run-time may not match the `LIBCURL_VERSION` at build time. Look up
the run-time curl version to populate the User-Agent string.
This is particularly important since commit d3cbee99e3 (macOS: Prefer
building with system-provided curl, 2024-05-09, v3.30.0-rc1~130^2~1)
switched to building our official binaries on macOS against the system
provided curl shared library.
Fixes: #26209
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmFileCommand.cxx | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 6265f82..506e9b7 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2131,7 +2131,10 @@ bool HandleDownloadCommand(std::vector<std::string> const& args, res = ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); check_curl_result(res, "DOWNLOAD cannot set http failure option: "); - res = ::curl_easy_setopt(curl, CURLOPT_USERAGENT, "curl/" LIBCURL_VERSION); + curl_version_info_data* cv = curl_version_info(CURLVERSION_FIRST); + res = ::curl_easy_setopt( + curl, CURLOPT_USERAGENT, + cmStrCat("curl/", cv ? cv->version : LIBCURL_VERSION).c_str()); check_curl_result(res, "DOWNLOAD cannot set user agent option: "); res = ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmWriteToFileCallback); |