Merge topic 'patch-FindSDL-version'

faca50bd3f FindSDL*: Add <PackageName>_VERSION

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11004
This commit is contained in:
Brad King
2025-08-04 14:27:25 +00:00
committed by Kitware Robot
9 changed files with 159 additions and 56 deletions

View File

@@ -31,3 +31,9 @@ Find Modules
* The :module:`FindPostgreSQL` module now provides a ``PostgreSQL_VERSION``
result variable. The ``PostgreSQL_VERSION_STRING`` result variable is
deprecated.
* The :module:`FindSDL_gfx`, :module:`FindSDL_image`, :module:`FindSDL_mixer`,
:module:`FindSDL_net`, :module:`FindSDL_sound`, and :module:`FindSDL_ttf`
modules now provide their respective ``<PackageName>_VERSION`` result
variables. Previous ``<PACKAGENAME>_VERSION_STRING`` result variables
are deprecated.

View File

@@ -5,8 +5,14 @@
FindSDL
-------
Finds the SDL (Simple DirectMedia Layer) library. SDL is a cross-platform
library for developing multimedia software, such as games and emulators.
Finds the SDL (Simple DirectMedia Layer) library:
.. code-block:: cmake
find_package(SDL [<version>] [...])
SDL is a cross-platform library for developing multimedia software, such as
games and emulators.
.. note::
@@ -127,7 +133,7 @@ value. If they are not set, ``SDL_LIBRARY`` will remain undefined.
Deprecated Variables
^^^^^^^^^^^^^^^^^^^^
These variables are obsolete and provided for backwards compatibility:
The following variables are provided for backward compatibility:
``SDL_VERSION_STRING``
.. deprecated:: 3.19
@@ -288,7 +294,7 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SDL
REQUIRED_VARS SDL_LIBRARY SDL_INCLUDE_DIR
VERSION_VAR SDL_VERSION_STRING)
VERSION_VAR SDL_VERSION)
if(SDL_FOUND)
set(SDL_LIBRARIES ${SDL_LIBRARY})

View File

@@ -8,7 +8,11 @@ FindSDL_gfx
.. versionadded:: 3.25
Finds the SDL_gfx library that provides graphics support in SDL (Simple
DirectMedia Layer) applications.
DirectMedia Layer) applications:
.. code-block:: cmake
find_package(SDL_gfx [<version>] [...])
.. note::
@@ -30,10 +34,13 @@ Result Variables
This module defines the following variables:
``SDL_gfx_FOUND``
Boolean indicating whether the (requested version of) SDL_gfx library is
Boolean indicating whether (the requested version of) SDL_gfx library is
found. For backward compatibility, the ``SDL_GFX_FOUND`` variable is also set
to the same value.
``SDL_GFX_VERSION_STRING``
``SDL_gfx_VERSION``
.. versionadded:: 4.2
The human-readable string containing the version of SDL_gfx found.
Cache Variables
@@ -43,6 +50,7 @@ The following cache variables may also be set:
``SDL_GFX_INCLUDE_DIRS``
The directory containing the headers needed to use SDL_gfx.
``SDL_GFX_LIBRARIES``
The path to the SDL_gfx library needed to link against to use SDL_gfx.
@@ -57,6 +65,17 @@ This module accepts the following variables:
was used when configuring, building, and installing SDL library:
``./configure --prefix=$SDLDIR``.
Deprecated Variables
^^^^^^^^^^^^^^^^^^^^
The following variables are provided for backward compatibility:
``SDL_GFX_VERSION_STRING``
.. deprecated:: 4.2
Use the ``SDL_gfx_VERSION``.
The human-readable string containing the version of SDL_gfx found.
Examples
^^^^^^^^
@@ -113,7 +132,8 @@ if(SDL_GFX_INCLUDE_DIRS AND EXISTS "${SDL_GFX_INCLUDE_DIRS}/SDL_gfxPrimitives.h"
string(REGEX REPLACE "^#define[ \t]+SDL_GFXPRIMITIVES_MAJOR[ \t]+([0-9]+)$" "\\1" SDL_GFX_VERSION_MAJOR "${SDL_GFX_VERSION_MAJOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL_GFXPRIMITIVES_MINOR[ \t]+([0-9]+)$" "\\1" SDL_GFX_VERSION_MINOR "${SDL_GFX_VERSION_MINOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL_GFXPRIMITIVES_MICRO[ \t]+([0-9]+)$" "\\1" SDL_GFX_VERSION_PATCH "${SDL_GFX_VERSION_PATCH_LINE}")
set(SDL_GFX_VERSION_STRING ${SDL_GFX_VERSION_MAJOR}.${SDL_GFX_VERSION_MINOR}.${SDL_GFX_VERSION_PATCH})
set(SDL_gfx_VERSION ${SDL_GFX_VERSION_MAJOR}.${SDL_GFX_VERSION_MINOR}.${SDL_GFX_VERSION_PATCH})
set(SDL_GFX_VERSION_STRING "${SDL_gfx_VERSION}")
unset(SDL_GFX_VERSION_MAJOR_LINE)
unset(SDL_GFX_VERSION_MINOR_LINE)
unset(SDL_GFX_VERSION_PATCH_LINE)
@@ -126,7 +146,7 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SDL_gfx
REQUIRED_VARS SDL_GFX_LIBRARIES SDL_GFX_INCLUDE_DIRS
VERSION_VAR SDL_GFX_VERSION_STRING)
VERSION_VAR SDL_gfx_VERSION)
if(SDL_gfx_FOUND)
if(NOT TARGET SDL::SDL_gfx)

