diff --git a/CMake/FindCARES.cmake b/CMake/FindCARES.cmake index c836d0099e..bbc942a2be 100644 --- a/CMake/FindCARES.cmake +++ b/CMake/FindCARES.cmake @@ -49,6 +49,13 @@ find_library(CARES_LIBRARY NAMES ${CARES_NAMES} "cares" if(PC_CARES_VERSION) set(CARES_VERSION ${PC_CARES_VERSION}) +elseif(CARES_INCLUDE_DIR AND EXISTS "${CARES_INCLUDE_DIR}/ares_version.h") + set(_version_regex "#[\t ]*define[\t ]+ARES_VERSION_STR[\t ]+\"([^\"]*)\"") + file(STRINGS "${CARES_INCLUDE_DIR}/ares_version.h" _version_str REGEX "${_version_regex}") + string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}") + set(CARES_VERSION "${_version_str}") + unset(_version_regex) + unset(_version_str) endif() include(FindPackageHandleStandardArgs) diff --git a/CMake/FindLibPSL.cmake b/CMake/FindLibPSL.cmake index 7a61ebc6f2..75268aa5cd 100644 --- a/CMake/FindLibPSL.cmake +++ b/CMake/FindLibPSL.cmake @@ -47,7 +47,9 @@ find_library(LIBPSL_LIBRARY NAMES "psl" "libpsl" ${PC_LIBPSL_LIBRARY_DIRS} ) -if(LIBPSL_INCLUDE_DIR) +if(PC_LIBPSL_VERSION) + set(LIBPSL_VERSION ${PC_LIBPSL_VERSION}) +elseif(LIBPSL_INCLUDE_DIR) file(STRINGS "${LIBPSL_INCLUDE_DIR}/libpsl.h" _libpsl_version_str REGEX "^#define[\t ]+PSL_VERSION[\t ]+\"(.*)\"") string(REGEX REPLACE "^.*\"([^\"]+)\"" "\\1" LIBPSL_VERSION "${_libpsl_version_str}") unset(_libpsl_version_str) diff --git a/CMake/FindLibSSH2.cmake b/CMake/FindLibSSH2.cmake index cdb0d3fdf1..22e35ee3bc 100644 --- a/CMake/FindLibSSH2.cmake +++ b/CMake/FindLibSSH2.cmake @@ -47,7 +47,9 @@ find_library(LIBSSH2_LIBRARY NAMES "ssh2" "libssh2" ${PC_LIBSSH2_LIBRARY_DIRS} ) -if(LIBSSH2_INCLUDE_DIR) +if(PC_LIBSSH2_VERSION) + set(LIBSSH2_VERSION ${PC_LIBSSH2_VERSION}) +elseif(LIBSSH2_INCLUDE_DIR) file(STRINGS "${LIBSSH2_INCLUDE_DIR}/libssh2.h" _libssh2_version_str REGEX "^#define[\t ]+LIBSSH2_VERSION[\t ]+\"(.*)\"") string(REGEX REPLACE "^.*\"([^\"]+)\"" "\\1" LIBSSH2_VERSION "${_libssh2_version_str}") unset(_libssh2_version_str) diff --git a/CMake/FindMbedTLS.cmake b/CMake/FindMbedTLS.cmake index 1383fcdd0d..b65885a674 100644 --- a/CMake/FindMbedTLS.cmake +++ b/CMake/FindMbedTLS.cmake @@ -65,6 +65,23 @@ find_library(MBEDCRYPTO_LIBRARY "mbedcrypto" if(PC_MBEDTLS_VERSION) set(MBEDTLS_VERSION ${PC_MBEDTLS_VERSION}) +elseif(MBEDTLS_INCLUDE_DIR) + if(EXISTS "${MBEDTLS_INCLUDE_DIR}/mbedtls/build_info.h") # 3.x + set(_version_header "${MBEDTLS_INCLUDE_DIR}/mbedtls/build_info.h") + elseif(EXISTS "${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h") # 2.x + set(_version_header "${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h") + else() + unset(_version_header) + endif() + if(_version_header) + set(_version_regex "#[\t ]*define[\t ]+MBEDTLS_VERSION_STRING[\t ]+\"([0-9.]+)\"") + file(STRINGS "${_version_header}" _version_str REGEX "${_version_regex}") + string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}") + set(MBEDTLS_VERSION "${_version_str}") + unset(_version_regex) + unset(_version_str) + unset(_version_header) + endif() endif() include(FindPackageHandleStandardArgs) diff --git a/CMake/FindNGHTTP2.cmake b/CMake/FindNGHTTP2.cmake index 4217416f81..b85b43f98a 100644 --- a/CMake/FindNGHTTP2.cmake +++ b/CMake/FindNGHTTP2.cmake @@ -49,6 +49,13 @@ find_library(NGHTTP2_LIBRARY NAMES "nghttp2" "nghttp2_static" if(PC_NGHTTP2_VERSION) set(NGHTTP2_VERSION ${PC_NGHTTP2_VERSION}) +elseif(NGHTTP2_INCLUDE_DIR AND EXISTS "${NGHTTP2_INCLUDE_DIR}/nghttp2/nghttp2ver.h") + set(_version_regex "#[\t ]*define[\t ]+NGHTTP2_VERSION[\t ]+\"([^\"]*)\"") + file(STRINGS "${NGHTTP2_INCLUDE_DIR}/nghttp2/nghttp2ver.h" _version_str REGEX "${_version_regex}") + string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}") + set(NGHTTP2_VERSION "${_version_str}") + unset(_version_regex) + unset(_version_str) endif() include(FindPackageHandleStandardArgs) diff --git a/CMake/FindNGHTTP3.cmake b/CMake/FindNGHTTP3.cmake index f29e4038b7..b92936de98 100644 --- a/CMake/FindNGHTTP3.cmake +++ b/CMake/FindNGHTTP3.cmake @@ -49,6 +49,13 @@ find_library(NGHTTP3_LIBRARY NAMES "nghttp3" if(PC_NGHTTP3_VERSION) set(NGHTTP3_VERSION ${PC_NGHTTP3_VERSION}) +elseif(NGHTTP3_INCLUDE_DIR AND EXISTS "${NGHTTP3_INCLUDE_DIR}/nghttp3/version.h") + set(_version_regex "#[\t ]*define[\t ]+NGHTTP3_VERSION[\t ]+\"([^\"]*)\"") + file(STRINGS "${NGHTTP3_INCLUDE_DIR}/nghttp3/version.h" _version_str REGEX "${_version_regex}") + string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}") + set(NGHTTP3_VERSION "${_version_str}") + unset(_version_regex) + unset(_version_str) endif() include(FindPackageHandleStandardArgs) diff --git a/CMake/FindNGTCP2.cmake b/CMake/FindNGTCP2.cmake index 67b8f9c9a0..1f584841f7 100644 --- a/CMake/FindNGTCP2.cmake +++ b/CMake/FindNGTCP2.cmake @@ -57,6 +57,13 @@ find_library(NGTCP2_LIBRARY NAMES "ngtcp2" if(PC_NGTCP2_VERSION) set(NGTCP2_VERSION ${PC_NGTCP2_VERSION}) +elseif(NGTCP2_INCLUDE_DIR AND EXISTS "${NGTCP2_INCLUDE_DIR}/ngtcp2/version.h") + set(_version_regex "#[\t ]*define[\t ]+NGTCP2_VERSION[\t ]+\"([^\"]*)\"") + file(STRINGS "${NGTCP2_INCLUDE_DIR}/ngtcp2/version.h" _version_str REGEX "${_version_regex}") + string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}") + set(NGTCP2_VERSION "${_version_str}") + unset(_version_regex) + unset(_version_str) endif() if(NGTCP2_FIND_COMPONENTS) diff --git a/CMake/FindWolfSSL.cmake b/CMake/FindWolfSSL.cmake index 51b3c2f264..6e827b16ae 100644 --- a/CMake/FindWolfSSL.cmake +++ b/CMake/FindWolfSSL.cmake @@ -47,7 +47,9 @@ find_library(WolfSSL_LIBRARY NAMES "wolfssl" ${PC_WOLFSSL_LIBRARY_DIRS} ) -if(WolfSSL_INCLUDE_DIR) +if(PC_WOLFSSL_VERSION) + set(WolfSSL_VERSION ${PC_WOLFSSL_VERSION}) +elseif(WolfSSL_INCLUDE_DIR) set(_version_regex "^#define[ \t]+LIBWOLFSSL_VERSION_STRING[ \t]+\"([^\"]+)\".*") file(STRINGS "${WolfSSL_INCLUDE_DIR}/wolfssl/version.h" WolfSSL_VERSION REGEX "${_version_regex}") string(REGEX REPLACE "${_version_regex}" "\\1" WolfSSL_VERSION "${WolfSSL_VERSION}") diff --git a/CMake/FindZstd.cmake b/CMake/FindZstd.cmake index dee8bfbc09..9f812462d3 100644 --- a/CMake/FindZstd.cmake +++ b/CMake/FindZstd.cmake @@ -47,7 +47,9 @@ find_library(Zstd_LIBRARY NAMES "zstd" ${PC_Zstd_LIBRARY_DIRS} ) -if(Zstd_INCLUDE_DIR) +if(PC_ZSTD_VERSION) + set(Zstd_VERSION ${PC_ZSTD_VERSION}) +elseif(Zstd_INCLUDE_DIR) file(READ "${Zstd_INCLUDE_DIR}/zstd.h" _zstd_header) string(REGEX MATCH ".*define ZSTD_VERSION_MAJOR *([0-9]+).*define ZSTD_VERSION_MINOR *([0-9]+).*define ZSTD_VERSION_RELEASE *([0-9]+)" _zstd_ver "${_zstd_header}") set(Zstd_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")