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 # I don't want a lua.a
27 lua53.so lua5.3.so lua-5.3.so
28 lua53.dynlib lua5.3.dynlib lua-5.3.dynlib
29 lua53.dll lua5.3.dll lua-5.3.dll
30 lua.so lua.dynlib lua.dll
31 lua53 lua5.3 lua-5.3 lua
44 message(FATAL_ERROR "Error: Lua library not found. Please install that package (and set LUA_HINT) or disable Lua.")
46 if (NOT LUA_INCLUDE_DIR OR NOT EXISTS "${LUA_INCLUDE_DIR}/lua.h")
47 message(FATAL_ERROR "Error: Lua header file not found. Please install that package (and set LUA_HINT) or disable Lua.")
50 # Extract the version info out of the header file
51 file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_VERSION_MAJOR[ \t]+\"[456]+\"")
52 string(REGEX REPLACE "^#define[ \t]+LUA_VERSION_MAJOR[ \t]+\"([^\"]+)\"" "\\1" LUA_VERSION_MAJOR "${lua_version_str}")
53 file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_VERSION_MINOR[ \t]+\"[0123456789]+\"")
54 string(REGEX REPLACE "^#define[ \t]+LUA_VERSION_MINOR[ \t]+\"([^\"]+)\"" "\\1" LUA_VERSION_MINOR "${lua_version_str}")
55 unset(lua_version_str)
57 # Check that we have a sufficient version of Lua
58 if(LUA_VERSION_MAJOR EQUAL 5 AND LUA_VERSION_MINOR EQUAL 3)
61 include_directories(${LUA_INCLUDE_DIR})
63 message(FATAL_ERROR "Error: Lua version 5.3 is required, but version ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR} found instead.")
66 message(STATUS "Lua version: ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}")
67 message(STATUS "Lua library: ${LUA_LIBRARY}")