View File

@@ -6,7 +6,11 @@ FindSDL_image
-------------
Finds the SDL_image library that loads images of various formats as SDL (Simple
DirectMedia Layer) surfaces.
DirectMedia Layer) surfaces:
.. code-block:: cmake
find_package(SDL_image [<version>] [...])
.. note::
@@ -27,7 +31,9 @@ This module defines the following variables:
found. For backward compatibility, the ``SDL_IMAGE_FOUND`` variable is also
set to the same value.
``SDL_IMAGE_VERSION_STRING``
``SDL_image_VERSION``
.. versionadded:: 4.2
The human-readable string containing the version of SDL_image found.
``SDL_IMAGE_INCLUDE_DIRS``
@@ -50,7 +56,13 @@ This module accepts the following variables:
Deprecated Variables
^^^^^^^^^^^^^^^^^^^^
For backward compatibility the following variables are also set:
The following variables are provided for backward compatibility:
``SDL_IMAGE_VERSION_STRING``
.. deprecated:: 4.2
Use the ``SDL_image_VERSION``.
The human-readable string containing the version of SDL_image found.
``SDLIMAGE_FOUND``
.. deprecated:: 2.8.10
@@ -149,7 +161,8 @@ if(SDL_IMAGE_INCLUDE_DIR AND EXISTS "${SDL_IMAGE_INCLUDE_DIR}/SDL_image.h")
string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_IMAGE_VERSION_MAJOR "${SDL_IMAGE_VERSION_MAJOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_IMAGE_VERSION_MINOR "${SDL_IMAGE_VERSION_MINOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_IMAGE_VERSION_PATCH "${SDL_IMAGE_VERSION_PATCH_LINE}")
set(SDL_IMAGE_VERSION_STRING ${SDL_IMAGE_VERSION_MAJOR}.${SDL_IMAGE_VERSION_MINOR}.${SDL_IMAGE_VERSION_PATCH})
set(SDL_image_VERSION ${SDL_IMAGE_VERSION_MAJOR}.${SDL_IMAGE_VERSION_MINOR}.${SDL_IMAGE_VERSION_PATCH})
set(SDL_IMAGE_VERSION_STRING "${SDL_image_VERSION}")
unset(SDL_IMAGE_VERSION_MAJOR_LINE)
unset(SDL_IMAGE_VERSION_MINOR_LINE)
unset(SDL_IMAGE_VERSION_PATCH_LINE)
@@ -165,7 +178,7 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SDL_image
REQUIRED_VARS SDL_IMAGE_LIBRARIES SDL_IMAGE_INCLUDE_DIRS
VERSION_VAR SDL_IMAGE_VERSION_STRING)
VERSION_VAR SDL_image_VERSION)
# for backward compatibility
set(SDLIMAGE_LIBRARY ${SDL_IMAGE_LIBRARIES})

View File

