# Try to find the zstd library
#
# If successful, the following variables will be defined:
# zstd_INCLUDE_DIR
# zstd_LIBRARY
# zstd_STATIC_LIBRARY
# zstd_FOUND
#
# Additionally, one of the following import targets will be defined:
# zstd::libzstd_shared
# zstd::libzstd_static
set(zstd_STATIC_LIBRARY_SUFFIX
"_static\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
set(zstd_STATIC_LIBRARY_SUFFIX
"\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
zstd_static
"${CMAKE_STATIC_LIBRARY_PREFIX}zstd${CMAKE_STATIC_LIBRARY_SUFFIX}")
include(FindPackageHandleStandardArgs
)
find_package_handle_standard_args(
zstd DEFAULT_MSG
zstd_LIBRARY zstd_INCLUDE_DIR
)
if(zstd_LIBRARY
MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$")
set(zstd_STATIC_LIBRARY
"${zstd_LIBRARY}")
elseif (NOT TARGET zstd::libzstd_shared
)
# IMPORTED_LOCATION is the path to the DLL and IMPORTED_IMPLIB is the "library".
string(REGEX REPLACE "${CMAKE_INSTALL_LIBDIR}$" "${CMAKE_INSTALL_BINDIR}" zstd_DIRNAME
"${zstd_DIRNAME}")
string(REGEX REPLACE "\\${CMAKE_LINK_LIBRARY_SUFFIX}$" "${CMAKE_SHARED_LIBRARY_SUFFIX}" zstd_BASENAME
"${zstd_BASENAME}")
INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}"
IMPORTED_LOCATION "${zstd_DIRNAME}/${zstd_BASENAME}"
IMPORTED_IMPLIB "${zstd_LIBRARY}")
INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}"
IMPORTED_LOCATION "${zstd_LIBRARY}")
if(zstd_STATIC_LIBRARY
MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$" AND
NOT TARGET zstd::libzstd_static)
INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}"
IMPORTED_LOCATION "${zstd_STATIC_LIBRARY}")
unset(zstd_STATIC_LIBRARY_SUFFIX
)