mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
FindLua: Add support for Lua 5.5
Fixes: #27476 Co-authored-by: Tyler Yankee <tyler.yankee@kitware.com>
This commit is contained in:
committed by
Tyler Yankee
co-authored by
Tyler Yankee
parent
538926c532
commit
261b7b933c
@@ -16,6 +16,9 @@ Lua is a embeddable scripting language.
|
||||
.. versionadded:: 3.18
|
||||
Support for Lua 5.4.
|
||||
|
||||
.. versionadded:: 4.3
|
||||
Support for Lua 5.5.
|
||||
|
||||
When working with Lua, its library headers are intended to be included in
|
||||
project source code as:
|
||||
|
||||
@@ -144,7 +147,7 @@ unset(_lua_append_versions)
|
||||
|
||||
# this is a function only to have all the variables inside go away automatically
|
||||
function(_lua_get_versions)
|
||||
set(LUA_VERSIONS5 5.4 5.3 5.2 5.1 5.0)
|
||||
set(LUA_VERSIONS5 5.5 5.4 5.3 5.2 5.1 5.0)
|
||||
|
||||
if (Lua_FIND_VERSION_EXACT)
|
||||
if (Lua_FIND_VERSION_COUNT GREATER 1)
|
||||
@@ -214,11 +217,11 @@ function(_lua_get_header_version)
|
||||
file(STRINGS "${_hdr_file}" lua_version_strings
|
||||
REGEX "^#define[ \t]+LUA_(RELEASE[ \t]+\"Lua [0-9]|VERSION([ \t]+\"Lua [0-9]|_[MR])).*")
|
||||
|
||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MAJOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" Lua_VERSION_MAJOR ";${lua_version_strings};")
|
||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MAJOR(_N)?[ \t]+\"?([0-9])\"?[ \t]*;.*" "\\2" Lua_VERSION_MAJOR ";${lua_version_strings};")
|
||||
|
||||
if (Lua_VERSION_MAJOR MATCHES "^[0-9]+$")
|
||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MINOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" Lua_VERSION_MINOR ";${lua_version_strings};")
|
||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_RELEASE[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" Lua_VERSION_PATCH ";${lua_version_strings};")
|
||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MINOR(_N)?[ \t]+\"?([0-9])\"?[ \t]*;.*" "\\2" Lua_VERSION_MINOR ";${lua_version_strings};")
|
||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_RELEASE(_N)?[ \t]+\"?([0-9])\"?[ \t]*;.*" "\\2" Lua_VERSION_PATCH ";${lua_version_strings};")
|
||||
set(Lua_VERSION "${Lua_VERSION_MAJOR}.${Lua_VERSION_MINOR}.${Lua_VERSION_PATCH}")
|
||||
else ()
|
||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" Lua_VERSION ";${lua_version_strings};")
|
||||
|
||||
@@ -64,13 +64,13 @@ endfunction()
|
||||
# Simple test
|
||||
test_path(prefix1 prefix1/include 5.3)
|
||||
# Find highest version
|
||||
test_path(prefix2 prefix2/include/lua5.3 5.3)
|
||||
foreach(ver 5.3 5.2 5.1)
|
||||
test_path(prefix2 prefix2/include/lua5.5 5.5)
|
||||
foreach(ver 5.5 5.3 5.2 5.1)
|
||||
# At least X or X.0 -> Highest
|
||||
set(VERSION "${ver}")
|
||||
test_path(prefix2 prefix2/include/lua5.3 5.3)
|
||||
test_path(prefix2 prefix2/include/lua5.5 5.5)
|
||||
set(VERSION "${ver}.0")
|
||||
test_path(prefix2 prefix2/include/lua5.3 5.3)
|
||||
test_path(prefix2 prefix2/include/lua5.5 5.5)
|
||||
# Exactly X/X.0
|
||||
set(VERSION "${ver}" EXACT)
|
||||
test_path(prefix2 prefix2/include/lua${ver} ${ver})
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
#define LUA_VERSION_MAJOR_N 5
|
||||
#define LUA_VERSION_MINOR_N 5
|
||||
#define LUA_VERSION_RELEASE_N 0
|
||||
|
||||
#define LUA_VERSION_NUM (LUA_VERSION_MAJOR_N * 100 + LUA_VERSION_MINOR_N)
|
||||
#define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + LUA_VERSION_RELEASE_N)
|
||||
|
||||
#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
|
||||
#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
|
||||
Reference in New Issue
Block a user