@@ -6,7 +6,11 @@ FindSDL_mixer
-------------
Finds the SDL_mixer library that provides an audio mixer with support for
various file formats in SDL (Simple DirectMedia Layer) applications.
various file formats in SDL (Simple DirectMedia Layer) applications:
.. code-block:: cmake
find_package(SDL_mixer [<version>] [...])
.. note::
@@ -26,7 +30,9 @@ This module defines the following variables:
found. For backward compatibility, the ``SDL_MIXER_FOUND`` variable is also
set to the same value.
``SDL_MIXER_VERSION_STRING``
``SDL_mixer_VERSION``
.. versionadded:: 4.2
The human-readable string containing the version of SDL_mixer found.
``SDL_MIXER_INCLUDE_DIRS``
@@ -49,7 +55,13 @@ This module accepts the following variables:
Deprecated Variables
^^^^^^^^^^^^^^^^^^^^
For backward compatibility the following variables are also set:
The following variables are provided for backward compatibility:
``SDL_MIXER_VERSION_STRING``
.. deprecated:: 4.2
Use the ``SDL_mixer_VERSION``.
The human-readable string containing the version of SDL_mixer found.
``SDLMIXER_FOUND``
.. deprecated:: 2.8.10
@@ -141,7 +153,8 @@ if(SDL_MIXER_INCLUDE_DIR AND EXISTS "${SDL_MIXER_INCLUDE_DIR}/SDL_mixer.h")
string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_MIXER_VERSION_MAJOR "${SDL_MIXER_VERSION_MAJOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_MIXER_VERSION_MINOR "${SDL_MIXER_VERSION_MINOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_MIXER_VERSION_PATCH "${SDL_MIXER_VERSION_PATCH_LINE}")
set(SDL_MIXER_VERSION_STRING ${SDL_MIXER_VERSION_MAJOR}.${SDL_MIXER_VERSION_MINOR}.${SDL_MIXER_VERSION_PATCH})
set(SDL_mixer_VERSION ${SDL_MIXER_VERSION_MAJOR}.${SDL_MIXER_VERSION_MINOR}.${SDL_MIXER_VERSION_PATCH})
set(SDL_MIXER_VERSION_STRING "${SDL_mixer_VERSION}")
unset(SDL_MIXER_VERSION_MAJOR_LINE)
unset(SDL_MIXER_VERSION_MINOR_LINE)
unset(SDL_MIXER_VERSION_PATCH_LINE)
@@ -157,7 +170,7 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SDL_mixer
REQUIRED_VARS SDL_MIXER_LIBRARIES SDL_MIXER_INCLUDE_DIRS
VERSION_VAR SDL_MIXER_VERSION_STRING)
VERSION_VAR SDL_mixer_VERSION)
# for backward compatibility
set(SDLMIXER_LIBRARY ${SDL_MIXER_LIBRARIES})

View File

@@ -6,7 +6,11 @@ FindSDL_net
-----------
Finds the SDL_net library, a cross-platform network library for use with the
SDL (Simple DirectMedia Layer) applications.
SDL (Simple DirectMedia Layer) applications:
.. code-block:: cmake
find_package(SDL_net [<version>] [...])
.. note::
@@ -26,7 +30,9 @@ This module defines the following variables:
found. For backward compatibility, the ``SDL_NET_FOUND`` variable is also set
to the same value.
``SDL_NET_VERSION_STRING``
``SDL_net_VERSION``
..versionadded:: 4.2
The human-readable string containing the version of SDL_net found.
``SDL_NET_INCLUDE_DIRS``
@@ -35,10 +41,27 @@ This module defines the following variables:
``SDL_NET_LIBRARIES``
Libraries needed to link against to use the SDL_net library.
Hints
^^^^^
This module accepts the following variables:
``SDLDIR``
Environment variable that can be set to help locate an SDL library installed
in a custom location. It should point to the installation destination that
was used when configuring, building, and installing SDL library:
``./configure --prefix=$SDLDIR``.
Deprecated Variables
^^^^^^^^^^^^^^^^^^^^
For backward compatibility the following variables are also set:
The following variables are provided for backward compatibility:
``SDL_NET_VERSION_STRING``
.. deprecated:: 4.2
Use the ``SDL_net_VERSION``.
The human-readable string containing the version of SDL_net found.
``SDLNET_FOUND``
.. deprecated:: 2.8.10
@@ -52,17 +75,6 @@ For backward compatibility the following variables are also set:
.. deprecated:: 2.8.10
Use the ``SDL_NET_LIBRARIES``, which has the same value.
Hints
^^^^^
This module accepts the following variables:
``SDLDIR``
Environment variable that can be set to help locate an SDL library installed
in a custom location. It should point to the installation destination that
was used when configuring, building, and installing SDL library:
``./configure --prefix=$SDLDIR``.
Examples
^^^^^^^^
@@ -141,7 +153,8 @@ if(SDL_NET_INCLUDE_DIR AND EXISTS "${SDL_NET_INCLUDE_DIR}/SDL_net.h")
string(REGEX REPLACE "^#define[ \t]+SDL_NET_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_NET_VERSION_MAJOR "${SDL_NET_VERSION_MAJOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL_NET_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_NET_VERSION_MINOR "${SDL_NET_VERSION_MINOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL_NET_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_NET_VERSION_PATCH "${SDL_NET_VERSION_PATCH_LINE}")
set(SDL_NET_VERSION_STRING ${SDL_NET_VERSION_MAJOR}.${SDL_NET_VERSION_MINOR}.${SDL_NET_VERSION_PATCH})
set(SDL_net_VERSION ${SDL_NET_VERSION_MAJOR}.${SDL_NET_VERSION_MINOR}.${SDL_NET_VERSION_PATCH})
set(SDL_NET_VERSION_STRING "${SDL_net_VERSION}")
unset(SDL_NET_VERSION_MAJOR_LINE)
unset(SDL_NET_VERSION_MINOR_LINE)
unset(SDL_NET_VERSION_PATCH_LINE)
@@ -157,7 +170,7 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SDL_net
REQUIRED_VARS SDL_NET_LIBRARIES SDL_NET_INCLUDE_DIRS
VERSION_VAR SDL_NET_VERSION_STRING)
VERSION_VAR SDL_net_VERSION)
# for backward compatibility
set(SDLNET_LIBRARY ${SDL_NET_LIBRARIES})

