-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-detect Lua compatible with installed Luabind
- Loading branch information
alex85k
committed
Sep 18, 2014
1 parent
8e72c3d
commit f14c6e6
Showing
2 changed files
with
31 additions
and
0 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,29 @@ | ||
INCLUDE (CheckCXXSourceCompiles) | ||
unset(LUABIND_WORKS CACHE) | ||
unset(LUABIND51_WORKS CACHE) | ||
SET (LUABIND_CHECK_SRC "#include \"lua.h\"\n#include <luabind/luabind.hpp>\n int main() { lua_State *myLuaState = luaL_newstate(); luabind::open(myLuaState); return 0;}") | ||
SET (CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE}) | ||
SET (CMAKE_REQUIRED_INCLUDES "${Boost_INCLUDE_DIR};${LUABIND_INCLUDE_DIR};${LUA_INCLUDE_DIR}") | ||
SET (CMAKE_REQUIRED_LIBRARIES "${LUABIND_LIBRARY};${LUA_LIBRARY}") | ||
|
||
CHECK_CXX_SOURCE_COMPILES("${LUABIND_CHECK_SRC}" LUABIND_WORKS) | ||
|
||
if( LUABIND_WORKS ) | ||
MESSAGE("Luabind works with ${LUA_LIBRARY}") | ||
else() | ||
MESSAGE("Luabind does not work with ${LUA_LIBRARY}, will try Lua 5.1.") | ||
unset(LUA_FOUND CACHE) | ||
unset(LUA_INCLUDE_DIR CACHE) | ||
unset(LUA_LIBRARY CACHE) | ||
find_package(Lua51) | ||
SET (CMAKE_REQUIRED_INCLUDES "${Boost_INCLUDE_DIR};${LUABIND_INCLUDE_DIR};${LUA_INCLUDE_DIR}") | ||
SET (CMAKE_REQUIRED_LIBRARIES "${LUABIND_LIBRARY};${LUA_LIBRARY}") | ||
|
||
CHECK_CXX_SOURCE_COMPILES("${LUABIND_CHECK_SRC}" LUABIND51_WORKS) | ||
|
||
if( LUABIND51_WORKS ) | ||
MESSAGE("Luabind works with Lua 5.1 at ${LUA_LIBRARY}") | ||
else() | ||
MESSAGE(FATAL_ERROR "Luabind does not work with Lua 5.1 at ${LUA_LIBRARY}, no working Luabind found") | ||
endif() | ||
endif() |