FindLua¶
Finds the Lua library:
find_package(Lua [<version>] [...])
Lua is a embeddable scripting language.
在 3.18 版被加入: Support for Lua 5.4.
When working with Lua, its library headers are intended to be included in project source code as:
#include <lua.h>
and not:
#include <lua/lua.h>
This is because, the location of Lua headers may differ across platforms and may
exist in locations other than lua/
.
結果變數¶
該模組定義了以下變數:
Lua_FOUND
在 3.3 版被加入.
Boolean indicating whether (the requested version of) Lua was found.
Lua_VERSION
在 4.2 版被加入.
The version of Lua found.
Lua_VERSION_MAJOR
在 4.2 版被加入.
The major version of Lua found.
Lua_VERSION_MINOR
在 4.2 版被加入.
The minor version of Lua found.
Lua_VERSION_PATCH
在 4.2 版被加入.
The patch version of Lua found.
LUA_LIBRARIES
Libraries needed to link against to use Lua. This list includes both
lua
andlualib
libraries.
快取變數¶
The following cache variables may also be set:
LUA_INCLUDE_DIR
The directory containing the Lua header files, such as
lua.h
,lualib.h
, andlauxlib.h
, needed to use Lua.
已棄用的變數¶
The following variables are provided for backward compatibility:
LUA_FOUND
在 4.2 版之後被棄用: Use
Lua_FOUND
, which has the same value.Boolean indicating whether (the requested version of) Lua was found.
LUA_VERSION_STRING
在 4.2 版之後被棄用: Superseded by the
Lua_VERSION
.The version of Lua found.
LUA_VERSION_MAJOR
在 4.2 版之後被棄用: Superseded by the
Lua_VERSION_MAJOR
.The major version of Lua found.
LUA_VERSION_MINOR
在 4.2 版之後被棄用: Superseded by the
Lua_VERSION_MINOR
.The minor version of Lua found.
LUA_VERSION_PATCH
在 4.2 版之後被棄用: Superseded by the
Lua_VERSION_PATCH
.The patch version of Lua found.
範例¶
Finding the Lua library and creating an interface imported target that encapsulates its usage requirements for linking to a project target:
find_package(Lua)
if(Lua_FOUND AND NOT TARGET Lua::Lua)
add_library(Lua::Lua INTERFACE IMPORTED)
set_target_properties(
Lua::Lua
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${LUA_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${LUA_LIBRARIES}"
)
endif()
target_link_libraries(project_target PRIVATE Lua::Lua)