mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-02 03:39:43 -06:00
FindCURL: Fix version string in case of multiple curl installations
On systems where there are two versions of libcurl installed CURL_VERSION_STRING is always set to the version found by the `pkg_check_modules(PC_CURL QUIET libcurl)`. But CURL_VERSION_STRING should match the libs and include paths found by `find_path` and `find_library` (more specifically the path where the header is found, because that where the version is parsed from. So make sure that the version is always parsed from the header file, use the output of pkg_check_modules only as HINT for find_path / find_library.
This commit is contained in:
@@ -82,7 +82,6 @@ find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PC_CURL QUIET libcurl)
|
||||
if(PC_CURL_FOUND)
|
||||
set(CURL_VERSION_STRING ${PC_CURL_VERSION})
|
||||
pkg_get_variable(CURL_SUPPORTED_PROTOCOLS libcurl supported_protocols)
|
||||
pkg_get_variable(CURL_SUPPORTED_FEATURES libcurl supported_features)
|
||||
endif()
|
||||
@@ -122,7 +121,7 @@ if(NOT CURL_LIBRARY)
|
||||
select_library_configurations(CURL)
|
||||
endif()
|
||||
|
||||
if(CURL_INCLUDE_DIR AND NOT CURL_VERSION_STRING)
|
||||
if(CURL_INCLUDE_DIR)
|
||||
foreach(_curl_version_header curlver.h curl.h)
|
||||
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 ]+\".*\"")
|
||||
|
||||
Reference in New Issue
Block a user