View File

@@ -6,7 +6,11 @@ FindSDL_sound
-------------
Finds the SDL_sound library, an abstract soundfile decoder for use in SDL
(Simple DirectMedia Layer) applications.
(Simple DirectMedia Layer) applications:
.. code-block:: cmake
find_package(SDL_sound [<version>] [...])
.. note::
@@ -35,7 +39,9 @@ This module defines the following variables:
found. For backward compatibility, the ``SDL_SOUND_FOUND`` variable is also
set to the same value.
``SDL_SOUND_VERSION_STRING``
``SDL_sound_VERSION``
.. versionadded:: 4.2
The human-readable string containing the version of SDL_sound found.
``SDL_SOUND_LIBRARIES``
@@ -100,6 +106,17 @@ This module accepts the following variables:
available mostly for cases this module failed to anticipate for and additional
flags must be added.
Deprecated Variables
^^^^^^^^^^^^^^^^^^^^
The following variables are provided for backward compatibility:
``SDL_SOUND_VERSION_STRING``
.. deprecated:: 4.2
Use the ``SDL_sound_VERSION``.
The human-readable string containing the version of SDL_sound found.
Examples
^^^^^^^^
@@ -441,7 +458,8 @@ if(SDL_SOUND_INCLUDE_DIR AND EXISTS "${SDL_SOUND_INCLUDE_DIR}/SDL_sound.h")
string(REGEX REPLACE "^#define[ \t]+SOUND_VER_MAJOR[ \t]+([0-9]+)$" "\\1" SDL_SOUND_VERSION_MAJOR "${SDL_SOUND_VERSION_MAJOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SOUND_VER_MINOR[ \t]+([0-9]+)$" "\\1" SDL_SOUND_VERSION_MINOR "${SDL_SOUND_VERSION_MINOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SOUND_VER_PATCH[ \t]+([0-9]+)$" "\\1" SDL_SOUND_VERSION_PATCH "${SDL_SOUND_VERSION_PATCH_LINE}")
set(SDL_SOUND_VERSION_STRING ${SDL_SOUND_VERSION_MAJOR}.${SDL_SOUND_VERSION_MINOR}.${SDL_SOUND_VERSION_PATCH})
set(SDL_sound_VERSION ${SDL_SOUND_VERSION_MAJOR}.${SDL_SOUND_VERSION_MINOR}.${SDL_SOUND_VERSION_PATCH})
set(SDL_SOUND_VERSION_STRING "${SDL_sound_VERSION}")
unset(SDL_SOUND_VERSION_MAJOR_LINE)
unset(SDL_SOUND_VERSION_MINOR_LINE)
unset(SDL_SOUND_VERSION_PATCH_LINE)
@@ -454,6 +472,6 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SDL_sound
REQUIRED_VARS SDL_SOUND_LIBRARY SDL_SOUND_INCLUDE_DIR
VERSION_VAR SDL_SOUND_VERSION_STRING)
VERSION_VAR SDL_sound_VERSION)
cmake_policy(POP)

