From 1a74f95656e9c66632ff9f5cc18b027852311340 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 13 Aug 2024 14:02:07 -0400 Subject: 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 --- Source/cmFileCommand.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 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); -- cgit v0.12