aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2021-09-01 10:37:38 +0200
committersfan5 <sfan5@live.de>2021-09-01 22:20:38 +0200
commit70dafcf5da29ff772ca6d4dcdd24d5548a0ddd31 (patch)
tree30c835478cd1bbc11cbf30c4aca592d21ef95d97
parentd1624a552151bcb152b7abf63df6501b63458d78 (diff)
downloadminetest-70dafcf5da29ff772ca6d4dcdd24d5548a0ddd31.tar.gz
minetest-70dafcf5da29ff772ca6d4dcdd24d5548a0ddd31.tar.bz2
minetest-70dafcf5da29ff772ca6d4dcdd24d5548a0ddd31.zip
Check for required libzstd APIs in cmake
It's very unlikely that anyone uses a zstd version this old, but if they do fail early.
-rw-r--r--cmake/Modules/FindZstd.cmake16
1 files changed, 16 insertions, 0 deletions
diff --git a/cmake/Modules/FindZstd.cmake b/cmake/Modules/FindZstd.cmake
index 461e4d5a6..e28e1334b 100644
--- a/cmake/Modules/FindZstd.cmake
+++ b/cmake/Modules/FindZstd.cmake
@@ -4,6 +4,22 @@ find_path(ZSTD_INCLUDE_DIR NAMES zstd.h)
find_library(ZSTD_LIBRARY NAMES zstd)
+if(ZSTD_INCLUDE_DIR AND ZSTD_LIBRARY)
+ # Check that the API we use exists
+ include(CheckSymbolExists)
+ unset(HAVE_ZSTD_INITCSTREAM CACHE)
+ set(CMAKE_REQUIRED_INCLUDES ${ZSTD_INCLUDE_DIR})
+ set(CMAKE_REQUIRED_LIBRARIES ${ZSTD_LIBRARY})
+ check_symbol_exists(ZSTD_initCStream zstd.h HAVE_ZSTD_INITCSTREAM)
+ unset(CMAKE_REQUIRED_INCLUDES)
+ unset(CMAKE_REQUIRED_LIBRARIES)
+
+ if(NOT HAVE_ZSTD_INITCSTREAM)
+ unset(ZSTD_INCLUDE_DIR CACHE)
+ unset(ZSTD_LIBRARY CACHE)
+ endif()
+endif()
+
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Zstd DEFAULT_MSG ZSTD_LIBRARY ZSTD_INCLUDE_DIR)