FindLua¶
Finds the Lua library. Lua is a embeddable scripting language.
Added in version 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/.
Result Variables¶
This module defines the following variables:
Lua_FOUNDBoolean indicating whether (the requested version of) Lua is found. For backward compatibility, the
LUA_FOUNDvariable is also set to the same value.LUA_VERSION_STRINGThe version of Lua found.
LUA_VERSION_MAJORThe major version of Lua found.
LUA_VERSION_MINORThe minor version of Lua found.
LUA_VERSION_PATCHThe patch version of Lua found.
LUA_LIBRARIESLibraries needed to link against to use Lua. This list includes both
luaandlualiblibraries.
Cache Variables¶
The following cache variables may also be set:
LUA_INCLUDE_DIRThe directory containing the Lua header files, such as
lua.h,lualib.h, andlauxlib.h, needed to use Lua.
Examples¶
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)