From 9fbda4ca75483ee0a43289526e88d8f1e8ca2a78 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 16 Aug 2024 18:56:49 +0200 Subject: [PATCH] cmake: rename wolfSSL and zstd config variables to uppercase To match with other config variables and other projects. Rename these CMake configuration variables: - `WolfSSL_INCLUDE_DIR` -> `WOLFSSL_INCLUDE_DIR` - `WolfSSL_LIBRARY` -> `WOLFSSL_LIBRARY` - `Zstd_INCLUDE_DIR` -> `ZSTD_INCLUDE_DIR` - `Zstd_LIBRARY` -> `ZSTD_LIBRARY` The old values continue to work, with a warning suggesting the new name. Also: - add similar warnings for earlier renames for mbedTLS and BearSSL. - rename internal variables `PC_Zstd_*` to uppercase. Follow-up to db39c668a8e33e064b9eb20892cd027f46302f77 #14542 Closes #14574 --- CMake/FindBearSSL.cmake | 2 +- CMake/FindMbedTLS.cmake | 2 +- CMake/FindWolfSSL.cmake | 45 ++++++++++++++++++------------ CMake/FindZstd.cmake | 61 ++++++++++++++++++++++++----------------- CMakeLists.txt | 14 +++++----- 5 files changed, 73 insertions(+), 51 deletions(-) diff --git a/CMake/FindBearSSL.cmake b/CMake/FindBearSSL.cmake index 4dd3817c89..2e25182c34 100644 --- a/CMake/FindBearSSL.cmake +++ b/CMake/FindBearSSL.cmake @@ -29,8 +29,8 @@ # BEARSSL_INCLUDE_DIRS The bearssl include directories # BEARSSL_LIBRARIES The bearssl library names -# for compatibility. Configuration via BEARSSL_INCLUDE_DIRS is deprecated, use BEARSSL_INCLUDE_DIR instead. if(DEFINED BEARSSL_INCLUDE_DIRS AND NOT DEFINED BEARSSL_INCLUDE_DIR) + message(WARNING "BEARSSL_INCLUDE_DIRS is deprecated, use BEARSSL_INCLUDE_DIR instead.") set(BEARSSL_INCLUDE_DIR "${BEARSSL_INCLUDE_DIRS}") unset(BEARSSL_INCLUDE_DIRS) endif() diff --git a/CMake/FindMbedTLS.cmake b/CMake/FindMbedTLS.cmake index 90d6a24d45..3376b2cee8 100644 --- a/CMake/FindMbedTLS.cmake +++ b/CMake/FindMbedTLS.cmake @@ -30,8 +30,8 @@ # MBEDTLS_LIBRARIES The mbedtls library names # MBEDTLS_VERSION Version of mbedtls -# for compatibility. Configuration via MBEDTLS_INCLUDE_DIRS is deprecated, use MBEDTLS_INCLUDE_DIR instead. if(DEFINED MBEDTLS_INCLUDE_DIRS AND NOT DEFINED MBEDTLS_INCLUDE_DIR) + message(WARNING "MBEDTLS_INCLUDE_DIRS is deprecated, use MBEDTLS_INCLUDE_DIR instead.") set(MBEDTLS_INCLUDE_DIR "${MBEDTLS_INCLUDE_DIRS}") unset(MBEDTLS_INCLUDE_DIRS) endif() diff --git a/CMake/FindWolfSSL.cmake b/CMake/FindWolfSSL.cmake index 2136a456b2..c4f28dfaa9 100644 --- a/CMake/FindWolfSSL.cmake +++ b/CMake/FindWolfSSL.cmake @@ -25,35 +25,46 @@ # # Result Variables: # -# WolfSSL_FOUND System has wolfssl -# WolfSSL_INCLUDE_DIRS The wolfssl include directories -# WolfSSL_LIBRARIES The wolfssl library names -# WolfSSL_VERSION Version of wolfssl +# WOLFSSL_FOUND System has wolfssl +# WOLFSSL_INCLUDE_DIRS The wolfssl include directories +# WOLFSSL_LIBRARIES The wolfssl library names +# WOLFSSL_VERSION Version of wolfssl + +if(DEFINED WolfSSL_INCLUDE_DIR AND NOT DEFINED WOLFSSL_INCLUDE_DIR) + message(WARNING "WolfSSL_INCLUDE_DIR is deprecated, use WOLFSSL_INCLUDE_DIR instead.") + set(WOLFSSL_INCLUDE_DIR "${WolfSSL_INCLUDE_DIR}") + unset(WolfSSL_INCLUDE_DIR) +endif() +if(DEFINED WolfSSL_LIBRARY AND NOT DEFINED WOLFSSL_LIBRARY) + message(WARNING "WolfSSL_LIBRARY is deprecated, use WOLFSSL_LIBRARY instead.") + set(WOLFSSL_LIBRARY "${WolfSSL_LIBRARY}") + unset(WolfSSL_LIBRARY) +endif() if(CURL_USE_PKGCONFIG) find_package(PkgConfig QUIET) pkg_check_modules(PC_WOLFSSL QUIET "wolfssl") endif() -find_path(WolfSSL_INCLUDE_DIR NAMES "wolfssl/ssl.h" +find_path(WOLFSSL_INCLUDE_DIR NAMES "wolfssl/ssl.h" HINTS ${PC_WOLFSSL_INCLUDEDIR} ${PC_WOLFSSL_INCLUDE_DIRS} ) -find_library(WolfSSL_LIBRARY NAMES "wolfssl" +find_library(WOLFSSL_LIBRARY NAMES "wolfssl" HINTS ${PC_WOLFSSL_LIBDIR} ${PC_WOLFSSL_LIBRARY_DIRS} ) if(PC_WOLFSSL_VERSION) - set(WolfSSL_VERSION ${PC_WOLFSSL_VERSION}) -elseif(WolfSSL_INCLUDE_DIR AND EXISTS "${WolfSSL_INCLUDE_DIR}/wolfssl/version.h") + set(WOLFSSL_VERSION ${PC_WOLFSSL_VERSION}) +elseif(WOLFSSL_INCLUDE_DIR AND EXISTS "${WOLFSSL_INCLUDE_DIR}/wolfssl/version.h") set(_version_regex "#[\t ]*define[\t ]+LIBWOLFSSL_VERSION_STRING[\t ]+\"([^\"]*)\"") - file(STRINGS "${WolfSSL_INCLUDE_DIR}/wolfssl/version.h" _version_str REGEX "${_version_regex}") + file(STRINGS "${WOLFSSL_INCLUDE_DIR}/wolfssl/version.h" _version_str REGEX "${_version_regex}") string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}") - set(WolfSSL_VERSION "${_version_str}") + set(WOLFSSL_VERSION "${_version_str}") unset(_version_regex) unset(_version_str) endif() @@ -61,15 +72,15 @@ endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(WolfSSL REQUIRED_VARS - WolfSSL_INCLUDE_DIR - WolfSSL_LIBRARY + WOLFSSL_INCLUDE_DIR + WOLFSSL_LIBRARY VERSION_VAR - WolfSSL_VERSION + WOLFSSL_VERSION ) -if(WolfSSL_FOUND) - set(WolfSSL_INCLUDE_DIRS ${WolfSSL_INCLUDE_DIR}) - set(WolfSSL_LIBRARIES ${WolfSSL_LIBRARY}) +if(WOLFSSL_FOUND) + set(WOLFSSL_INCLUDE_DIRS ${WOLFSSL_INCLUDE_DIR}) + set(WOLFSSL_LIBRARIES ${WOLFSSL_LIBRARY}) endif() -mark_as_advanced(WolfSSL_INCLUDE_DIR WolfSSL_LIBRARY) +mark_as_advanced(WOLFSSL_INCLUDE_DIR WOLFSSL_LIBRARY) diff --git a/CMake/FindZstd.cmake b/CMake/FindZstd.cmake index acd2d6a305..72feb30c09 100644 --- a/CMake/FindZstd.cmake +++ b/CMake/FindZstd.cmake @@ -25,41 +25,52 @@ # # Result Variables: # -# Zstd_FOUND System has zstd -# Zstd_INCLUDE_DIRS The zstd include directories -# Zstd_LIBRARIES The zstd library names -# Zstd_VERSION Version of zstd +# ZSTD_FOUND System has zstd +# ZSTD_INCLUDE_DIRS The zstd include directories +# ZSTD_LIBRARIES The zstd library names +# ZSTD_VERSION Version of zstd + +if(DEFINED Zstd_INCLUDE_DIR AND NOT DEFINED ZSTD_INCLUDE_DIR) + message(WARNING "Zstd_INCLUDE_DIR is deprecated, use ZSTD_INCLUDE_DIR instead.") + set(ZSTD_INCLUDE_DIR "${Zstd_INCLUDE_DIR}") + unset(Zstd_INCLUDE_DIR) +endif() +if(DEFINED Zstd_LIBRARY AND NOT DEFINED ZSTD_LIBRARY) + message(WARNING "Zstd_LIBRARY is deprecated, use ZSTD_LIBRARY instead.") + set(ZSTD_LIBRARY "${Zstd_LIBRARY}") + unset(Zstd_LIBRARY) +endif() if(CURL_USE_PKGCONFIG) find_package(PkgConfig QUIET) - pkg_check_modules(PC_Zstd "libzstd") + pkg_check_modules(PC_ZSTD "libzstd") endif() -find_path(Zstd_INCLUDE_DIR "zstd.h" +find_path(ZSTD_INCLUDE_DIR "zstd.h" HINTS - ${PC_Zstd_INCLUDEDIR} - ${PC_Zstd_INCLUDE_DIRS} + ${PC_ZSTD_INCLUDEDIR} + ${PC_ZSTD_INCLUDE_DIRS} ) -find_library(Zstd_LIBRARY NAMES "zstd" +find_library(ZSTD_LIBRARY NAMES "zstd" HINTS - ${PC_Zstd_LIBDIR} - ${PC_Zstd_LIBRARY_DIRS} + ${PC_ZSTD_LIBDIR} + ${PC_ZSTD_LIBRARY_DIRS} ) -if(PC_Zstd_VERSION) - set(Zstd_VERSION ${PC_Zstd_VERSION}) -elseif(Zstd_INCLUDE_DIR AND EXISTS "${Zstd_INCLUDE_DIR}/zstd.h") +if(PC_ZSTD_VERSION) + set(ZSTD_VERSION ${PC_ZSTD_VERSION}) +elseif(ZSTD_INCLUDE_DIR AND EXISTS "${ZSTD_INCLUDE_DIR}/zstd.h") set(_version_regex1 "#[\t ]*define[ \t]+ZSTD_VERSION_MAJOR[ \t]+([0-9]+).*") set(_version_regex2 "#[\t ]*define[ \t]+ZSTD_VERSION_MINOR[ \t]+([0-9]+).*") set(_version_regex3 "#[\t ]*define[ \t]+ZSTD_VERSION_RELEASE[ \t]+([0-9]+).*") - file(STRINGS "${Zstd_INCLUDE_DIR}/zstd.h" _version_str1 REGEX "${_version_regex1}") - file(STRINGS "${Zstd_INCLUDE_DIR}/zstd.h" _version_str2 REGEX "${_version_regex2}") - file(STRINGS "${Zstd_INCLUDE_DIR}/zstd.h" _version_str3 REGEX "${_version_regex3}") + file(STRINGS "${ZSTD_INCLUDE_DIR}/zstd.h" _version_str1 REGEX "${_version_regex1}") + file(STRINGS "${ZSTD_INCLUDE_DIR}/zstd.h" _version_str2 REGEX "${_version_regex2}") + file(STRINGS "${ZSTD_INCLUDE_DIR}/zstd.h" _version_str3 REGEX "${_version_regex3}") string(REGEX REPLACE "${_version_regex1}" "\\1" _version_str1 "${_version_str1}") string(REGEX REPLACE "${_version_regex2}" "\\1" _version_str2 "${_version_str2}") string(REGEX REPLACE "${_version_regex3}" "\\1" _version_str3 "${_version_str3}") - set(Zstd_VERSION "${_version_str1}.${_version_str2}.${_version_str3}") + set(ZSTD_VERSION "${_version_str1}.${_version_str2}.${_version_str3}") unset(_version_regex1) unset(_version_regex2) unset(_version_regex3) @@ -71,15 +82,15 @@ endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Zstd REQUIRED_VARS - Zstd_INCLUDE_DIR - Zstd_LIBRARY + ZSTD_INCLUDE_DIR + ZSTD_LIBRARY VERSION_VAR - Zstd_VERSION + ZSTD_VERSION ) -if(Zstd_FOUND) - set(Zstd_INCLUDE_DIRS ${Zstd_INCLUDE_DIR}) - set(Zstd_LIBRARIES ${Zstd_LIBRARY}) +if(ZSTD_FOUND) + set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR}) + set(ZSTD_LIBRARIES ${ZSTD_LIBRARY}) endif() -mark_as_advanced(Zstd_INCLUDE_DIR Zstd_LIBRARY) +mark_as_advanced(ZSTD_INCLUDE_DIR ZSTD_LIBRARY) diff --git a/CMakeLists.txt b/CMakeLists.txt index b8a42a5f8e..b72c7a871f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -594,9 +594,9 @@ if(CURL_USE_WOLFSSL) find_package(WolfSSL REQUIRED) set(_ssl_enabled ON) set(USE_WOLFSSL ON) - list(APPEND CURL_LIBS ${WolfSSL_LIBRARIES}) + list(APPEND CURL_LIBS ${WOLFSSL_LIBRARIES}) list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "wolfssl") - include_directories(${WolfSSL_INCLUDE_DIRS}) + include_directories(${WOLFSSL_INCLUDE_DIRS}) if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "wolfssl") set(_valid_default_ssl_backend TRUE) @@ -688,11 +688,11 @@ option(CURL_ZSTD "Set to ON to enable building curl with zstd support." OFF) set(HAVE_ZSTD OFF) if(CURL_ZSTD) find_package(Zstd REQUIRED) - if(Zstd_FOUND AND NOT Zstd_VERSION VERSION_LESS 1.0.0) + if(ZSTD_FOUND AND NOT ZSTD_VERSION VERSION_LESS 1.0.0) set(HAVE_ZSTD ON) - list(APPEND CURL_LIBS ${Zstd_LIBRARIES}) + list(APPEND CURL_LIBS ${ZSTD_LIBRARIES}) list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "libzstd") - include_directories(${Zstd_INCLUDE_DIRS}) + include_directories(${ZSTD_INCLUDE_DIRS}) else() message(WARNING "zstd v1.0.0 or newer is required, disabling zstd support.") endif() @@ -712,8 +712,8 @@ macro(openssl_check_symbol_exists _symbol _files _variable _extra_libs) list(APPEND CMAKE_REQUIRED_LIBRARIES "bcrypt") # for OpenSSL/LibreSSL endif() elseif(USE_WOLFSSL) - set(CMAKE_REQUIRED_INCLUDES "${WolfSSL_INCLUDE_DIRS}") - set(CMAKE_REQUIRED_LIBRARIES "${WolfSSL_LIBRARIES}") + set(CMAKE_REQUIRED_INCLUDES "${WOLFSSL_INCLUDE_DIRS}") + set(CMAKE_REQUIRED_LIBRARIES "${WOLFSSL_LIBRARIES}") if(HAVE_LIBZ) list(APPEND CMAKE_REQUIRED_INCLUDES "${ZLIB_INCLUDE_DIRS}") # Public wolfSSL headers require zlib headers list(APPEND CMAKE_REQUIRED_LIBRARIES "${ZLIB_LIBRARIES}") -- 2.47.3