From: Michihiro NAKAJIMA Date: Sun, 6 Jul 2014 04:40:53 +0000 (+0900) Subject: Add lz4 detection for CMake configuration. X-Git-Tag: v3.1.900a~260 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07e5668348927b5cbbe09cd5dec39a2fb824e92c;p=thirdparty%2Flibarchive.git Add lz4 detection for CMake configuration. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index b55567095..db245e435 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -466,6 +466,33 @@ IF(LZO2_FOUND) ENDIF(LZO2_FOUND) MARK_AS_ADVANCED(CLEAR LZO2_INCLUDE_DIR) MARK_AS_ADVANCED(CLEAR LZO2_LIBRARY) +# +# Find LZ4 +# +IF (LZ4_INCLUDE_DIR) + # Already in cache, be silent + SET(LZ4_FIND_QUIETLY TRUE) +ENDIF (LZ4_INCLUDE_DIR) + +FIND_PATH(LZ4_INCLUDE_DIR lz4.h) +FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4) +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZ4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR) +IF(LZ4_FOUND) + SET(HAVE_LIBLZ4 1) + SET(HAVE_LZ4_H 1) + CMAKE_PUSH_CHECK_STATE() # Save the state of the variables + SET(CMAKE_REQUIRED_INCLUDES ${LZ4_INCLUDE_DIR}) + CHECK_INCLUDE_FILES("lz4hc.h" HAVE_LZ4HC_H) + CMAKE_POP_CHECK_STATE() # Restore the state of the variables + INCLUDE_DIRECTORIES(${LZ4_INCLUDE_DIR}) + LIST(APPEND ADDITIONAL_LIBS ${LZ4_LIBRARY}) + # + # TODO: test for static library. + # +ENDIF(LZ4_FOUND) +MARK_AS_ADVANCED(CLEAR LZ4_INCLUDE_DIR) +MARK_AS_ADVANCED(CLEAR LZ4_LIBRARY) # # Check headers diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in index 179ffa7ca..3b82b24fd 100644 --- a/build/cmake/config.h.in +++ b/build/cmake/config.h.in @@ -585,6 +585,9 @@ typedef uint64_t uintmax_t; /* Define to 1 if you have the `gcc' library (-lgcc). */ #cmakedefine HAVE_LIBGCC 1 +/* Define to 1 if you have the `lz4' library (-llz4). */ +#cmakedefine HAVE_LIBLZ4 1 + /* Define to 1 if you have the `lzma' library (-llzma). */ #cmakedefine HAVE_LIBLZMA 1 @@ -676,6 +679,12 @@ typedef uint64_t uintmax_t; /* Define to 1 if you have the `lutimes' function. */ #cmakedefine HAVE_LUTIMES 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LZ4HC_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LZ4_H 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_LZMADEC_H 1