2022-07-05 11:26:52 +00:00
|
|
|
# Copyright (C) 2022 The Qt Company Ltd.
|
2022-08-19 13:21:34 +00:00
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
2022-07-05 11:26:52 +00:00
|
|
|
|
2019-01-30 15:53:40 +00:00
|
|
|
#.rst:
|
|
|
|
# FindZstd
|
|
|
|
# ---------
|
|
|
|
#
|
|
|
|
# Try to locate the Zstd library.
|
|
|
|
# If found, this will define the following variables:
|
|
|
|
#
|
2022-02-23 11:29:08 +00:00
|
|
|
# ``WrapZSTD_FOUND``
|
2019-01-30 15:53:40 +00:00
|
|
|
# True if the zstd library is available
|
|
|
|
# ``ZSTD_INCLUDE_DIRS``
|
|
|
|
# The zstd include directories
|
|
|
|
# ``ZSTD_LIBRARIES``
|
|
|
|
# The zstd libraries for linking
|
|
|
|
#
|
2022-02-23 11:29:08 +00:00
|
|
|
# If ``WrapZSTD_FOUND`` is TRUE, it will also define the following
|
2019-01-30 15:53:40 +00:00
|
|
|
# imported target:
|
|
|
|
#
|
2022-02-23 11:29:08 +00:00
|
|
|
# ``WrapZSTD::WrapZSTD``
|
2019-01-30 15:53:40 +00:00
|
|
|
# The zstd library
|
|
|
|
|
2020-11-09 15:06:57 +00:00
|
|
|
find_package(zstd CONFIG QUIET)
|
2019-01-30 15:53:40 +00:00
|
|
|
|
2020-11-06 11:06:23 +00:00
|
|
|
include(FindPackageHandleStandardArgs)
|
2019-01-30 15:53:40 +00:00
|
|
|
|
2020-11-06 11:06:23 +00:00
|
|
|
if(TARGET zstd::libzstd_static OR TARGET zstd::libzstd_shared)
|
2022-02-23 11:29:08 +00:00
|
|
|
find_package_handle_standard_args(WrapZSTD
|
|
|
|
REQUIRED_VARS zstd_VERSION VERSION_VAR zstd_VERSION)
|
2020-11-06 11:06:23 +00:00
|
|
|
if(TARGET zstd::libzstd_static)
|
|
|
|
set(zstdtargetsuffix "_static")
|
|
|
|
else()
|
|
|
|
set(zstdtargetsuffix "_shared")
|
|
|
|
endif()
|
2022-02-23 11:29:08 +00:00
|
|
|
if(NOT TARGET WrapZSTD::WrapZSTD)
|
|
|
|
add_library(WrapZSTD::WrapZSTD INTERFACE IMPORTED)
|
|
|
|
set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
|
2020-11-06 11:06:23 +00:00
|
|
|
INTERFACE_LINK_LIBRARIES "zstd::libzstd${zstdtargetsuffix}")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
find_package(PkgConfig QUIET)
|
2022-12-26 18:25:14 +00:00
|
|
|
pkg_check_modules(PC_ZSTD QUIET "libzstd")
|
2019-01-30 15:53:40 +00:00
|
|
|
|
2020-11-06 11:06:23 +00:00
|
|
|
find_path(ZSTD_INCLUDE_DIRS
|
|
|
|
NAMES zstd.h
|
|
|
|
HINTS ${PC_ZSTD_INCLUDEDIR}
|
|
|
|
PATH_SUFFIXES zstd)
|
|
|
|
|
|
|
|
find_library(ZSTD_LIBRARY_RELEASE
|
|
|
|
NAMES zstd zstd_static
|
|
|
|
HINTS ${PC_ZSTD_LIBDIR}
|
|
|
|
)
|
|
|
|
find_library(ZSTD_LIBRARY_DEBUG
|
|
|
|
NAMES zstdd zstd_staticd zstd zstd_static
|
|
|
|
HINTS ${PC_ZSTD_LIBDIR}
|
|
|
|
)
|
2019-01-30 15:53:40 +00:00
|
|
|
|
2020-11-06 11:06:23 +00:00
|
|
|
include(SelectLibraryConfigurations)
|
|
|
|
select_library_configurations(ZSTD)
|
2019-01-30 15:53:40 +00:00
|
|
|
|
2022-06-30 15:11:27 +00:00
|
|
|
if(PC_ZSTD_VERSION)
|
|
|
|
set(WrapZSTD_VERSION "${PC_ZSTD_VERSION}")
|
|
|
|
endif()
|
2022-02-23 11:29:08 +00:00
|
|
|
find_package_handle_standard_args(WrapZSTD
|
|
|
|
REQUIRED_VARS ZSTD_LIBRARIES ZSTD_INCLUDE_DIRS
|
2022-06-30 15:11:27 +00:00
|
|
|
VERSION_VAR WrapZSTD_VERSION)
|
2020-11-06 11:06:23 +00:00
|
|
|
|
2022-02-23 11:29:08 +00:00
|
|
|
if(WrapZSTD_FOUND AND NOT TARGET WrapZSTD::WrapZSTD)
|
|
|
|
add_library(WrapZSTD::WrapZSTD UNKNOWN IMPORTED)
|
|
|
|
set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
|
2020-11-06 11:06:23 +00:00
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIRS}")
|
2022-02-23 11:29:08 +00:00
|
|
|
set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
|
2020-11-09 15:06:57 +00:00
|
|
|
IMPORTED_LOCATION "${ZSTD_LIBRARY}")
|
2020-11-06 11:06:23 +00:00
|
|
|
if(ZSTD_LIBRARY_RELEASE)
|
2022-02-23 11:29:08 +00:00
|
|
|
set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
|
2020-11-06 11:06:23 +00:00
|
|
|
IMPORTED_LOCATION_RELEASE "${ZSTD_LIBRARY_RELEASE}")
|
|
|
|
endif()
|
|
|
|
if(ZSTD_LIBRARY_DEBUG)
|
2022-02-23 11:29:08 +00:00
|
|
|
set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
|
2020-11-06 11:06:23 +00:00
|
|
|
IMPORTED_LOCATION_DEBUG "${ZSTD_LIBRARY_DEBUG}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
mark_as_advanced(ZSTD_INCLUDE_DIRS ZSTD_LIBRARIES ZSTD_LIBRARY_RELEASE ZSTD_LIBRARY_DEBUG)
|
|
|
|
endif()
|
Write find_dependency() calls in Qt Module config files
This change introduces a new function called qt_find_package()
which can take an extra option called PROVIDED_TARGETS, which
associates targets with the package that defines those targets.
This is done by setting the INTERFACE_QT_PACKAGE_NAME and
INTERFACE_QT_PACKAGE_VERSION properties on the imported targets.
This information allows us to generate appropriate find_dependency()
calls in a module's Config file for third party libraries.
For example when an application links against QtCore, it should also
link against zlib and atomic libraries. In order to do that, the
library locations first have to be found by CMake. This is achieved by
embedding find_dependency(ZLIB) and find_dependency(Atomic) in
Qt5CoreDependencies.cmake which is included by Qt5CoreConfig.cmake.
The latter is picked up when an application project contains
find_package(Qt5Core), and thus all linking dependencies are resolved.
The information 'which package provides which targets' is contained
in the python json2cmake conversion script. The generated output of
the script contains qt_find_package() calls that represent that
information.
The Qt5CoreDependencies.cmake file and which which dependencies it
contains is generated at the QtPostProcess stop.
Note that for non-static Qt builds, we only need to propagate public
3rd party libraries. For static builds, we need all third party
libraries.
In order for the INTERFACE_QT_PACKAGE_NAME property to be read in any
scope, the targets on which the property is set, have to be GLOBAL.
Also for applications and other modules to find all required third
party libraries, we have to install all our custom Find modules, and
make sure they define INTERFACE IMPORTED libraries, and not just
IMPORTED libraries.
Change-Id: I694d6e32d05b96d5e241df0156fc79d0029426aa
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-24 15:14:25 +00:00
|
|
|
include(FeatureSummary)
|
2022-02-23 11:29:08 +00:00
|
|
|
set_package_properties(WrapZSTD PROPERTIES
|
2019-01-30 15:53:40 +00:00
|
|
|
URL "https://github.com/facebook/zstd"
|
|
|
|
DESCRIPTION "ZSTD compression library")
|
|
|
|
|