1 # Search for the Lua 5.3 include files and libraries
4 # LUA_HINT: path to Lua installation -- only needed for non-standard installs
6 # HAVE_LUA : if Lua was found
7 # LUA_LIBRARY : the path to the dynamic library
8 # LUA_INCLUDE_DIR : where to find lua.h
9 # LUA_VERSION_MAJOR: First part of the version (often, 5)
10 # LUA_VERSION_MINOR: Second part of the version (3 when we have 5.3)
12 find_path(LUA_INCLUDE_DIR lua.h
15 PATH_SUFFIXES include/lua53 include/lua5.3 include/lua-5.3 include/lua include
20 /opt/local # DarwinPorts
25 find_library(LUA_LIBRARY
26 NAMES lua53 lua5.3 lua-5.3 lua
39 message(FATAL_ERROR "Error: Lua library not found. Please install that package (and set LUA_HINT) or disable Lua.")
41 if (NOT LUA_INCLUDE_DIR OR NOT EXISTS "${LUA_INCLUDE_DIR}/lua.h")
42 message(FATAL_ERROR "Error: Lua header file not found. Please install that package (and set LUA_HINT) or disable Lua.")
45 # Extract the version info out of the header file
46 file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_VERSION_MAJOR[ \t]+\"[456]+\"")
47 string(REGEX REPLACE "^#define[ \t]+LUA_VERSION_MAJOR[ \t]+\"([^\"]+)\"" "\\1" LUA_VERSION_MAJOR "${lua_version_str}")
48 file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_VERSION_MINOR[ \t]+\"[0123456789]+\"")
49 string(REGEX REPLACE "^#define[ \t]+LUA_VERSION_MINOR[ \t]+\"([^\"]+)\"" "\\1" LUA_VERSION_MINOR "${lua_version_str}")
50 unset(lua_version_str)
52 # Check that we have a sufficient version of Lua
53 if(LUA_VERSION_MAJOR EQUAL 5 AND LUA_VERSION_MINOR EQUAL 3)
56 include_directories(${LUA_INCLUDE_DIR})
58 message(FATAL_ERROR "Error: Lua version 5.3 is required, but version ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR} found instead.")
61 message(STATUS "Lua version: ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}")
62 message(STATUS "Lua library: ${LUA_LIBRARY}")