FindLibXslt: Add LibXslt_VERSION
This deprecates the LIBXSLT_VERSION_STRING result variable.
Issue: #27088
diff --git a/Help/release/dev/find-modules.rst b/Help/release/dev/find-modules.rst
index c90e172..b8c69e0 100644
--- a/Help/release/dev/find-modules.rst
+++ b/Help/release/dev/find-modules.rst
@@ -19,6 +19,9 @@
* The :module:`FindLibXml2` module now provides a ``LibXml2_VERSION`` result
variable. The ``LIBXML2_VERSION_STRING`` result variable is deprecated.
+* The :module:`FindLibXslt` module now provides a ``LibXslt_VERSION`` result
+ variable. The ``LIBXSLT_VERSION_STRING`` result variable is deprecated.
+
* The :module:`FindPostgreSQL` module now provides a ``PostgreSQL_VERSION``
result variable. The ``PostgreSQL_VERSION_STRING`` result variable is
deprecated.
diff --git a/Modules/FindLibXslt.cmake b/Modules/FindLibXslt.cmake
index d612c7d..5180f4c 100644
--- a/Modules/FindLibXslt.cmake
+++ b/Modules/FindLibXslt.cmake
@@ -6,7 +6,11 @@
-----------
Finds the XSL Transformations, Extensible Stylesheet Language Transformations
-(XSLT) library (libxslt).
+(XSLT) library (libxslt):
+
+.. code-block:: cmake
+
+ find_package(LibXslt [<version>] [...])
Imported Targets
^^^^^^^^^^^^^^^^
@@ -36,8 +40,14 @@
This module sets the following variables:
``LibXslt_FOUND``
- Boolean indicating whether the libxslt is found. For backward compatibility,
- the ``LIBXSLT_FOUND`` variable is also set to the same value.
+ Boolean indicating whether (the requested version of) libxslt is found.
+ For backward compatibility, the ``LIBXSLT_FOUND`` variable is also set to
+ the same value.
+
+``LibXslt_VERSION``
+ .. versionadded:: 4.2
+
+ The version of libxslt found.
``LIBXSLT_LIBRARIES``
Libraries needed to link to libxslt.
@@ -45,9 +55,6 @@
``LIBXSLT_DEFINITIONS``
Compiler switches required for using libxslt.
-``LIBXSLT_VERSION_STRING``
- Version of libxslt found.
-
``LIBXSLT_EXSLT_LIBRARIES``
Libraries needed when linking against the exslt library. These are available
and needed only when using exslt library.
@@ -70,6 +77,17 @@
Full path to the XSLT processor executable ``xsltproc`` if found. This path
is optional.
+Deprecated Variables
+^^^^^^^^^^^^^^^^^^^^
+
+The following variables are provided for backward compatibility:
+
+``LIBXSLT_VERSION_STRING``
+ .. deprecated:: 4.2
+ Superseded by the ``LibXslt_VERSION``.
+
+ The version of libxslt found.
+
Examples
^^^^^^^^
@@ -159,20 +177,22 @@
find_program(LIBXSLT_XSLTPROC_EXECUTABLE xsltproc)
if(PC_LIBXSLT_VERSION)
- set(LIBXSLT_VERSION_STRING ${PC_LIBXSLT_VERSION})
+ set(LibXslt_VERSION ${PC_LIBXSLT_VERSION})
+ set(LIBXSLT_VERSION_STRING "${LibXslt_VERSION}")
elseif(LIBXSLT_INCLUDE_DIR AND EXISTS "${LIBXSLT_INCLUDE_DIR}/libxslt/xsltconfig.h")
file(STRINGS "${LIBXSLT_INCLUDE_DIR}/libxslt/xsltconfig.h" libxslt_version_str
REGEX "^#define[\t ]+LIBXSLT_DOTTED_VERSION[\t ]+\".*\"")
string(REGEX REPLACE "^#define[\t ]+LIBXSLT_DOTTED_VERSION[\t ]+\"([^\"]*)\".*" "\\1"
- LIBXSLT_VERSION_STRING "${libxslt_version_str}")
+ LibXslt_VERSION "${libxslt_version_str}")
+ set(LIBXSLT_VERSION_STRING "${LibXslt_VERSION}")
unset(libxslt_version_str)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibXslt
REQUIRED_VARS LIBXSLT_LIBRARIES LIBXSLT_INCLUDE_DIR
- VERSION_VAR LIBXSLT_VERSION_STRING)
+ VERSION_VAR LibXslt_VERSION)
mark_as_advanced(LIBXSLT_INCLUDE_DIR
LIBXSLT_LIBRARY
diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt
index 0d8083f..7eb381a 100644
--- a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt
+++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt
@@ -120,7 +120,7 @@
GIF GTK2
HDF5
Jasper JPEG
- LibArchive LIBLZMA LibXml2
+ LibArchive LIBLZMA LibXml2 LibXslt
OPENSCENEGRAPH
PostgreSQL Protobuf
Ruby RUBY
diff --git a/Tests/FindLibXslt/Test/CMakeLists.txt b/Tests/FindLibXslt/Test/CMakeLists.txt
index 0f23500..8059012 100644
--- a/Tests/FindLibXslt/Test/CMakeLists.txt
+++ b/Tests/FindLibXslt/Test/CMakeLists.txt
@@ -6,7 +6,7 @@
find_package(LibXml2 REQUIRED)
find_package(LibXslt REQUIRED)
-add_definitions(-DCMAKE_EXPECTED_LibXslt_VERSION="${LIBXSLT_VERSION_STRING}")
+add_definitions(-DCMAKE_EXPECTED_LibXslt_VERSION="${LibXslt_VERSION}")
add_executable(libxslt_tgt libxslt.c)
if(Iconv_FOUND)