mirror of
https://github.com/curl/curl.git
synced 2026-04-14 22:41:40 +03:00
cmake: migrate dependency detections to Find modules
For: libgsasl, libidn2, libssh, libuv. The new Find modules retain using `pkg-config` natively, not as a "hint" for the CMake-native detection. Of the pre-existing Find modules, only FindNettle, and FindGSS (with customized code) work this way. Align detection code for the new modules and add version detection for the CMake-native paths. Also, add CMake-native detection for `libgsasl`. The remaining outlier in `CMakeLists.txt` is GnuTLS, which has a CMake built-in Find module, but which lacks `pkg-config` support, required for vcpkg. It remains unchanged. Another part-outlier is `libssh`, which keeps requiring the trick `find_package(libssh CONFIG QUIET)` for reasons I could not yet figure out. Closes #14555
This commit is contained in:
parent
cd683f9071
commit
422696f0a4
6 changed files with 350 additions and 44 deletions
76
CMake/FindLibidn2.cmake
Normal file
76
CMake/FindLibidn2.cmake
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
#***************************************************************************
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
#
|
||||
# This software is licensed as described in the file COPYING, which
|
||||
# you should have received as part of this distribution. The terms
|
||||
# are also available at https://curl.se/docs/copyright.html.
|
||||
#
|
||||
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
# copies of the Software, and permit persons to whom the Software is
|
||||
# furnished to do so, under the terms of the COPYING file.
|
||||
#
|
||||
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
# KIND, either express or implied.
|
||||
#
|
||||
# SPDX-License-Identifier: curl
|
||||
#
|
||||
###########################################################################
|
||||
# Find the libidn2 library
|
||||
#
|
||||
# Input variables:
|
||||
#
|
||||
# LIBIDN2_INCLUDE_DIR The libidn2 include directory
|
||||
# LIBIDN2_LIBRARY Path to libidn2 library
|
||||
#
|
||||
# Result variables:
|
||||
#
|
||||
# LIBIDN2_FOUND System has libidn2
|
||||
# LIBIDN2_INCLUDE_DIRS The libidn2 include directories
|
||||
# LIBIDN2_LIBRARIES The libidn2 library names
|
||||
# LIBIDN2_VERSION Version of libidn2
|
||||
|
||||
if(CURL_USE_PKGCONFIG AND
|
||||
NOT DEFINED LIBIDN2_INCLUDE_DIR AND
|
||||
NOT DEFINED LIBIDN2_LIBRARY)
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(LIBIDN2 "libidn2")
|
||||
endif()
|
||||
|
||||
if(LIBIDN2_FOUND)
|
||||
set(LIBIDN2_LIBRARIES ${LIBIDN2_LINK_LIBRARIES})
|
||||
message(STATUS "Found Libidn2 (via pkg-config): ${LIBIDN2_INCLUDE_DIRS} (Found version \"${LIBIDN2_VERSION}\")")
|
||||
else()
|
||||
find_path(LIBIDN2_INCLUDE_DIR NAMES "idn2.h")
|
||||
find_library(LIBIDN2_LIBRARY NAMES "idn2" "libidn2")
|
||||
|
||||
if(LIBIDN2_INCLUDE_DIR AND EXISTS "${LIBIDN2_INCLUDE_DIR}/idn2.h")
|
||||
set(_version_regex "#[\t ]*define[\t ]+IDN2_VERSION[\t ]+\"([^\"]*)\"")
|
||||
file(STRINGS "${LIBIDN2_INCLUDE_DIR}/idn2.h" _version_str REGEX "${_version_regex}")
|
||||
string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}")
|
||||
set(LIBIDN2_VERSION "${_version_str}")
|
||||
unset(_version_regex)
|
||||
unset(_version_str)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Libidn2
|
||||
REQUIRED_VARS
|
||||
LIBIDN2_INCLUDE_DIR
|
||||
LIBIDN2_LIBRARY
|
||||
VERSION_VAR
|
||||
LIBIDN2_VERSION
|
||||
)
|
||||
|
||||
if(LIBIDN2_FOUND)
|
||||
set(LIBIDN2_INCLUDE_DIRS ${LIBIDN2_INCLUDE_DIR})
|
||||
set(LIBIDN2_LIBRARIES ${LIBIDN2_LIBRARY})
|
||||
endif()
|
||||
|
||||
mark_as_advanced(LIBIDN2_INCLUDE_DIR LIBIDN2_LIBRARY)
|
||||
endif()
|
||||
Loading…
Add table
Add a link
Reference in a new issue