Browse Source

FindFreetype: Add Freetype_VERSION

This deprecates the FREETYPE_VERSION_STRING result variable.

Issue: #27088
Peter Kokot 4 months ago
parent
commit
58d61f6846

+ 3 - 0
Help/release/dev/find-modules.rst

@@ -10,6 +10,9 @@ Find Modules
 * The :module:`FindEXPAT` module now provides a ``EXPAT_VERSION`` result
   variable.  The ``EXPAT_VERSION_STRING`` result variable is deprecated.
 
+* The :module:`FindFreetype` module now provides a ``Freetype_VERSION`` result
+  variable.  The ``FREETYPE_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.

+ 30 - 12
Modules/FindFreetype.cmake

@@ -5,7 +5,11 @@
 FindFreetype
 ------------
 
-Finds the FreeType font renderer library.
+Finds the FreeType font renderer library:
+
+.. code-block:: cmake
+
+  find_package(Freetype [<version>] [...])
 
 Imported Targets
 ^^^^^^^^^^^^^^^^
@@ -24,9 +28,14 @@ Result Variables
 This module defines the following variables:
 
 ``Freetype_FOUND``
-  Boolean indicating whether the (requested version of) Freetype is found.  For
-  backward compatibility, the ``FREETYPE_FOUND`` variable is also set to the
-  same value.
+  Boolean indicating whether (the requested version of) Freetype is found.
+  For backward compatibility, the ``FREETYPE_FOUND`` variable is also set
+  to the same value.
+
+``Freetype_VERSION``
+  .. versionadded:: 4.2
+
+  The version of Freetype found.
 
 ``FREETYPE_INCLUDE_DIRS``
   Include directories containing headers needed to use Freetype.  This is the
@@ -36,9 +45,6 @@ This module defines the following variables:
 ``FREETYPE_LIBRARIES``
   Libraries needed to link against for using Freetype.
 
-``FREETYPE_VERSION_STRING``
-  The version of Freetype found.
-
 .. versionadded:: 3.7
   Debug and Release library variants are found separately.
 
@@ -62,6 +68,17 @@ This module accepts the following variables:
   The user may set this environment variable to the root directory of a Freetype
   installation to find Freetype in non-standard locations.
 
+Deprecated Variables
+^^^^^^^^^^^^^^^^^^^^
+
+The following variables are provided for backward compatibility:
+
+``FREETYPE_VERSION_STRING``
+  .. deprecated:: 4.2
+    Superseded by the ``Freetype_VERSION``.
+
+  The version of Freetype found.
+
 Examples
 ^^^^^^^^
 
@@ -170,20 +187,21 @@ if(FREETYPE_INCLUDE_DIR_freetype2 AND FREETYPE_H)
   file(STRINGS "${FREETYPE_H}" freetype_version_str
        REGEX "^#[\t ]*define[\t ]+FREETYPE_(MAJOR|MINOR|PATCH)[\t ]+[0-9]+$")
 
-  unset(FREETYPE_VERSION_STRING)
+  unset(Freetype_VERSION)
   foreach(VPART MAJOR MINOR PATCH)
     foreach(VLINE ${freetype_version_str})
       if(VLINE MATCHES "^#[\t ]*define[\t ]+FREETYPE_${VPART}[\t ]+([0-9]+)$")
         set(FREETYPE_VERSION_PART "${CMAKE_MATCH_1}")
-        if(FREETYPE_VERSION_STRING)
-          string(APPEND FREETYPE_VERSION_STRING ".${FREETYPE_VERSION_PART}")
+        if(Freetype_VERSION)
+          string(APPEND Freetype_VERSION ".${FREETYPE_VERSION_PART}")
         else()
-          set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_PART}")
+          set(Freetype_VERSION "${FREETYPE_VERSION_PART}")
         endif()
         unset(FREETYPE_VERSION_PART)
       endif()
     endforeach()
   endforeach()
+  set(FREETYPE_VERSION_STRING ${Freetype_VERSION})
 endif()
 
 include(FindPackageHandleStandardArgs)
@@ -194,7 +212,7 @@ find_package_handle_standard_args(
     FREETYPE_LIBRARY
     FREETYPE_INCLUDE_DIRS
   VERSION_VAR
-    FREETYPE_VERSION_STRING
+    Freetype_VERSION
 )
 
 mark_as_advanced(

+ 1 - 1
Tests/CMakeOnly/AllFindModules/CMakeLists.txt

@@ -116,7 +116,7 @@ foreach(
     CUDA
     DOXYGEN
     EXPAT
-    FLEX
+    FLEX Freetype
     GIF GTK2
     HDF5
     JPEG

+ 1 - 1
Tests/FindFreetype/Test/CMakeLists.txt

@@ -4,7 +4,7 @@ include(CTest)
 
 find_package(Freetype REQUIRED)
 
-add_definitions(-DCMAKE_EXPECTED_FREETYPE_VERSION="${FREETYPE_VERSION_STRING}")
+add_definitions(-DCMAKE_EXPECTED_FREETYPE_VERSION="${Freetype_VERSION}")
 
 add_executable(testfreetype_tgt main.c)
 target_link_libraries(testfreetype_tgt Freetype::Freetype)