Skip to content

FindCURL: Fix version string in case of multiple curl installations

Georg requested to merge sercxanto/cmake:qnx710_libcurl into master

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

The issue is triggered when an additional version of libcurl is found in the system and that additional version does not provide a .pc file. It can be reproduced in the following way, e.g. on Ubuntu 18.04 (where libcurl is available as default in version 7.58.0):

  • Install QNX 7.1 under /opt/qnx710
    • QNX 7.1 includes curl 7.77.0 .pc but does not provide .pc files
    • find_package(CURL) sets CURL_VERSION_STRING to 7.58.0 but finds libcurl.so itself under /opt/qnx710
    • -- Found CURL: /opt/qnx710/target/qnx7/x86_64/usr/lib/libcurl.so (found version "7.58.0")
  • Build libcurl version 7.77.0 locally install it to /usr/local and manually delete .pc and .cmake files
    • find_package(CURL) sets CURL_VERSION_STRING to 7.58.0 but finds libcurl.so itself under /usr/local
    • -- Found CURL: /usr/local/lib/libcurl.so (found version "7.58.0")

Topic-rename: FindCURL-version-string

Edited by Brad King

Merge request reports