mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-28 01:49:23 -05:00
Merge topic 'patch-FindLibLZMA-version'
08fc190c03 FindLibLZMA: Add LibLZMA_VERSION
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11001
This commit is contained in:
@@ -16,6 +16,9 @@ Find Modules
|
||||
* The :module:`FindJasper` module now provides a ``Jasper_VERSION`` result
|
||||
variable. The ``JASPER_VERSION_STRING`` result variable is deprecated.
|
||||
|
||||
* The :module:`FindLibLZMA` module now provides a ``LibLZMA_VERSION`` result
|
||||
variable. The ``LIBLZMA_VERSION`` result variable is deprecated.
|
||||
|
||||
* The :module:`FindLibXml2` module now provides a ``LibXml2_VERSION`` result
|
||||
variable. The ``LIBXML2_VERSION_STRING`` result variable is deprecated.
|
||||
|
||||
|
||||
+51
-24
@@ -5,8 +5,12 @@
|
||||
FindLibLZMA
|
||||
-----------
|
||||
|
||||
Finds the data compression library that implements the LZMA (Lempel–Ziv–Markov
|
||||
chain algorithm) - liblzma.
|
||||
Finds the liblzma, a data compression library that implements the LZMA
|
||||
(Lempel–Ziv–Markov chain algorithm):
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
find_package(LibLZMA [<version>] [...])
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
@@ -25,17 +29,21 @@ Result Variables
|
||||
This module defines the following variables:
|
||||
|
||||
``LibLZMA_FOUND``
|
||||
Boolean indicating whether the liblzma is found. For backward compatibility,
|
||||
the ``LIBLZMA_FOUND`` variable is also set to the same value.
|
||||
``LIBLZMA_INCLUDE_DIRS``
|
||||
Include directories containing headers needed to use liblzma.
|
||||
``LIBLZMA_LIBRARIES``
|
||||
Libraries needed to link against to use liblzma.
|
||||
``LIBLZMA_VERSION``
|
||||
.. versionadded:: 3.26
|
||||
Boolean indicating whether (the requested version of) liblzma is found.
|
||||
For backward compatibility, the ``LIBLZMA_FOUND`` variable is also set to
|
||||
the same value.
|
||||
|
||||
``LibLZMA_VERSION``
|
||||
.. versionadded:: 4.2
|
||||
|
||||
The version of liblzma found (available as a string, for example, ``5.0.3``).
|
||||
|
||||
``LIBLZMA_INCLUDE_DIRS``
|
||||
Include directories containing headers needed to use liblzma.
|
||||
|
||||
``LIBLZMA_LIBRARIES``
|
||||
Libraries needed to link against to use liblzma.
|
||||
|
||||
Cache Variables
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -44,29 +52,47 @@ The following cache variables may also be set:
|
||||
``LIBLZMA_HAS_AUTO_DECODER``
|
||||
Boolean sanity check result indicating whether the ``lzma_auto_decoder()``
|
||||
function (automatic decoder functionality) is found in liblzma (required).
|
||||
|
||||
``LIBLZMA_HAS_EASY_ENCODER``
|
||||
Boolean sanity check result indicating whether the ``lzma_easy_encoder()``
|
||||
function (basic encoder API) is found in liblzma (required).
|
||||
|
||||
``LIBLZMA_HAS_LZMA_PRESET``
|
||||
Boolean sanity check result indicating whether the ``lzma_lzma_preset()``
|
||||
function (preset compression configuration) is found in liblzma (required).
|
||||
|
||||
Legacy Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
Deprecated Variables
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The following variables are provided for backward compatibility:
|
||||
|
||||
``LIBLZMA_VERSION_MAJOR``
|
||||
The major version of liblzma found.
|
||||
``LIBLZMA_VERSION_MINOR``
|
||||
The minor version of liblzma found.
|
||||
``LIBLZMA_VERSION_PATCH``
|
||||
The patch version of liblzma found.
|
||||
``LIBLZMA_VERSION_STRING``
|
||||
``LIBLZMA_VERSION``
|
||||
.. versionadded:: 3.26
|
||||
.. deprecated:: 4.2
|
||||
Superseded by the ``LibLZMA_VERSION``.
|
||||
|
||||
The version of liblzma found.
|
||||
|
||||
.. versionchanged:: 3.26
|
||||
Superseded by ``LIBLZMA_VERSION``.
|
||||
``LIBLZMA_VERSION_STRING``
|
||||
.. deprecated:: 3.26
|
||||
Superseded by the ``LIBLZMA_VERSION`` (and ``LibLZMA_VERSION``).
|
||||
|
||||
The version of liblzma found.
|
||||
|
||||
``LIBLZMA_VERSION_MAJOR``
|
||||
.. deprecated:: 3.26
|
||||
|
||||
The major version of liblzma found.
|
||||
|
||||
``LIBLZMA_VERSION_MINOR``
|
||||
.. deprecated:: 3.26
|
||||
|
||||
The minor version of liblzma found.
|
||||
|
||||
``LIBLZMA_VERSION_PATCH``
|
||||
.. deprecated:: 3.26
|
||||
|
||||
The patch version of liblzma found.
|
||||
|
||||
Examples
|
||||
^^^^^^^^
|
||||
@@ -99,8 +125,9 @@ if(LIBLZMA_INCLUDE_DIR AND EXISTS "${LIBLZMA_INCLUDE_DIR}/lzma/version.h")
|
||||
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}")
|
||||
|
||||
set(LIBLZMA_VERSION_STRING "${LIBLZMA_VERSION_MAJOR}.${LIBLZMA_VERSION_MINOR}.${LIBLZMA_VERSION_PATCH}")
|
||||
set(LIBLZMA_VERSION ${LIBLZMA_VERSION_STRING})
|
||||
set(LibLZMA_VERSION "${LIBLZMA_VERSION_MAJOR}.${LIBLZMA_VERSION_MINOR}.${LIBLZMA_VERSION_PATCH}")
|
||||
set(LIBLZMA_VERSION "${LibLZMA_VERSION}")
|
||||
set(LIBLZMA_VERSION_STRING "${LibLZMA_VERSION}")
|
||||
unset(LIBLZMA_HEADER_CONTENTS)
|
||||
endif()
|
||||
|
||||
@@ -131,7 +158,7 @@ find_package_handle_standard_args(LibLZMA REQUIRED_VARS LIBLZMA_LIBRARY
|
||||
LIBLZMA_HAS_AUTO_DECODER
|
||||
LIBLZMA_HAS_EASY_ENCODER
|
||||
LIBLZMA_HAS_LZMA_PRESET
|
||||
VERSION_VAR LIBLZMA_VERSION
|
||||
VERSION_VAR LibLZMA_VERSION
|
||||
)
|
||||
mark_as_advanced( LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY )
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ foreach(
|
||||
GIF GTK2
|
||||
HDF5
|
||||
Jasper JPEG
|
||||
LibArchive LIBLZMA LibXml2 LibXslt LTTngUST
|
||||
LibArchive LibLZMA LIBLZMA LibXml2 LibXslt LTTngUST
|
||||
OPENSCENEGRAPH
|
||||
PNG PostgreSQL Protobuf
|
||||
Ruby RUBY
|
||||
|
||||
@@ -4,6 +4,8 @@ include(CTest)
|
||||
|
||||
find_package(LibLZMA REQUIRED)
|
||||
|
||||
add_definitions(-DCMAKE_EXPECTED_LIBLZMA_VERSION="${LibLZMA_VERSION}")
|
||||
|
||||
add_executable(test_tgt main.c)
|
||||
target_link_libraries(test_tgt LibLZMA::LibLZMA)
|
||||
add_test(NAME test_tgt COMMAND test_tgt)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <assert.h>
|
||||
#include <lzma.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static uint8_t const test_string[9] = "123456789";
|
||||
@@ -11,5 +12,8 @@ int main(void)
|
||||
uint32_t crc = lzma_crc32(test_string, sizeof(test_string), 0);
|
||||
assert(crc == test_vector);
|
||||
|
||||
return 0;
|
||||
printf("Found LibLZMA version %s, expected version %s\n",
|
||||
lzma_version_string(), CMAKE_EXPECTED_LIBLZMA_VERSION);
|
||||
|
||||
return strcmp(lzma_version_string(), CMAKE_EXPECTED_LIBLZMA_VERSION);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user