Use PkgConfig to find Zstd

This commit is contained in:
Richard Berger 2020-09-01 11:14:36 -04:00
parent 8e0c4d764e
commit 3db1a6d690
No known key found for this signature in database
GPG Key ID: A9E83994E0BA0CAB
2 changed files with 3 additions and 30 deletions

View File

@ -1,28 +0,0 @@
# Find Zstd library
#
# Zstd_INCLUDE_DIRS - where to find zstd.h, etc.
# Zstd_LIBRARIES - List of libraries when using libzstd
# Zstd_FOUND - True if libzstd is found.
find_path(Zstd_INCLUDE_DIR NAMES zstd.h)
find_library(Zstd_LIBRARY NAMES zstd)
# handle the QUIET and REQUIRED arguments and
# set Zstd_FOUND to TRUE if all variables are non-zero
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Zstd DEFAULT_MSG Zstd_LIBRARY Zstd_INCLUDE_DIR)
# Copy the results to the output variables and target.
if(Zstd_FOUND)
set(Zstd_LIBRARIES ${Zstd_LIBRARY})
set(Zstd_INCLUDE_DIRS ${Zstd_INCLUDE_DIR})
if(NOT TARGET Zstd::Zstd)
add_library(Zstd::Zstd UNKNOWN IMPORTED)
set_target_properties(Zstd::Zstd PROPERTIES
IMPORTED_LOCATION "${Zstd_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${Zstd_INCLUDE_DIR}")
endif()
endif()
mark_as_advanced(Zstd_INCLUDE_DIR Zstd_LIBRARY)

View File

@ -1,9 +1,10 @@
find_package(ZLIB REQUIRED)
target_link_libraries(lammps PRIVATE ZLIB::ZLIB)
find_package(Zstd)
find_package(PkgConfig REQUIRED)
pkg_check_modules(Zstd IMPORTED_TARGET libzstd)
if(Zstd_FOUND)
target_compile_definitions(lammps PRIVATE -DLAMMPS_ZSTD)
target_link_libraries(lammps PRIVATE Zstd::Zstd)
target_link_libraries(lammps PRIVATE PkgConfig::Zstd)
endif()