]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: sync up result variable names in Find modules
authorViktor Szakats <commit@vsz.me>
Wed, 14 Aug 2024 01:09:08 +0000 (03:09 +0200)
committerViktor Szakats <commit@vsz.me>
Wed, 14 Aug 2024 12:58:58 +0000 (14:58 +0200)
- bearssl, c-ares, gss, libpsl, libssh2, mbedtls:
  Before this patch these Find modules returned results via
  `<NAME>_INCLUDE_DIR` and `<NAME>_LIBRARY`.

  This patch makes them return `<NAME>_INCLUDE_DIRS` (note the `S`)
  and `<NAME>_LIBRARIES` like other modules already did.

- bearssl, mbedtls:
  Before this patch these Find modules allowed custom configuration
  via `<NAME>_INCLUDE_DIRS` (note the `S`).

  This patch makes them accept `<NAME>_INCLUDE_DIR`, like the rest of
  the modules did.

  Deprecate the old variables, but keep accepting them for
  compatibility.

- bearssl: add missing `mark_as_advanced()` call.

Closes #14542

CMake/FindBearSSL.cmake
CMake/FindCARES.cmake
CMake/FindGSS.cmake
CMake/FindLibPSL.cmake
CMake/FindLibSSH2.cmake
CMake/FindMbedTLS.cmake
CMakeLists.txt
lib/CMakeLists.txt
tests/libtest/CMakeLists.txt
tests/server/CMakeLists.txt

index fe77fddb2f70cd6a01e7b93088fd128b46389093..1d8fbce10132171dd8d8c57198e62e0f582042fb 100644 (file)
 # BEARSSL_INCLUDE_DIRS  The bearssl include directories
 # BEARSSL_LIBRARIES     The bearssl library names
 
-find_path(BEARSSL_INCLUDE_DIRS "bearssl.h")
+# 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)
+  set(BEARSSL_INCLUDE_DIR "${BEARSSL_INCLUDE_DIRS}")
+  unset(BEARSSL_INCLUDE_DIRS)
+endif()
+
+find_path(BEARSSL_INCLUDE_DIR "bearssl.h")
 
 find_library(BEARSSL_LIBRARY "bearssl")
 
@@ -40,4 +46,9 @@ find_package_handle_standard_args(BEARSSL
     BEARSSL_LIBRARY
 )
 
-mark_as_advanced(BEARSSL_INCLUDE_DIRS BEARSSL_LIBRARY)
+if(BEARSSL_FOUND)
+  set(BEARSSL_INCLUDE_DIRS ${BEARSSL_INCLUDE_DIR})
+  set(BEARSSL_LIBRARIES    ${BEARSSL_LIBRARY})
+endif()
+
+mark_as_advanced(BEARSSL_INCLUDE_DIR BEARSSL_LIBRARY)
index 12efea9138a48c19493e861884397973094d67b8..24c19d24d63f86b1a2f15074dbb05544526afd9c 100644 (file)
@@ -25,9 +25,9 @@
 #
 # Result Variables:
 #
-# CARES_FOUND        System has c-ares
-# CARES_INCLUDE_DIR  The c-ares include directory
-# CARES_LIBRARY      The c-ares library name
+# CARES_FOUND         System has c-ares
+# CARES_INCLUDE_DIRS  The c-ares include directories
+# CARES_LIBRARIES     The c-ares library names
 
 find_path(CARES_INCLUDE_DIR "ares.h")
 
@@ -40,4 +40,9 @@ find_package_handle_standard_args(CARES
     CARES_LIBRARY
 )
 
+if(CARES_FOUND)
+  set(CARES_INCLUDE_DIRS ${CARES_INCLUDE_DIR})
+  set(CARES_LIBRARIES    ${CARES_LIBRARY})
+endif()
+
 mark_as_advanced(CARES_INCLUDE_DIR CARES_LIBRARY)
