summaryrefslogtreecommitdiffstats
path: root/cmake/FindWrapZSTD.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-02-23 12:29:08 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2022-02-28 23:08:20 +0100
commit34a4fe01663c3d8b193e42c6609e75c431f8a897 (patch)
tree6c0c8cf06157fafecfe5270b34e7b5e69873e193 /cmake/FindWrapZSTD.cmake
parent0ada264dda533cd3be2699330a5c1e2dd27a0e6a (diff)
CMake: Rename FindZSTD to FindWrapZSTD
And the target ZSTD::ZSTD to WrapZSTD::WrapZSTD. This should allow building Qt with the -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON set. Pick-to: 6.2 6.3 Fixes: QTBUG-100537 Change-Id: I748601e4ad6f518323bf1034d6fc1de582c815e1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake/FindWrapZSTD.cmake')
-rw-r--r--cmake/FindWrapZSTD.cmake85
1 files changed, 85 insertions, 0 deletions
diff --git a/cmake/FindWrapZSTD.cmake b/cmake/FindWrapZSTD.cmake
new file mode 100644
index 0000000000..e619d78c86
--- /dev/null
+++ b/cmake/FindWrapZSTD.cmake
@@ -0,0 +1,85 @@
+#.rst:
+# FindZstd
+# ---------
+#
+# Try to locate the Zstd library.
+# If found, this will define the following variables:
+#
+# ``WrapZSTD_FOUND``
+# True if the zstd library is available
+# ``ZSTD_INCLUDE_DIRS``
+# The zstd include directories
+# ``ZSTD_LIBRARIES``
+# The zstd libraries for linking
+#
+# If ``WrapZSTD_FOUND`` is TRUE, it will also define the following
+# imported target:
+#
+# ``WrapZSTD::WrapZSTD``
+# The zstd library
+
+find_package(zstd CONFIG QUIET)
+
+include(FindPackageHandleStandardArgs)
+
+if(TARGET zstd::libzstd_static OR TARGET zstd::libzstd_shared)
+ find_package_handle_standard_args(WrapZSTD
+ REQUIRED_VARS zstd_VERSION VERSION_VAR zstd_VERSION)
+ if(TARGET zstd::libzstd_static)
+ set(zstdtargetsuffix "_static")
+ else()
+ set(zstdtargetsuffix "_shared")
+ endif()
+ if(NOT TARGET WrapZSTD::WrapZSTD)
+ add_library(WrapZSTD::WrapZSTD INTERFACE IMPORTED)
+ set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
+ INTERFACE_LINK_LIBRARIES "zstd::libzstd${zstdtargetsuffix}")
+ endif()
+else()
+ find_package(PkgConfig QUIET)
+ pkg_check_modules(PC_ZSTD QUIET libzstd)
+
+ 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}
+ )
+
+ include(SelectLibraryConfigurations)
+ select_library_configurations(ZSTD)
+
+ find_package_handle_standard_args(WrapZSTD
+ REQUIRED_VARS ZSTD_LIBRARIES ZSTD_INCLUDE_DIRS
+ VERSION_VAR PC_ZSTD_VERSION)
+
+ if(WrapZSTD_FOUND AND NOT TARGET WrapZSTD::WrapZSTD)
+ add_library(WrapZSTD::WrapZSTD UNKNOWN IMPORTED)
+ set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIRS}")
+ set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
+ IMPORTED_LOCATION "${ZSTD_LIBRARY}")
+ if(ZSTD_LIBRARY_RELEASE)
+ set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${ZSTD_LIBRARY_RELEASE}")
+ endif()
+ if(ZSTD_LIBRARY_DEBUG)
+ set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
+ IMPORTED_LOCATION_DEBUG "${ZSTD_LIBRARY_DEBUG}")
+ endif()
+ endif()
+
+ mark_as_advanced(ZSTD_INCLUDE_DIRS ZSTD_LIBRARIES ZSTD_LIBRARY_RELEASE ZSTD_LIBRARY_DEBUG)
+endif()
+include(FeatureSummary)
+set_package_properties(WrapZSTD PROPERTIES
+ URL "https://github.com/facebook/zstd"
+ DESCRIPTION "ZSTD compression library")
+