Allow non-lua builds
This commit is contained in:
parent
7045b8fefd
commit
eed011b898
@ -2,14 +2,19 @@ cmake_minimum_required(VERSION 3.13)
|
||||
project(Couch)
|
||||
set(CMAKE_MODULE_PATH, ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR/cmake.})
|
||||
|
||||
add_compile_definitions(LUA_SCRIPTING)
|
||||
option(LUA_ENABLED "Lua scripting support" ON)
|
||||
if (LUA_ENABLED)
|
||||
add_compile_definitions(LUA_SCRIPTING)
|
||||
endif ()
|
||||
add_executable(couch core/couch.cpp)
|
||||
|
||||
add_subdirectory(core)
|
||||
target_link_libraries(couch couchlib)
|
||||
|
||||
add_subdirectory(scripting)
|
||||
target_link_libraries(couch couchlua)
|
||||
if (LUA_ENABLED)
|
||||
target_link_libraries(couch couchlua)
|
||||
endif()
|
||||
|
||||
add_subdirectory(thirdparty)
|
||||
|
||||
@ -24,4 +29,7 @@ if(WIN32)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
|
||||
endif(WIN32)
|
||||
|
||||
install(TARGETS couch couchlib couchlua)
|
||||
install(TARGETS couch couchlib)
|
||||
if (LUA_ENABLED)
|
||||
install(TARGETS couch couchlua)
|
||||
endif ()
|
||||
|
@ -8,8 +8,10 @@ find_package(glfw3 3.3 REQUIRED)
|
||||
## Find Bullet
|
||||
find_package(Bullet REQUIRED)
|
||||
|
||||
if (LUA_ENABLED)
|
||||
## Find Lua
|
||||
find_package(Lua REQUIRED)
|
||||
endif ()
|
||||
|
||||
add_library(couchlib SHARED)
|
||||
target_sources(couchlib PUBLIC
|
||||
@ -74,7 +76,9 @@ if(NOT WIN32)
|
||||
endif()
|
||||
target_link_libraries(couchlib OpenGL::GL)
|
||||
target_link_libraries(couchlib GLEW::GLEW)
|
||||
target_link_libraries(couchlib ${LUA_LIBRARIES})
|
||||
if (LUA_ENABLED)
|
||||
target_link_libraries(couchlib ${LUA_LIBRARIES})
|
||||
endif ()
|
||||
target_link_libraries(couchlib ${BULLET_LIBRARIES})
|
||||
|
||||
## Add documentation
|
||||
|
@ -85,8 +85,9 @@ bool Lua::HasHook(const char *name) {
|
||||
return exists;
|
||||
}
|
||||
|
||||
void Lua::LuaKeyHandler(Window *window, int key, int code, int action, int mods) {
|
||||
#ifdef LUA_SCRIPTING
|
||||
|
||||
void Lua::LuaKeyHandler(Window *window, int key, int code, int action, int mods) {
|
||||
// lua_State *L = (lua_State*) glfwGetWindowUserPointer(window);
|
||||
lua_getglobal(L, "onkey");
|
||||
lua_pushinteger(L, key);
|
||||
@ -97,11 +98,9 @@ void Lua::LuaKeyHandler(Window *window, int key, int code, int action, int mods)
|
||||
if (err != LUA_OK) {
|
||||
Error();
|
||||
}
|
||||
#endif // LUA_SCRIPTING
|
||||
}
|
||||
|
||||
void Lua::LuaMousePositionHandler(Window *window, double xpos, double ypos, double relx, double rely) {
|
||||
#ifdef LUA_SCRIPTING
|
||||
// lua_State *L = (lua_State*) glfwGetWindowUserPointer(window);
|
||||
lua_getglobal(L, "onmousemotion");
|
||||
lua_pushnumber(L, xpos);
|
||||
@ -112,5 +111,7 @@ void Lua::LuaMousePositionHandler(Window *window, double xpos, double ypos, doub
|
||||
if (err != LUA_OK) {
|
||||
Error();
|
||||
}
|
||||
#endif // LUA_SCRIPTING
|
||||
}
|
||||
|
||||
#endif // LUA_SCRIPTING
|
||||
|
||||
|
@ -2,21 +2,22 @@ include(UseSWIG)
|
||||
set_property(SOURCE couch.i PROPERTY CPLUSPLUS ON)
|
||||
set_property(SOURCE couch.i PROPERTY USE_TARGET_INCLUDE_DIRECTORIES ON)
|
||||
|
||||
if (NOT WIN32)
|
||||
swig_add_library(couchlua
|
||||
TYPE SHARED
|
||||
LANGUAGE lua
|
||||
SOURCES couch.i lua/helpers.i)
|
||||
else()
|
||||
swig_add_library(couchlua
|
||||
TYPE STATIC
|
||||
LANGUAGE lua
|
||||
SOURCES couch.i lua/helpers.i)
|
||||
endif()
|
||||
|
||||
if (LUA_ENABLED)
|
||||
if (NOT WIN32)
|
||||
swig_add_library(couchlua
|
||||
TYPE SHARED
|
||||
LANGUAGE lua
|
||||
SOURCES couch.i lua/helpers.i)
|
||||
else()
|
||||
swig_add_library(couchlua
|
||||
TYPE STATIC
|
||||
LANGUAGE lua
|
||||
SOURCES couch.i lua/helpers.i)
|
||||
endif()
|
||||
target_include_directories(couchlua PRIVATE "${PROJECT_SOURCE_DIR}/core")
|
||||
|
||||
swig_link_libraries(couchlua
|
||||
PRIVATE
|
||||
couchlib
|
||||
${LUA_LIBRARIES})
|
||||
endif ()
|
||||
|
Loading…
Reference in New Issue
Block a user