index cbd9bbe5c6c8ed1c2cf542db98779f7eb95795d9..3b528eaa01ce2fecdc426e28ff90dfcfc1b1bbea 100644 (file)
@@ -31,7 +31,7 @@
 #
 # GSS_FOUND             System has the Heimdal library
 # GSS_FLAVOUR           "MIT" or "Heimdal" if anything found
-# GSS_INCLUDE_DIR       The GSS include directory
+# GSS_INCLUDE_DIRS      The GSS include directories
 # GSS_LIBRARIES         The GSS library names
 # GSS_LINK_DIRECTORIES  Directories to add to linker search path
 # GSS_LINKER_FLAGS      Additional linker flags
@@ -260,7 +260,7 @@ else()
   endif()
 endif()
 
-set(GSS_INCLUDE_DIR ${_GSS_INCLUDE_DIRS})
+set(GSS_INCLUDE_DIRS ${_GSS_INCLUDE_DIRS})
 set(GSS_LIBRARIES ${_GSS_LIBRARIES})
 set(GSS_LINK_DIRECTORIES ${_GSS_LIBRARY_DIRS})
 set(GSS_LINKER_FLAGS ${_GSS_LDFLAGS})
@@ -275,8 +275,8 @@ if(GSS_FLAVOUR)
       set(_heimdal_manifest_file "Heimdal.Application.x86.manifest")
     endif()
 
-    if(EXISTS "${GSS_INCLUDE_DIR}/${_heimdal_manifest_file}")
-      file(STRINGS "${GSS_INCLUDE_DIR}/${_heimdal_manifest_file}" _heimdal_version_str
+    if(EXISTS "${GSS_INCLUDE_DIRS}/${_heimdal_manifest_file}")
+      file(STRINGS "${GSS_INCLUDE_DIRS}/${_heimdal_manifest_file}" _heimdal_version_str
         REGEX "^.*version=\"[0-9]\\.[^\"]+\".*$")
 
       string(REGEX MATCH "[0-9]\\.[^\"]+" GSS_VERSION "${_heimdal_version_str}")
index 03be5885b8ee1adfc4d342d200cbd3354c6c2786..0f647b114e1dcf016590e4f2c7ed9dfcd889292d 100644 (file)
 #
 # Result Variables:
 #
-# LIBPSL_FOUND        System has libpsl
-# LIBPSL_INCLUDE_DIR  The libpsl include directory
-# LIBPSL_LIBRARY      The libpsl library name
-# LIBPSL_VERSION      Version of libpsl
+# LIBPSL_FOUND         System has libpsl
+# LIBPSL_INCLUDE_DIRS  The libpsl include directories
+# LIBPSL_LIBRARIES     The libpsl library names
+# LIBPSL_VERSION       Version of libpsl
 
 find_path(LIBPSL_INCLUDE_DIR "libpsl.h")
 
@@ -49,4 +49,9 @@ find_package_handle_standard_args(LibPSL
     LIBPSL_VERSION
 )
 
+if(LIBPSL_FOUND)
+  set(LIBPSL_INCLUDE_DIRS ${LIBPSL_INCLUDE_DIR})
+  set(LIBPSL_LIBRARIES    ${LIBPSL_LIBRARY})
+endif()
+
 mark_as_advanced(LIBPSL_INCLUDE_DIR LIBPSL_LIBRARY)
index 05a5bf9c50c03100f0f300ae229dec28db9d96dc..d8375b55d645645e545bd019639a71669525c641 100644 (file)
 #
 # Result Variables:
 #
-# LIBSSH2_FOUND        System has libssh2
-# LIBSSH2_INCLUDE_DIR  The libssh2 include directory
-# LIBSSH2_LIBRARY      The libssh2 library name
-# LIBSSH2_VERSION      Version of libssh2
+# LIBSSH2_FOUND         System has libssh2
+# LIBSSH2_INCLUDE_DIRS  The libssh2 include directories
+# LIBSSH2_LIBRARIES     The libssh2 library names
+# LIBSSH2_VERSION       Version of libssh2
 
 find_path(LIBSSH2_INCLUDE_DIR "libssh2.h")
 
@@ -49,4 +49,9 @@ find_package_handle_standard_args(LibSSH2
     LIBSSH2_VERSION
 )
 
+if(LIBSSH2_FOUND)
+  set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR})
+  set(LIBSSH2_LIBRARIES    ${LIBSSH2_LIBRARY})
+endif()
+
 mark_as_advanced(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY)
