FindLua51: Use Lua51_VERSION result variable

If using both FindLua and FindLua51 modules, the FindLua51 and Lua 5.2
or newer is found, FindLua51 module can set the Lua_VERSION variable to
empty value. Instead, the Lua51_VERSION can be used to bypass this
issue.

Issue: #27088
This commit is contained in:
Peter Kokot
2025-10-13 12:10:24 -04:00
committed by Brad King
parent da592d67b1
commit b4a08078d6
3 changed files with 14 additions and 14 deletions
+3 -3
View File
@@ -7,9 +7,9 @@ FindLua50
.. note::
This module is specifically for Lua version branch 5.0, which is obsolete and
not maintained anymore. In new code use the latest supported Lua version and
the version-agnostic module :module:`FindLua` instead.
This module is intended specifically for Lua version branch 5.0, which is
obsolete and not maintained anymore. In new code use the latest supported
Lua version and the version-agnostic module :module:`FindLua` instead.
Finds the Lua library:
+10 -10
View File
@@ -7,9 +7,9 @@ FindLua51
.. note::
This module is specifically for Lua version branch 5.1, which is obsolete and
not maintained anymore. In new code use the latest supported Lua version and
the version-agnostic module :module:`FindLua` instead.
This module is intended specifically for Lua version branch 5.1, which is
obsolete and not maintained anymore. In new code use the latest supported
Lua version and the version-agnostic module :module:`FindLua` instead.
Finds the Lua library:
@@ -45,10 +45,10 @@ This module defines the following variables:
Boolean indicating whether (the requested version of) Lua was found.
``Lua_VERSION``
``Lua51_VERSION``
.. versionadded:: 4.2
The version of Lua found.
The version of Lua 5.1 found.
Cache Variables
^^^^^^^^^^^^^^^
@@ -75,9 +75,9 @@ The following variables are provided for backward compatibility:
``LUA_VERSION_STRING``
.. deprecated:: 4.2
Superseded by the ``Lua_VERSION``.
Use ``Lua51_VERSION``, which has the same value.
The version of Lua found.
The version of Lua 5.1 found.
Examples
^^^^^^^^
@@ -146,15 +146,15 @@ endif()
if(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
string(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" Lua_VERSION "${lua_version_str}")
set(LUA_VERSION_STRING "${Lua_VERSION}")
string(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" Lua51_VERSION "${lua_version_str}")
set(LUA_VERSION_STRING "${Lua51_VERSION}")
unset(lua_version_str)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Lua51
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
VERSION_VAR Lua_VERSION)
VERSION_VAR Lua51_VERSION)
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)
@@ -124,7 +124,7 @@ foreach(
HDF5 Hg HSPELL
Icotool ImageMagick
Jasper JPEG
LibArchive LibLZMA LIBLZMA LibXml2 LibXslt LTTngUST
LibArchive LibLZMA LIBLZMA LibXml2 LibXslt LTTngUST Lua
OpenCL OpenSceneGraph OPENSCENEGRAPH OpenSSL OPENSSL
Perl PerlLibs PkgConfig PNG PostgreSQL Protobuf
Ruby RUBY