summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Hunger <[email protected]>2019-01-30 16:53:40 +0100
committerTobias Hunger <[email protected]>2019-01-31 13:57:24 +0000
commite7e793555ff4ee6dca0d9da581fa019bf9f93a24 (patch)
treec29d62cee08b885cec4f01aa4b6ad251299ec4b0
parent1218d8a9f0bcacf4dee3795c3172c9ce05b8baa8 (diff)
CMake: Add FindZSTD.cmake and wire it up in configurejson2cmake.py
Zstd is used in the dev branch, so prepare for it. Change-Id: I130d98e3888a1eb4c7444728fc5088c5dae9d911 Reviewed-by: Frederik Gladhorn <[email protected]>
-rw-r--r--cmake/FindZSTD.cmake49
-rwxr-xr-xutil/cmake/configurejson2cmake.py1
2 files changed, 50 insertions, 0 deletions
diff --git a/cmake/FindZSTD.cmake b/cmake/FindZSTD.cmake
new file mode 100644
index 00000000000..040e8c1642a
--- /dev/null
+++ b/cmake/FindZSTD.cmake
@@ -0,0 +1,49 @@
+#.rst:
+# FindZstd
+# ---------
+#
+# Try to locate the Zstd library.
+# If found, this will define the following variables:
+#
+# ``ZSTD_FOUND``
+# True if the zstd library is available
+# ``ZSTD_INCLUDE_DIRS``
+# The zstd include directories
+# ``ZSTD_LIBRARIES``
+# The zstd libraries for linking
+#
+# If ``ZSTD_FOUND`` is TRUE, it will also define the following
+# imported target:
+#
+# ``ZSTD::ZSTD``
+# The zstd library
+
+find_package(PkgConfig)
+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_LIBRARIES
+ NAMES zstd
+ HINTS ${PC_ZSTD_LIBDIR}
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(ZSTD DEFAULT_MSG ZSTD_LIBRARIES ZSTD_INCLUDE_DIRS)
+
+if(ZSTD_FOUND AND NOT TARGET ZSTD::ZSTD)
+ add_library(ZSTD::ZSTD UNKNOWN IMPORTED)
+ set_target_properties(ZSTD::ZSTD PROPERTIES
+ IMPORTED_LOCATION "${ZSTD_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIRS}")
+endif()
+
+mark_as_advanced(ZSTD_INCLUDE_DIRS ZSTD_LIBRARIES)
+
+set_package_properties(ZSTD PROPERTIES
+ URL "https://github.com/facebook/zstd"
+ DESCRIPTION "ZSTD compression library")
+
diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py
index 312f0cc54d1..03625da1a5c 100755
--- a/util/cmake/configurejson2cmake.py
+++ b/util/cmake/configurejson2cmake.py
@@ -92,6 +92,7 @@ def map_library(lib: str) -> Union[str, LibraryMapping, List[str]]:
'xlib': 'X11',
'xrender': LibraryMapping(package="XCB", resultVariable="XCB_RENDER"),
'zlib': 'ZLIB',
+ 'zstd': 'ZSTD',
} # type: Dict[str, Union[str, List[str], LibraryMapping]]
if lib not in libmap:
raise Exception(' XXXX Unknown library "{}".'.format(lib))