index afb98f44d6d608b49123b02330dea8b701c36aac..83c34ec4e3f689d60d91b39da925b05d53741b48 100644 (file)
 # MBEDTLS_INCLUDE_DIRS  The mbedtls include directories
 # MBEDTLS_LIBRARIES     The mbedtls library names
 
-find_path(MBEDTLS_INCLUDE_DIRS "mbedtls/ssl.h")
+# 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)
+  set(MBEDTLS_INCLUDE_DIR "${MBEDTLS_INCLUDE_DIRS}")
+  unset(MBEDTLS_INCLUDE_DIRS)
+endif()
+
+find_path(MBEDTLS_INCLUDE_DIR "mbedtls/ssl.h")
 
 find_library(MBEDTLS_LIBRARY "mbedtls")
 find_library(MBEDX509_LIBRARY "mbedx509")
 find_library(MBEDCRYPTO_LIBRARY "mbedcrypto")
 
-set(MBEDTLS_LIBRARIES "${MBEDTLS_LIBRARY}" "${MBEDX509_LIBRARY}" "${MBEDCRYPTO_LIBRARY}")
-
 include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args(MbedTLS
   REQUIRED_VARS
-    MBEDTLS_INCLUDE_DIRS
+    MBEDTLS_INCLUDE_DIR
     MBEDTLS_LIBRARY
     MBEDX509_LIBRARY
     MBEDCRYPTO_LIBRARY
 )
 
-mark_as_advanced(MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
+if(MBEDTLS_FOUND)
+  set(MBEDTLS_INCLUDE_DIRS ${MBEDTLS_INCLUDE_DIR})
+  set(MBEDTLS_LIBRARIES    ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
+endif()
+
+mark_as_advanced(MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
index ed8097f1498d2189c7147672f4f13745534f7aa8..36616b0b0b7a6b28f544c65cffccdffb372dd376 100644 (file)
@@ -216,7 +216,7 @@ set(LIBCURL_PC_REQUIRES_PRIVATE "")
 if(ENABLE_ARES)
   set(USE_ARES 1)
   find_package(CARES REQUIRED)
-  list(APPEND CURL_LIBS ${CARES_LIBRARY})
+  list(APPEND CURL_LIBS ${CARES_LIBRARIES})
   list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "libcares")
 endif()
 
@@ -568,7 +568,7 @@ if(CURL_USE_BEARSSL)
   find_package(BearSSL REQUIRED)
   set(_ssl_enabled ON)
   set(USE_BEARSSL ON)
-  list(APPEND CURL_LIBS ${BEARSSL_LIBRARY})
+  list(APPEND CURL_LIBS ${BEARSSL_LIBRARIES})
   include_directories(${BEARSSL_INCLUDE_DIRS})
 
   if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "bearssl")
@@ -1019,10 +1019,10 @@ set(USE_LIBPSL OFF)
 if(CURL_USE_LIBPSL)
   find_package(LibPSL)
   if(LIBPSL_FOUND)
-    list(APPEND CURL_LIBS ${LIBPSL_LIBRARY})
+    list(APPEND CURL_LIBS ${LIBPSL_LIBRARIES})
     list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "libpsl")
-    list(APPEND CMAKE_REQUIRED_INCLUDES "${LIBPSL_INCLUDE_DIR}")
-    include_directories(${LIBPSL_INCLUDE_DIR})
+    list(APPEND CMAKE_REQUIRED_INCLUDES "${LIBPSL_INCLUDE_DIRS}")
+    include_directories(${LIBPSL_INCLUDE_DIRS})
     set(USE_LIBPSL ON)
   endif()
 endif()
