mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00
FindBZip2: Add BZip2_VERSION
This deprecates the BZIP2_VERSION result variable. Issue: #27088
This commit is contained in:
5
Help/release/dev/find-modules.rst
Normal file
5
Help/release/dev/find-modules.rst
Normal file
@@ -0,0 +1,5 @@
|
||||
Find Modules
|
||||
------------
|
||||
|
||||
* The :module:`FindBZip2` module now provides a ``BZip2_VERSION`` result
|
||||
variable. The ``BZIP2_VERSION`` result variable is deprecated.
|
@@ -28,8 +28,14 @@ Result Variables
|
||||
This module defines the following variables:
|
||||
|
||||
``BZip2_FOUND``
|
||||
Boolean indicating whether the BZip2 library is found. For backward
|
||||
compatibility, the ``BZIP2_FOUND`` variable is also set to the same value.
|
||||
Boolean indicating whether (the requested version of) BZip2 library is
|
||||
found. For backward compatibility, the ``BZIP2_FOUND`` variable is also
|
||||
set to the same value.
|
||||
|
||||
``BZip2_VERSION``
|
||||
.. versionadded:: 4.2
|
||||
|
||||
The version of BZip2 found.
|
||||
|
||||
``BZIP2_INCLUDE_DIRS``
|
||||
.. versionadded:: 3.12
|
||||
@@ -39,11 +45,6 @@ This module defines the following variables:
|
||||
``BZIP2_LIBRARIES``
|
||||
Libraries needed for linking to use BZip2.
|
||||
|
||||
``BZIP2_VERSION``
|
||||
.. versionadded:: 3.26
|
||||
|
||||
The version of BZip2 found.
|
||||
|
||||
Cache Variables
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -63,14 +64,22 @@ The following cache variables may also be set:
|
||||
(e.g., ``BZ2_bzCompressInit()``). Versions of BZip2 prior to 1.0.0 used
|
||||
unprefixed function names (e.g., ``bzCompressInit()``).
|
||||
|
||||
Legacy Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
Deprecated Variables
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The following variables are provided for backward compatibility:
|
||||
|
||||
``BZIP2_VERSION_STRING``
|
||||
.. versionchanged:: 3.26
|
||||
Superseded by ``BZIP2_VERSION``.
|
||||
.. deprecated:: 3.26
|
||||
Superseded by the ``BZIP2_VERSION`` (and ``BZip2_VERSION``).
|
||||
|
||||
The version of BZip2 found.
|
||||
|
||||
``BZIP2_VERSION``
|
||||
.. versionadded:: 3.26
|
||||
|
||||
.. deprecated:: 4.2
|
||||
Superseded by the ``BZip2_VERSION``.
|
||||
|
||||
The version of BZip2 found.
|
||||
|
||||
@@ -108,12 +117,13 @@ 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]+ ")
|
||||
string(REGEX REPLACE ".* bzip2/libbzip2 version ([0-9]+\\.[^ ]+) of [0-9]+ .*" "\\1" BZIP2_VERSION_STRING "${BZLIB_H}")
|
||||
set(BZIP2_VERSION ${BZIP2_VERSION_STRING})
|
||||
set(BZip2_VERSION ${BZIP2_VERSION_STRING})
|
||||
endif ()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(BZip2
|
||||
REQUIRED_VARS BZIP2_LIBRARIES BZIP2_INCLUDE_DIR
|
||||
VERSION_VAR BZIP2_VERSION)
|
||||
VERSION_VAR BZip2_VERSION)
|
||||
|
||||
if (BZip2_FOUND)
|
||||
set(BZIP2_INCLUDE_DIRS ${BZIP2_INCLUDE_DIR})
|
||||
@@ -126,7 +136,7 @@ if (BZip2_FOUND)
|
||||
|
||||
# Versions before 1.0.2 required <stdio.h> for the FILE definition.
|
||||
set(BZip2_headers "bzlib.h")
|
||||
if(BZIP2_VERSION VERSION_LESS "1.0.2")
|
||||
if(BZip2_VERSION VERSION_LESS "1.0.2")
|
||||
list(PREPEND BZip2_headers "stdio.h")
|
||||
endif()
|
||||
check_symbol_exists(BZ2_bzCompressInit "${BZip2_headers}" BZIP2_NEED_PREFIX)
|
||||
|
@@ -90,15 +90,42 @@ endmacro()
|
||||
# If any of these modules reported that it was found a version number should have been
|
||||
# reported.
|
||||
|
||||
foreach(VTEST ALSA ARMADILLO BZIP2 CUPS CURL EXPAT FREETYPE GETTEXT GIT HG
|
||||
HSPELL ICOTOOL JASPER LIBLZMA LIBXML2 LIBXSLT LTTNGUST PERL PKG_CONFIG
|
||||
PostgreSQL TIFF ZLIB)
|
||||
check_version_string(${VTEST} ${VTEST}_VERSION_STRING)
|
||||
foreach(
|
||||
VTEST
|
||||
ALSA ARMADILLO
|
||||
BZIP2
|
||||
CUPS CURL
|
||||
EXPAT
|
||||
FREETYPE
|
||||
GETTEXT GIT
|
||||
HG HSPELL
|
||||
ICOTOOL
|
||||
JASPER
|
||||
LIBLZMA LIBXML2 LIBXSLT LTTNGUST
|
||||
PERL PKG_CONFIG PostgreSQL
|
||||
TIFF
|
||||
ZLIB
|
||||
)
|
||||
check_version_string(${VTEST} ${VTEST}_VERSION_STRING)
|
||||
endforeach()
|
||||
|
||||
foreach(VTEST BISON Boost BZIP2 CUDA DOXYGEN FLEX GIF GTK2
|
||||
HDF5 JPEG LibArchive LIBLZMA OPENSCENEGRAPH Ruby RUBY SWIG Protobuf ZLIB)
|
||||
check_version_string(${VTEST} ${VTEST}_VERSION)
|
||||
foreach(
|
||||
VTEST
|
||||
BISON Boost BZip2 BZIP2
|
||||
CUDA
|
||||
DOXYGEN
|
||||
FLEX
|
||||
GIF GTK2
|
||||
HDF5
|
||||
JPEG
|
||||
LibArchive LIBLZMA
|
||||
OPENSCENEGRAPH
|
||||
Protobuf
|
||||
Ruby RUBY
|
||||
SWIG
|
||||
ZLIB
|
||||
)
|
||||
check_version_string(${VTEST} ${VTEST}_VERSION)
|
||||
endforeach()
|
||||
|
||||
check_version_string(PYTHONINTERP PYTHON_VERSION_STRING)
|
||||
|
@@ -4,7 +4,7 @@ include(CTest)
|
||||
|
||||
find_package(BZip2 REQUIRED)
|
||||
|
||||
add_definitions(-DCMAKE_EXPECTED_BZip2_VERSION="${BZip2_VERSION_STRING}")
|
||||
add_definitions(-DCMAKE_EXPECTED_BZip2_VERSION="${BZip2_VERSION}")
|
||||
|
||||
add_executable(test_tgt main.c)
|
||||
target_link_libraries(test_tgt BZip2::BZip2)
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include <bzlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
@@ -19,5 +20,9 @@ int main(void)
|
||||
|
||||
remove("test.bzip2");
|
||||
|
||||
return 0;
|
||||
printf("Found BZip2 version %s, expected version %s\n", BZ2_bzlibVersion(),
|
||||
CMAKE_EXPECTED_BZip2_VERSION);
|
||||
|
||||
return strncmp(BZ2_bzlibVersion(), CMAKE_EXPECTED_BZip2_VERSION,
|
||||
strlen(CMAKE_EXPECTED_BZip2_VERSION));
|
||||
}
|
||||
|
Reference in New Issue
Block a user