FindLua
Finds the Lua library:
find_package(Lua [<version>] [...])
Lua is a embeddable scripting language.
Added in version 3.18: Support for Lua 5.4.
Added in version 4.3: Support for Lua 5.5.
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_FOUND -
Added in version 3.3.
Boolean indicating whether (the requested version of) Lua was found.
-
Lua_VERSION -
Added in version 4.2.
The version of Lua found.
-
Lua_VERSION_MAJOR -
Added in version 4.2.
The major version of Lua found.
-
Lua_VERSION_MINOR -
Added in version 4.2.
The minor version of Lua found.
-
Lua_VERSION_PATCH -
Added in version 4.2.
The patch version of Lua found.
-
LUA_LIBRARIES -
Libraries needed to link against to use Lua. This list includes both
luaandlualiblibraries.
Cache Variables
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.
Deprecated Variables
The following variables are provided for backward compatibility:
-
LUA_FOUND -
Deprecated since version 4.2: Use
Lua_FOUND, which has the same value.Boolean indicating whether (the requested version of) Lua was found.
-
LUA_VERSION_STRING -
Deprecated since version 4.2: Superseded by the
Lua_VERSION.The version of Lua found.
-
LUA_VERSION_MAJOR -
Deprecated since version 4.2: Superseded by the
Lua_VERSION_MAJOR.The major version of Lua found.
-
LUA_VERSION_MINOR -
Deprecated since version 4.2: Superseded by the
Lua_VERSION_MINOR.The minor version of Lua found.
-
LUA_VERSION_PATCH -
Deprecated since version 4.2: Superseded by the
Lua_VERSION_PATCH.The patch version of Lua found.
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)
© 2000–2026 Kitware, Inc. and Contributors
Licensed under the BSD 3-clause License.
https://cmake.org/cmake/help/latest/module/FindLua.html