-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] Add lua package finding in CMakeLists.txt. Default to Builtin v…
…ersion. Support: Builtin/LuaJIT/5.1/5.2/5.3/5.4.
- Loading branch information
1 parent
c88d6e9
commit 114481d
Showing
4 changed files
with
129 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# This file is from lua-cbson library: https://github.com/isage/lua-cbson/blob/master/cmake/FindLuaJIT.cmake | ||
# Locate LuaJIT library | ||
# This module defines | ||
# LUAJIT_FOUND, if false, do not try to link to Lua | ||
# LUA_LIBRARIES | ||
# LUA_INCLUDE_DIR, where to find lua.h | ||
# LUAJIT_VERSION_STRING, the version of Lua found (since CMake 2.8.8) | ||
|
||
## Copied from default CMake FindLua51.cmake | ||
|
||
find_path(LUA_INCLUDE_DIR luajit.h | ||
HINTS | ||
ENV LUA_DIR | ||
PATH_SUFFIXES include/luajit-2.0 include/luajit-2.1 include | ||
PATHS | ||
~/Library/Frameworks | ||
/Library/Frameworks | ||
/sw # Fink | ||
/opt/local # DarwinPorts | ||
/opt/csw # Blastwave | ||
/opt | ||
/usr/local/openresty/luajit/ # openresty | ||
) | ||
|
||
find_library(LUA_LIBRARY | ||
NAMES luajit-5.1 luajit-5.2 lua | ||
HINTS | ||
ENV LUA_DIR | ||
PATH_SUFFIXES lib | ||
PATHS | ||
~/Library/Frameworks | ||
/Library/Frameworks | ||
/sw | ||
/opt/local | ||
/opt/csw | ||
/opt | ||
/usr/local/openresty/luajit/ # openresty | ||
) | ||
|
||
if(LUA_LIBRARY) | ||
# include the math library for Unix | ||
# if(UNIX AND NOT APPLE) | ||
# find_library(LUA_MATH_LIBRARY m) | ||
# set( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries") | ||
# For Windows and Mac, don't need to explicitly include the math library | ||
# else() | ||
set( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries") | ||
# endif() | ||
endif() | ||
|
||
if(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/luajit.h") | ||
file(STRINGS "${LUA_INCLUDE_DIR}/luajit.h" luajit_version_str REGEX "^#define[ \t]+LUAJIT_VERSION[ \t]+\"LuaJIT .+\"") | ||
|
||
string(REGEX REPLACE "^#define[ \t]+LUAJIT_VERSION[ \t]+\"LuaJIT ([^\"]+)\".*" "\\1" LUAJIT_VERSION_STRING "${luajit_version_str}") | ||
unset(luajit_version_str) | ||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if | ||
# all listed variables are TRUE | ||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJIT | ||
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR | ||
VERSION_VAR LUAJIT_VERSION_STRING) | ||
|
||
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters