From: Milan Ševčík Date: Wed, 19 Apr 2017 17:20:27 +0000 (+0200) Subject: Add lzma and zlib support to cmake build system X-Git-Tag: v1.2.0^2~36^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=522df42e10710a543414f84d620a8b858645d0e2;p=thirdparty%2Fzstd.git Add lzma and zlib support to cmake build system cmake 2.8.9 needed for FindLibLZMA --- diff --git a/build/cmake/CMakeLists.txt b/build/cmake/CMakeLists.txt index 9ce52ed21..bf6890818 100644 --- a/build/cmake/CMakeLists.txt +++ b/build/cmake/CMakeLists.txt @@ -8,7 +8,7 @@ # ################################################################ PROJECT(zstd) -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9) SET(ZSTD_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../..") #----------------------------------------------------------------------------- diff --git a/build/cmake/programs/CMakeLists.txt b/build/cmake/programs/CMakeLists.txt index 588fea41e..b6f79aba3 100644 --- a/build/cmake/programs/CMakeLists.txt +++ b/build/cmake/programs/CMakeLists.txt @@ -64,3 +64,30 @@ IF (ZSTD_MULTITHREAD_SUPPORT) ADD_CUSTOM_COMMAND(TARGET zstd POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink zstd zstdmt COMMENT "Creating zstdmt symlink") INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/zstdmt DESTINATION "bin") ENDIF (ZSTD_MULTITHREAD_SUPPORT) + +OPTION(ZSTD_ZLIB_SUPPORT "ZLIB SUPPORT" OFF) +OPTION(ZSTD_LZMA_SUPPORT "LZMA SUPPORT" OFF) + +IF (ZSTD_ZLIB_SUPPORT) + FIND_PACKAGE(ZLIB REQUIRED) + + IF (ZLIB_FOUND) + INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS}) + TARGET_LINK_LIBRARIES(zstd ${ZLIB_LIBRARIES}) + SET_TARGET_PROPERTIES(zstd PROPERTIES COMPILE_DEFINITIONS "ZSTD_GZCOMPRESS;ZSTD_GZDECOMPRESS") + ELSE () + MESSAGE(SEND_ERROR "zlib library is missing") + ENDIF () +ENDIF () + +IF (ZSTD_LZMA_SUPPORT) + FIND_PACKAGE(LibLZMA REQUIRED) + + IF (LIBLZMA_FOUND) + INCLUDE_DIRECTORIES(${LIBLZMA_INCLUDE_DIRS}) + TARGET_LINK_LIBRARIES(zstd ${LIBLZMA_LIBRARIES}) + SET_TARGET_PROPERTIES(zstd PROPERTIES COMPILE_DEFINITIONS "ZSTD_LZMACOMPRESS;ZSTD_LZMADECOMPRESS") + ELSE () + MESSAGE(SEND_ERROR "lzma library is missing") + ENDIF () +ENDIF ()