-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
99 lines (78 loc) · 2.55 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#
# Diluculum build system
# Leandro Motta Barros
#
# General settings
project(Diluculum)
cmake_minimum_required(VERSION 2.6)
# Add CTest support
enable_testing()
# Packages
set(Boost_USE_STATIC_LIBS OFF)
find_package(Boost 1.39 COMPONENTS unit_test_framework REQUIRED)
find_package(Lua51 REQUIRED)
add_definitions(-DBOOST_ALL_DYN_LINK)
# Include directories
include_directories(${Boost_INCLUDE_DIRS}
${LUA_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}/include)
# Link directories
link_directories(${Boost_LIBRARY_DIRS})
# Enable warnings when compiling with G++
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic")
endif(CMAKE_COMPILER_IS_GNUCXX)
# Build the library
set(DiluculumSources
Sources/InternalUtils.cpp
Sources/LuaExceptions.cpp
Sources/LuaFunction.cpp
Sources/LuaState.cpp
Sources/LuaUserData.cpp
Sources/LuaUtils.cpp
Sources/LuaValue.cpp
Sources/LuaVariable.cpp
Sources/LuaWrappers.cpp)
add_library(Diluculum STATIC ${DiluculumSources})
target_link_libraries(Diluculum ${LUA_LIBRARIES})
if(${CMAKE_SYSTEM_NAME} MATCHES Linux)
target_link_libraries(Diluculum dl)
endif(${CMAKE_SYSTEM_NAME} MATCHES Linux)
# Now, the unit tests
function(AddUnitTest name)
add_executable(${name} Tests/${name}.cpp)
target_link_libraries(${name}
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
${LUA_LIBRARIES}
Diluculum)
if(${CMAKE_SYSTEM_NAME} MATCHES Linux)
target_link_libraries(Diluculum dl)
endif(${CMAKE_SYSTEM_NAME} MATCHES Linux)
add_test(${name} ${name})
endfunction(AddUnitTest)
add_library(ATestModule SHARED Tests/ATestModule.cpp)
target_link_libraries(ATestModule
${LUA_LIBRARIES}
Diluculum)
set_target_properties(ATestModule
PROPERTIES PREFIX "")
AddUnitTest(TestLuaFunction)
AddUnitTest(TestLuaState)
AddUnitTest(TestLuaUserData)
AddUnitTest(TestLuaUtils)
AddUnitTest(TestLuaValue)
AddUnitTest(TestLuaVariable)
AddUnitTest(TestLuaWrappers)
# Copy the files needed by the unit tests
configure_file(${CMAKE_SOURCE_DIR}/Tests/ReturnThread.lua
${CMAKE_BINARY_DIR}/ReturnThread.lua
COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/Tests/SyntaxError.lua
${CMAKE_BINARY_DIR}/SyntaxError.lua
COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/Tests/TestLuaStateDoFile.lua
${CMAKE_BINARY_DIR}/TestLuaStateDoFile.lua
COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/Tests/TestLuaStateDoFileNoReturn.lua
${CMAKE_BINARY_DIR}/TestLuaStateDoFileNoReturn.lua
COPYONLY)