diff --git a/Help/release/dev/find-modules.rst b/Help/release/dev/find-modules.rst new file mode 100644 index 0000000000..ff9ca6dadf --- /dev/null +++ b/Help/release/dev/find-modules.rst @@ -0,0 +1,5 @@ +Find Modules +------------ + +* The :module:`FindBZip2` module now provides a ``BZip2_VERSION`` result + variable. The ``BZIP2_VERSION`` result variable is deprecated. diff --git a/Modules/FindBZip2.cmake b/Modules/FindBZip2.cmake index 0b9f3fe716..6432ec56c1 100644 --- a/Modules/FindBZip2.cmake +++ b/Modules/FindBZip2.cmake @@ -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 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) diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt index 8e70eb1a3d..1b6e506550 100644 --- a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt +++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt @@ -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) diff --git a/Tests/FindBZip2/Test/CMakeLists.txt b/Tests/FindBZip2/Test/CMakeLists.txt index 281339a232..bffb652272 100644 --- a/Tests/FindBZip2/Test/CMakeLists.txt +++ b/Tests/FindBZip2/Test/CMakeLists.txt @@ -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) diff --git a/Tests/FindBZip2/Test/main.c b/Tests/FindBZip2/Test/main.c index b3cf34ba6f..0dc27b3911 100644 --- a/Tests/FindBZip2/Test/main.c +++ b/Tests/FindBZip2/Test/main.c @@ -1,6 +1,7 @@ #include #include #include +#include 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)); }