View File

@@ -6,7 +6,11 @@ FindSDL_ttf
-----------
Finds the SDL_ttf library that provides support for rendering text with TrueType
fonts in SDL (Simple DirectMedia Layer) applications.
fonts in SDL (Simple DirectMedia Layer) applications:
.. code-block:: cmake
find_package(SDL_ttf [<version>] [...])
.. note::
@@ -27,7 +31,9 @@ This module defines the following variables:
found. For backward compatibility, the ``SDL_TTF_FOUND`` variable is also set
to the same value.
``SDL_TTF_VERSION_STRING``
``SDL_ttf_VERSION``
.. versionadded:: 4.2
The human-readable string containing the version of SDL_ttf found.
``SDL_TTF_INCLUDE_DIRS``
@@ -36,10 +42,27 @@ This module defines the following variables:
``SDL_TTF_LIBRARIES``
Libraries needed to link against to use SDL_ttf.
Hints
^^^^^
This module accepts the following variables:
``SDLDIR``
Environment variable that can be set to help locate an SDL library installed
in a custom location. It should point to the installation destination that
was used when configuring, building, and installing SDL library:
``./configure --prefix=$SDLDIR``.
Deprecated Variables
^^^^^^^^^^^^^^^^^^^^
For backward compatibility the following variables are also set:
The following variables are provided for backward compatibility:
``SDL_TTF_VERSION_STRING``
.. deprecated:: 4.2
Use the ``SDL_ttf_VERSION``.
The human-readable string containing the version of SDL_ttf found.
``SDLTTF_FOUND``
.. deprecated:: 2.8.10
@@ -53,17 +76,6 @@ For backward compatibility the following variables are also set:
.. deprecated:: 2.8.10
Replaced with ``SDL_TTF_LIBRARIES``, which has the same value.
Hints
^^^^^
This module accepts the following variables:
``SDLDIR``
Environment variable that can be set to help locate an SDL library installed
in a custom location. It should point to the installation destination that
was used when configuring, building, and installing SDL library:
``./configure --prefix=$SDLDIR``.
Examples
^^^^^^^^
@@ -149,7 +161,8 @@ if(SDL_TTF_INCLUDE_DIR AND EXISTS "${SDL_TTF_INCLUDE_DIR}/SDL_ttf.h")
string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_MAJOR "${SDL_TTF_VERSION_MAJOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_MINOR "${SDL_TTF_VERSION_MINOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_PATCH "${SDL_TTF_VERSION_PATCH_LINE}")
set(SDL_TTF_VERSION_STRING ${SDL_TTF_VERSION_MAJOR}.${SDL_TTF_VERSION_MINOR}.${SDL_TTF_VERSION_PATCH})
set(SDL_ttf_VERSION ${SDL_TTF_VERSION_MAJOR}.${SDL_TTF_VERSION_MINOR}.${SDL_TTF_VERSION_PATCH})
set(SDL_TTF_VERSION_STRING "${SDL_ttf_VERSION}")
unset(SDL_TTF_VERSION_MAJOR_LINE)
unset(SDL_TTF_VERSION_MINOR_LINE)
unset(SDL_TTF_VERSION_PATCH_LINE)
@@ -165,7 +178,7 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SDL_ttf
REQUIRED_VARS SDL_TTF_LIBRARIES SDL_TTF_INCLUDE_DIRS
VERSION_VAR SDL_TTF_VERSION_STRING)
VERSION_VAR SDL_ttf_VERSION)
# for backward compatibility
set(SDLTTF_LIBRARY ${SDL_TTF_LIBRARIES})

View File

@@ -103,6 +103,7 @@ foreach(
JASPER
LIBLZMA LIBXML2 LIBXSLT LTTNGUST
PERL PKG_CONFIG PNG PostgreSQL
SDL
TIFF
ZLIB
)
@@ -124,7 +125,7 @@ foreach(
OPENSCENEGRAPH
PNG PostgreSQL Protobuf
Ruby RUBY
SWIG
SDL SWIG
ZLIB
)
check_version_string(${VTEST} ${VTEST}_VERSION)