forked from ElektraInitiative/libelektra
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
62 lines (52 loc) · 1.96 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
include (LibAddBinding)
if (DEPENDENCY_PHASE)
set (LUA_REQUIRED_VERSION 5.1)
find_package (Lua ${LUA_REQUIRED_VERSION} QUIET)
find_swig ()
check_binding_included ("swig_lua"
BINDING_WAS_ADDED
SUBDIRECTORY
"swig/lua"
SILENT)
if (LUA_FOUND AND SWIG_FOUND AND BINDING_WAS_ADDED)
include (LibAddMacros)
add_custom_command (OUTPUT runtime.h
COMMAND ${SWIG_EXECUTABLE}
-c++
-lua
-external-runtime
runtime.h)
# we call this SWIG_COMPILE_FLAGS because we have the same variable in our swig bindings
set (SWIG_COMPILE_FLAGS "-Wno-shadow -Wno-old-style-cast -Wno-unused-variable")
set_source_files_properties (lua.cpp
PROPERTIES
COMPILE_FLAGS
"${SWIG_COMPILE_FLAGS}")
elseif (NOT LUA_FOUND)
remove_plugin (lua "Lua libs (>= liblua${LUA_REQUIRED_VERSION}-dev) not found")
elseif (NOT BINDING_WAS_ADDED)
remove_plugin (lua "swig_lua binding is required")
else ()
remove_plugin (lua "swig not found")
endif ()
endif ()
add_plugin (lua CPP
SOURCES lua.hpp lua.cpp ${CMAKE_CURRENT_BINARY_DIR}/runtime.h
INCLUDE_DIRECTORIES ${LUA_INCLUDE_DIR}
LINK_LIBRARIES ${LUA_LIBRARIES}
COMPILE_DEFINITIONS SWIG_TYPE_TABLE=kdb
INSTALL_TEST_DATA)
if (ADDTESTING_PHASE)
# TODO: ENABLE_BROKEN_TESTS
if (APPLE OR CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
return ()
endif ()
check_binding_was_added ("swig_lua" BINDING_WAS_ADDED) # bindings are required for tests
if (BUILD_TESTING AND BINDING_WAS_ADDED)
# test environment clears env so setting LUA_CPATH is no option we workaround this by changing the current directory to our
# bindings output directory + per default lua loads modules from current directory
add_plugintest (lua MEMLEAK WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../bindings/swig/lua/ INSTALL_TEST_DATA)
else ()
message (WARNING "swig_lua bindings are required for testing, test deactivated")
endif ()
endif ()