Find{BZip2,LibLZMA,ZLIB}: use *_VERSION as modern CMake

The old *_VERSION_STRING is silently left set for backward compat.
This commit is contained in:
Michael Hirsch
2022-11-06 14:02:08 -05:00
committed by Brad King
parent 890d447923
commit 9e3f1723ff
4 changed files with 83 additions and 26 deletions
+18 -3
View File
@@ -29,8 +29,11 @@ This module defines the following variables:
Link these to use BZip2 Link these to use BZip2
``BZIP2_NEED_PREFIX`` ``BZIP2_NEED_PREFIX``
this is set if the functions are prefixed with ``BZ2_`` this is set if the functions are prefixed with ``BZ2_``
``BZIP2_VERSION_STRING`` ``BZIP2_VERSION``
the version of BZip2 found .. versionadded:: 3.26
the version of BZip2 found.
See also legacy variable ``BZIP2_VERSION_STRING``.
Cache variables Cache variables
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
@@ -39,6 +42,17 @@ The following cache variables may also be set:
``BZIP2_INCLUDE_DIR`` ``BZIP2_INCLUDE_DIR``
the BZip2 include directory the BZip2 include directory
Legacy Variables
^^^^^^^^^^^^^^^^
The following variables are provided for backward compatibility:
``BZIP2_VERSION_STRING``
the version of BZip2 found.
.. versionchanged:: 3.26
Superseded by ``BZIP2_VERSION``.
#]=======================================================================] #]=======================================================================]
set(_BZIP2_PATHS PATHS set(_BZIP2_PATHS PATHS
@@ -60,12 +74,13 @@ endif ()
if (BZIP2_INCLUDE_DIR AND EXISTS "${BZIP2_INCLUDE_DIR}/bzlib.h") if (BZIP2_INCLUDE_DIR AND EXISTS "${BZIP2_INCLUDE_DIR}/bzlib.h")
file(STRINGS "${BZIP2_INCLUDE_DIR}/bzlib.h" BZLIB_H REGEX "bzip2/libbzip2 version [0-9]+\\.[^ ]+ of [0-9]+ ") file(STRINGS "${BZIP2_INCLUDE_DIR}/bzlib.h" BZLIB_H REGEX "bzip2/libbzip2 version [0-9]+\\.[^ ]+ of [0-9]+ ")
string(REGEX REPLACE ".* bzip2/libbzip2 version ([0-9]+\\.[^ ]+) of [0-9]+ .*" "\\1" BZIP2_VERSION_STRING "${BZLIB_H}") string(REGEX REPLACE ".* bzip2/libbzip2 version ([0-9]+\\.[^ ]+) of [0-9]+ .*" "\\1" BZIP2_VERSION_STRING "${BZLIB_H}")
set(BZIP2_VERSION ${BZIP2_VERSION_STRING})
endif () endif ()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(BZip2 FIND_PACKAGE_HANDLE_STANDARD_ARGS(BZip2
REQUIRED_VARS BZIP2_LIBRARIES BZIP2_INCLUDE_DIR REQUIRED_VARS BZIP2_LIBRARIES BZIP2_INCLUDE_DIR
VERSION_VAR BZIP2_VERSION_STRING) VERSION_VAR BZIP2_VERSION)
if (BZIP2_FOUND) if (BZIP2_FOUND)
set(BZIP2_INCLUDE_DIRS ${BZIP2_INCLUDE_DIR}) set(BZIP2_INCLUDE_DIRS ${BZIP2_INCLUDE_DIR})
+17 -1
View File
@@ -33,6 +33,17 @@ This module will set the following variables in your project:
True if lzma_easy_encoder() is found (required). True if lzma_easy_encoder() is found (required).
``LIBLZMA_HAS_LZMA_PRESET`` ``LIBLZMA_HAS_LZMA_PRESET``
True if lzma_lzma_preset() is found (required). True if lzma_lzma_preset() is found (required).
``LIBLZMA_VERSION``
.. versionadded:: 3.26
the version of LZMA found.
See also legacy variable ``LIBLZMA_VERSION_STRING``.
Legacy Variables
^^^^^^^^^^^^^^^^
The following variables are provided for backward compatibility:
``LIBLZMA_VERSION_MAJOR`` ``LIBLZMA_VERSION_MAJOR``
The major version of lzma The major version of lzma
``LIBLZMA_VERSION_MINOR`` ``LIBLZMA_VERSION_MINOR``
@@ -41,6 +52,10 @@ This module will set the following variables in your project:
The patch version of lzma The patch version of lzma
``LIBLZMA_VERSION_STRING`` ``LIBLZMA_VERSION_STRING``
version number as a string (ex: "5.0.3") version number as a string (ex: "5.0.3")
.. versionchanged:: 3.26
Superseded by ``LIBLZMA_VERSION``.
#]=======================================================================] #]=======================================================================]
find_path(LIBLZMA_INCLUDE_DIR lzma.h ) find_path(LIBLZMA_INCLUDE_DIR lzma.h )
@@ -61,6 +76,7 @@ if(LIBLZMA_INCLUDE_DIR AND EXISTS "${LIBLZMA_INCLUDE_DIR}/lzma/version.h")
string(REGEX REPLACE ".*#define LZMA_VERSION_PATCH ([0-9]+).*" "\\1" LIBLZMA_VERSION_PATCH "${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_STRING "${LIBLZMA_VERSION_MAJOR}.${LIBLZMA_VERSION_MINOR}.${LIBLZMA_VERSION_PATCH}")
set(LIBLZMA_VERSION ${LIBLZMA_VERSION_STRING})
unset(LIBLZMA_HEADER_CONTENTS) unset(LIBLZMA_HEADER_CONTENTS)
endif() endif()
@@ -91,7 +107,7 @@ find_package_handle_standard_args(LibLZMA REQUIRED_VARS LIBLZMA_LIBRARY
LIBLZMA_HAS_AUTO_DECODER LIBLZMA_HAS_AUTO_DECODER
LIBLZMA_HAS_EASY_ENCODER LIBLZMA_HAS_EASY_ENCODER
LIBLZMA_HAS_LZMA_PRESET LIBLZMA_HAS_LZMA_PRESET
VERSION_VAR LIBLZMA_VERSION_STRING VERSION_VAR LIBLZMA_VERSION
) )
mark_as_advanced( LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY ) mark_as_advanced( LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY )
+46 -20
View File
@@ -20,33 +20,57 @@ Result Variables
This module defines the following variables: This module defines the following variables:
:: ``ZLIB_INCLUDE_DIRS``
where to find zlib.h, etc.
``ZLIB_LIBRARIES``
List of libraries when using zlib.
``ZLIB_FOUND``
True if zlib found.
``ZLIB_VERSION``
.. versionadded:: 3.26
the version of Zlib found.
ZLIB_INCLUDE_DIRS - where to find zlib.h, etc. See also legacy variable ``ZLIB_VERSION_STRING``.
ZLIB_LIBRARIES - List of libraries when using zlib.
ZLIB_FOUND - True if zlib found.
::
ZLIB_VERSION_STRING - The version of zlib found (x.y.z)
ZLIB_VERSION_MAJOR - The major version of zlib
ZLIB_VERSION_MINOR - The minor version of zlib
ZLIB_VERSION_PATCH - The patch version of zlib
ZLIB_VERSION_TWEAK - The tweak version of zlib
.. versionadded:: 3.4 .. versionadded:: 3.4
Debug and Release variants are found separately. Debug and Release variants are found separately.
Backward Compatibility Legacy Variables
^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
The following variable are provided for backward compatibility The following variables are provided for backward compatibility:
:: ``ZLIB_VERSION_MAJOR``
The major version of zlib.
ZLIB_MAJOR_VERSION - The major version of zlib .. versionchanged:: 3.26
ZLIB_MINOR_VERSION - The minor version of zlib Superseded by ``ZLIB_VERSION``.
ZLIB_PATCH_VERSION - The patch version of zlib ``ZLIB_VERSION_MINOR``
The minor version of zlib.
.. versionchanged:: 3.26
Superseded by ``ZLIB_VERSION``.
``ZLIB_VERSION_PATCH``
The patch version of zlib.
.. versionchanged:: 3.26
Superseded by ``ZLIB_VERSION``.
``ZLIB_VERSION_TWEAK``
The tweak version of zlib.
.. versionchanged:: 3.26
Superseded by ``ZLIB_VERSION``.
``ZLIB_VERSION_STRING``
The version of zlib found (x.y.z)
.. versionchanged:: 3.26
Superseded by ``ZLIB_VERSION``.
``ZLIB_MAJOR_VERSION``
The major version of zlib. Superseded by ``ZLIB_VERSION_MAJOR``.
``ZLIB_MINOR_VERSION``
The minor version of zlib. Superseded by ``ZLIB_VERSION_MINOR``.
``ZLIB_PATCH_VERSION``
The patch version of zlib. Superseded by ``ZLIB_VERSION_PATCH``.
Hints Hints
^^^^^ ^^^^^
@@ -168,11 +192,13 @@ if(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h")
set(ZLIB_MAJOR_VERSION "${ZLIB_VERSION_MAJOR}") set(ZLIB_MAJOR_VERSION "${ZLIB_VERSION_MAJOR}")
set(ZLIB_MINOR_VERSION "${ZLIB_VERSION_MINOR}") set(ZLIB_MINOR_VERSION "${ZLIB_VERSION_MINOR}")
set(ZLIB_PATCH_VERSION "${ZLIB_VERSION_PATCH}") set(ZLIB_PATCH_VERSION "${ZLIB_VERSION_PATCH}")
set(ZLIB_VERSION ${ZLIB_VERSION_STRING})
endif() endif()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB REQUIRED_VARS ZLIB_LIBRARY ZLIB_INCLUDE_DIR FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB REQUIRED_VARS ZLIB_LIBRARY ZLIB_INCLUDE_DIR
VERSION_VAR ZLIB_VERSION_STRING VERSION_VAR ZLIB_VERSION
HANDLE_COMPONENTS) HANDLE_COMPONENTS)
if(ZLIB_FOUND) if(ZLIB_FOUND)
@@ -96,8 +96,8 @@ foreach(VTEST ALSA ARMADILLO BZIP2 CUPS CURL EXPAT FREETYPE GETTEXT GIT HG
check_version_string(${VTEST} ${VTEST}_VERSION_STRING) check_version_string(${VTEST} ${VTEST}_VERSION_STRING)
endforeach() endforeach()
foreach(VTEST BISON Boost CUDA DOXYGEN FLEX GIF GTK2 foreach(VTEST BISON Boost BZIP2 CUDA DOXYGEN FLEX GIF GTK2
HDF5 JPEG LibArchive OPENSCENEGRAPH Ruby RUBY SWIG Protobuf) HDF5 JPEG LibArchive LIBLZMA OPENSCENEGRAPH Ruby RUBY SWIG Protobuf ZLIB)
check_version_string(${VTEST} ${VTEST}_VERSION) check_version_string(${VTEST} ${VTEST}_VERSION)
endforeach() endforeach()