Skip to content

Commit

Permalink
Check for required libzstd APIs in cmake
Browse files Browse the repository at this point in the history
It's very unlikely that anyone uses a zstd version this old, but if they do fail early.
  • Loading branch information
sfan5 committed Sep 1, 2021
1 parent d1624a5 commit 70dafcf
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cmake/Modules/FindZstd.cmake
Expand Up @@ -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)

0 comments on commit 70dafcf

Please sign in to comment.