2016-09-27 19:01:08 +00:00
|
|
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
|
|
|
2013-10-15 15:17:36 +00:00
|
|
|
#.rst:
|
|
|
|
# FindLibLZMA
|
|
|
|
# -----------
|
|
|
|
#
|
|
|
|
# Find LibLZMA
|
|
|
|
#
|
2012-05-31 06:47:10 +00:00
|
|
|
# Find LibLZMA headers and library
|
|
|
|
#
|
2013-10-15 15:17:36 +00:00
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# LIBLZMA_FOUND - True if liblzma is found.
|
|
|
|
# LIBLZMA_INCLUDE_DIRS - Directory where liblzma headers are located.
|
|
|
|
# LIBLZMA_LIBRARIES - Lzma libraries to link against.
|
|
|
|
# LIBLZMA_HAS_AUTO_DECODER - True if lzma_auto_decoder() is found (required).
|
|
|
|
# LIBLZMA_HAS_EASY_ENCODER - True if lzma_easy_encoder() is found (required).
|
|
|
|
# LIBLZMA_HAS_LZMA_PRESET - True if lzma_lzma_preset() is found (required).
|
|
|
|
# LIBLZMA_VERSION_MAJOR - The major version of lzma
|
|
|
|
# LIBLZMA_VERSION_MINOR - The minor version of lzma
|
|
|
|
# LIBLZMA_VERSION_PATCH - The patch version of lzma
|
|
|
|
# LIBLZMA_VERSION_STRING - version number as a string (ex: "5.0.3")
|
2012-05-31 06:47:10 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
find_path(LIBLZMA_INCLUDE_DIR lzma.h )
|
|
|
|
find_library(LIBLZMA_LIBRARY lzma)
|
2012-05-31 06:47:10 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
if(LIBLZMA_INCLUDE_DIR AND EXISTS "${LIBLZMA_INCLUDE_DIR}/lzma/version.h")
|
2012-08-19 11:54:56 +00:00
|
|
|
file(STRINGS "${LIBLZMA_INCLUDE_DIR}/lzma/version.h" LIBLZMA_HEADER_CONTENTS REGEX "#define LZMA_VERSION_[A-Z]+ [0-9]+")
|
2012-05-31 06:47:10 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
string(REGEX REPLACE ".*#define LZMA_VERSION_MAJOR ([0-9]+).*" "\\1" LIBLZMA_VERSION_MAJOR "${LIBLZMA_HEADER_CONTENTS}")
|
|
|
|
string(REGEX REPLACE ".*#define LZMA_VERSION_MINOR ([0-9]+).*" "\\1" LIBLZMA_VERSION_MINOR "${LIBLZMA_HEADER_CONTENTS}")
|
|
|
|
string(REGEX REPLACE ".*#define LZMA_VERSION_PATCH ([0-9]+).*" "\\1" LIBLZMA_VERSION_PATCH "${LIBLZMA_HEADER_CONTENTS}")
|
2012-05-31 06:47:10 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
set(LIBLZMA_VERSION_STRING "${LIBLZMA_VERSION_MAJOR}.${LIBLZMA_VERSION_MINOR}.${LIBLZMA_VERSION_PATCH}")
|
2012-08-19 11:54:56 +00:00
|
|
|
unset(LIBLZMA_HEADER_CONTENTS)
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
2012-05-31 06:47:10 +00:00
|
|
|
|
|
|
|
# We're using new code known now as XZ, even library still been called LZMA
|
|
|
|
# it can be found in http://tukaani.org/xz/
|
|
|
|
# Avoid using old codebase
|
2012-08-13 17:47:32 +00:00
|
|
|
if (LIBLZMA_LIBRARY)
|
2012-09-08 17:03:26 +00:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
|
2014-03-30 02:22:54 +00:00
|
|
|
set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
|
|
|
|
set(CMAKE_REQUIRED_QUIET ${LibLZMA_FIND_QUIETLY})
|
2012-05-31 06:47:10 +00:00
|
|
|
CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_auto_decoder "" LIBLZMA_HAS_AUTO_DECODER)
|
|
|
|
CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_easy_encoder "" LIBLZMA_HAS_EASY_ENCODER)
|
|
|
|
CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_lzma_preset "" LIBLZMA_HAS_LZMA_PRESET)
|
2014-03-30 02:22:54 +00:00
|
|
|
set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
|
2012-08-13 17:50:14 +00:00
|
|
|
endif ()
|
2012-05-31 06:47:10 +00:00
|
|
|
|
2012-09-08 17:03:26 +00:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
2012-05-31 06:47:10 +00:00
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibLZMA REQUIRED_VARS LIBLZMA_INCLUDE_DIR
|
|
|
|
LIBLZMA_LIBRARY
|
|
|
|
LIBLZMA_HAS_AUTO_DECODER
|
|
|
|
LIBLZMA_HAS_EASY_ENCODER
|
|
|
|
LIBLZMA_HAS_LZMA_PRESET
|
|
|
|
VERSION_VAR LIBLZMA_VERSION_STRING
|
|
|
|
)
|
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
if (LIBLZMA_FOUND)
|
|
|
|
set(LIBLZMA_LIBRARIES ${LIBLZMA_LIBRARY})
|
|
|
|
set(LIBLZMA_INCLUDE_DIRS ${LIBLZMA_INCLUDE_DIR})
|
2012-08-13 17:50:14 +00:00
|
|
|
endif ()
|
2012-05-31 06:47:10 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
mark_as_advanced( LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY )
|