2020-05-25 23:49:46 +08:00
|
|
|
#***************************************************************************
|
|
|
|
# _ _ ____ _
|
|
|
|
# Project ___| | | | _ \| |
|
|
|
|
# / __| | | | |_) | |
|
|
|
|
# | (__| |_| | _ <| |___
|
|
|
|
# \___|\___/|_| \_\_____|
|
|
|
|
#
|
2023-01-02 20:51:48 +08:00
|
|
|
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
2020-05-25 23:49:46 +08:00
|
|
|
#
|
|
|
|
# This software is licensed as described in the file COPYING, which
|
|
|
|
# you should have received as part of this distribution. The terms
|
2020-11-04 21:02:01 +08:00
|
|
|
# are also available at https://curl.se/docs/copyright.html.
|
2020-05-25 23:49:46 +08:00
|
|
|
#
|
|
|
|
# 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
|
2022-05-17 17:16:50 +08:00
|
|
|
#
|
2020-05-25 23:49:46 +08:00
|
|
|
###########################################################################
|
2024-07-13 03:10:57 +08:00
|
|
|
# Find the zstd library
|
|
|
|
#
|
2024-08-05 02:35:13 +08:00
|
|
|
# Result Variables:
|
|
|
|
#
|
2024-07-13 03:10:57 +08:00
|
|
|
# Zstd_FOUND System has zstd
|
2024-08-05 02:35:13 +08:00
|
|
|
# Zstd_INCLUDE_DIRS The zstd include directories
|
2024-07-13 03:10:57 +08:00
|
|
|
# Zstd_LIBRARIES The libraries needed to use zstd
|
2024-08-05 02:35:13 +08:00
|
|
|
# Zstd_VERSION Version of zstd
|
2020-05-25 23:49:46 +08:00
|
|
|
|
cmake: allow `pkg-config` in more envs
Before this patch, `pkg-config` was used for `UNIX` builds only (with
a few exceptions like wolfSSL, libssh, gsasl, libuv). This patch extends
`pkg-config` use to all envs except: `MSVC` without vcpkg. Meaning MSVC
with vcpkg will now use it. Also mingw on Windows.
Also apply the new condition to options where `pkg-config` was used
unconditionally (= for all targets). These are:
`-DCURL_USE_WOLFSSL=ON`, `-DCURL_USE_LIBSSH=ON`,
`-DCURL_USE_GSASL=ON` and `-DCURL_USE_LIBUV=ON`
This patch may still cause regressions for cross-builds (e.g. mingw
cross-build from Unix) and potentially other cases. If that happens, we
recommend using some of these methods to explicitly disable `pkg-config`
when using CMake:
- CMake option: `-DPKG_CONFIG_EXECUTABLE=`
(or `-DPKG_CONFIG_EXECUTABLE=nonexistent` or similar)
This is similar to the (curl-specific) `PKG_CONFIG` env for autotools.
- export env: `PKG_CONFIG_LIBDIR=`
(or `PKG_CONFIG_PATH`, `PKG_CONFIG_SYSROOT_DIR`,
or the CMake-specific `PKG_CONFIG`)
We may improve control over this in a future patch, also allowing opting
in MSVC (without vcpkg).
Ref: #14405
Ref: #14408
Ref: #14140
Closes #14483
2024-08-10 15:33:18 +08:00
|
|
|
if(NOT MSVC OR VCPKG_TOOLCHAIN)
|
2020-05-25 23:49:46 +08:00
|
|
|
find_package(PkgConfig QUIET)
|
2024-08-05 02:35:13 +08:00
|
|
|
pkg_search_module(PC_Zstd "libzstd")
|
2020-05-25 23:49:46 +08:00
|
|
|
endif()
|
|
|
|
|
2024-08-05 02:35:13 +08:00
|
|
|
find_path(Zstd_INCLUDE_DIR "zstd.h"
|
2020-05-25 23:49:46 +08:00
|
|
|
HINTS
|
|
|
|
${PC_Zstd_INCLUDEDIR}
|
|
|
|
${PC_Zstd_INCLUDE_DIRS}
|
|
|
|
)
|
|
|
|
|
2024-08-05 02:35:13 +08:00
|
|
|
find_library(Zstd_LIBRARY NAMES "zstd"
|
2020-05-25 23:49:46 +08:00
|
|
|
HINTS
|
|
|
|
${PC_Zstd_LIBDIR}
|
|
|
|
${PC_Zstd_LIBRARY_DIRS}
|
|
|
|
)
|
|
|
|
|
2023-10-26 07:37:48 +08:00
|
|
|
if(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}")
|
|
|
|
endif()
|
|
|
|
|
2020-05-25 23:49:46 +08:00
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package_handle_standard_args(Zstd
|
|
|
|
REQUIRED_VARS
|
|
|
|
Zstd_INCLUDE_DIR
|
2024-08-05 02:35:13 +08:00
|
|
|
Zstd_LIBRARY
|
|
|
|
VERSION_VAR
|
|
|
|
Zstd_VERSION
|
2020-05-25 23:49:46 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
if(Zstd_FOUND)
|
|
|
|
set(Zstd_INCLUDE_DIRS ${Zstd_INCLUDE_DIR})
|
2024-08-05 02:35:13 +08:00
|
|
|
set(Zstd_LIBRARIES ${Zstd_LIBRARY})
|
2020-05-25 23:49:46 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
mark_as_advanced(Zstd_INCLUDE_DIRS Zstd_LIBRARIES)
|