@@ -1035,10 +1035,10 @@ set(USE_LIBSSH2 OFF)
 if(CURL_USE_LIBSSH2)
   find_package(LibSSH2)
   if(LIBSSH2_FOUND)
-    list(APPEND CURL_LIBS ${LIBSSH2_LIBRARY})
+    list(APPEND CURL_LIBS ${LIBSSH2_LIBRARIES})
     list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "libssh2")
-    list(APPEND CMAKE_REQUIRED_INCLUDES "${LIBSSH2_INCLUDE_DIR}")
-    include_directories(${LIBSSH2_INCLUDE_DIR})
+    list(APPEND CMAKE_REQUIRED_INCLUDES "${LIBSSH2_INCLUDE_DIRS}")
+    include_directories(${LIBSSH2_INCLUDE_DIRS})
     set(USE_LIBSSH2 ON)
   endif()
 endif()
@@ -1093,7 +1093,7 @@ if(CURL_USE_GSSAPI)
 
     message(STATUS "Found ${GSS_FLAVOUR} GSSAPI version: \"${GSS_VERSION}\"")
 
-    list(APPEND CMAKE_REQUIRED_INCLUDES ${GSS_INCLUDE_DIR})
+    list(APPEND CMAKE_REQUIRED_INCLUDES ${GSS_INCLUDE_DIRS})
 
     string(REPLACE ";" " " GSS_COMPILER_FLAGS "${GSS_COMPILER_FLAGS}")
     string(REPLACE ";" " " GSS_LINKER_FLAGS "${GSS_LINKER_FLAGS}")
@@ -1129,7 +1129,7 @@ if(CURL_USE_GSSAPI)
       endif()
     endif()
 
-    include_directories(${GSS_INCLUDE_DIR})
+    include_directories(${GSS_INCLUDE_DIRS})
     link_directories(${GSS_LINK_DIRECTORIES})
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GSS_COMPILER_FLAGS}")
     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GSS_LINKER_FLAGS}")
index f439b42cad620230b3186c9ad4e6133861d1e1f2..52324ba296f6f1e29bd04649c55fff2cea246e33 100644 (file)
@@ -43,7 +43,7 @@ include_directories(
   "${CMAKE_CURRENT_SOURCE_DIR}"
 )
 if(USE_ARES)
-  include_directories(${CARES_INCLUDE_DIR})
+  include_directories(${CARES_INCLUDE_DIRS})
 endif()
 
 if(BUILD_TESTING)
index b24ee1087ebf65817b1681565ebba490b672883a..c3e27ad53f8c425e73343fb5873c3a7c966855c1 100644 (file)
@@ -38,7 +38,7 @@ function(setup_test _test_name)  # ARGN are the files in the test
     "${CURL_SOURCE_DIR}/tests/libtest"  # to be able to build generated tests
   )
   if(USE_ARES)
-    include_directories(${CARES_INCLUDE_DIR})
+    include_directories(${CARES_INCLUDE_DIRS})
   endif()
 
   target_link_libraries(${_test_name} ${LIB_SELECTED} ${CURL_LIBS})
index 33bc6941ec68b4866716fae264fd652ca7b30e90..3e9bcbcda4e1ba23fac4f8b7526130a733572eb0 100644 (file)
@@ -31,7 +31,7 @@ function(setup_executable _test_name)  # ARGN are the files in the test
     "${CURL_SOURCE_DIR}/src"  # for "tool_xattr.h" in disabled_SOURCES
   )
   if(USE_ARES)
-    include_directories(${CARES_INCLUDE_DIR})
+    include_directories(${CARES_INCLUDE_DIRS})
   endif()
 
   target_link_libraries(${_test_name} ${CURL_LIBS})