-
Notifications
You must be signed in to change notification settings - Fork 14
/
CMakeLists.txt
107 lines (85 loc) · 3.24 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
100
101
102
103
104
105
106
107
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(crud NONE)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)
file(GLOB_RECURSE LUA_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/crud.lua"
"${CMAKE_CURRENT_SOURCE_DIR}/crud/*.lua"
"${CMAKE_CURRENT_SOURCE_DIR}/cartridge/roles/*.lua"
)
## Testing ####################################################################
###############################################################################
enable_testing()
find_package(LuaCheck)
add_custom_target(luacheck
COMMAND ${LUACHECK} ${PROJECT_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
find_package(LuaTest)
find_package(LuaCov)
find_package(LuaCovCoveralls)
set(CODE_COVERAGE_REPORT "${PROJECT_SOURCE_DIR}/luacov.report.out")
set(CODE_COVERAGE_STATS "${PROJECT_SOURCE_DIR}/luacov.stats.out")
add_custom_target(luatest
COMMAND ${LUATEST} -v --coverage
BYPRODUCTS ${CODE_COVERAGE_STATS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Run regression tests"
)
add_custom_target(luatest-no-coverage
COMMAND ${LUATEST} -v
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Run regression tests without coverage"
)
set(PERFORMANCE_TESTS_SUBDIR "test/performance")
add_custom_target(performance
COMMAND PERF_MODE_ON=true ${LUATEST} -v -c ${PERFORMANCE_TESTS_SUBDIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Run performance tests"
)
add_custom_target(coverage
COMMAND ${LUACOV} ${PROJECT_SOURCE_DIR} && grep -A999 '^Summary' ${CODE_COVERAGE_REPORT}
DEPENDS ${CODE_COVERAGE_STATS}
BYPRODUCTS ${CODE_COVERAGE_REPORT}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Generate code coverage stats"
)
if(DEFINED ENV{GITHUB_TOKEN})
set(COVERALLS_COMMAND ${LUACOVCOVERALLS} -v -r ${PROJECT_SOURCE_DIR} --repo-token $ENV{GITHUB_TOKEN})
else()
set(COVERALLS_COMMAND ${CMAKE_COMMAND} -E echo "Skipped uploading to coveralls.io: no token.")
endif()
add_custom_target(coveralls
# Replace absolute paths with relative ones.
# In command line: sed -i -e 's@'"$(realpath .)"'/@@'.
COMMAND sed -i -e "\"s@\"'${PROJECT_SOURCE_DIR}'\"/@@\"" ${CODE_COVERAGE_STATS}
COMMAND ${COVERALLS_COMMAND}
DEPENDS ${CODE_COVERAGE_STATS}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Send code coverage data to the coveralls.io service"
)
## Install ####################################################################
###############################################################################
if(NOT DEFINED TARANTOOL_INSTALL_LUADIR)
set(TARANTOOL_INSTALL_LUADIR "${PROJECT_SOURCE_DIR}/.rocks/share/tarantool")
endif()
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}
DESTINATION ${TARANTOOL_INSTALL_LUADIR}
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/crud.lua
DESTINATION ${TARANTOOL_INSTALL_LUADIR}
)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cartridge
DESTINATION ${TARANTOOL_INSTALL_LUADIR}
)
# Don't include to rockspec as some Tarantool versions (e.g. 2.2 and 2.3)
# don't have symbols required by "tuple-merger" and "tuple-keydef" modules.
execute_process(
COMMAND bash "-c" "tarantoolctl rocks install tuple-keydef 0.0.2"
)
execute_process(
COMMAND bash "-c" "tarantoolctl rocks install tuple-merger 0.0.2"
)