FindLua50

備註

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 FindLua instead.

Finds the Lua library:

find_package(Lua50 [...])

Lua is a embeddable scripting language.

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/.

結果變數

該模組定義了以下變數:

Lua50_FOUND

在 3.3 版被加入.

Boolean indicating whether Lua was found.

快取變數

The following cache variables may also be set:

LUA_INCLUDE_DIR

The directory containing the Lua header files, such as lua.h, lualib.h, and lauxlib.h, needed to use Lua.

LUA_LIBRARIES

Libraries needed to link against to use Lua. This list includes both lua and lualib libraries.

已棄用的變數

The following variables are provided for backward compatibility:

LUA50_FOUND

在 4.2 版之後被棄用: Use Lua50_FOUND, which has the same value.

Boolean indicating whether Lua was found.

範例

Finding the Lua 5.0 library and creating an interface imported target that encapsulates its usage requirements for linking to a project target:

find_package(Lua50)

if(Lua50_FOUND AND NOT TARGET Lua50::Lua50)
  add_library(Lua50::Lua50 INTERFACE IMPORTED)
  set_target_properties(
    Lua50::Lua50
    PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "${LUA_INCLUDE_DIR}"
      INTERFACE_LINK_LIBRARIES "${LUA_LIBRARIES}"
  )
endif()

target_link_libraries(project_target PRIVATE Lua50::Lua50)

另請參見

  • The FindLua module to find Lua in version-agnostic way.