1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-23 00:04:06 +00:00
transmission/cmake/FindDEFLATE.cmake
Charles Kerr d8d765c595
refactor: use libdeflate instead of zlib's deflate() (#2405)
Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
2022-01-17 10:20:12 -06:00

37 lines
1.1 KiB
CMake

if(DEFLATE_PREFER_STATIC_LIB)
set(DEFLATE_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
if(WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif()
endif()
if(UNIX)
find_package(PkgConfig QUIET)
# cmake supported added in libdeflate v1.9
pkg_check_modules(_DEFLATE libdeflate>=${DEFLATE_MINIMUM})
endif()
find_path(DEFLATE_INCLUDE_DIR NAMES libdeflate.h HINTS ${_DEFLATE_INCLUDEDIR})
find_library(DEFLATE_LIBRARY NAMES deflate HINTS ${_DEFLATE_LIBDIR})
set(DEFLATE_INCLUDE_DIRS ${DEFLATE_INCLUDE_DIR})
set(DEFLATE_LIBRARIES ${DEFLATE_LIBRARY})
set(DEFLATE_VERSION ${_DEFLATE_VERSION})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DEFLATE
REQUIRED_VARS
DEFLATE_INCLUDE_DIR
DEFLATE_LIBRARY
DEFLATE_VERSION
)
mark_as_advanced(DEFLATE_INCLUDE_DIR DEFLATE_LIBRARY)
if(DEFLATE_PREFER_STATIC_LIB)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${DEFLATE_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
unset(DEFLATE_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES)
endif()