-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathCMakeLists.txt
75 lines (61 loc) · 2.4 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
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(http C)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
find_package(LuaTest)
find_package(LuaCheck)
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")
# Find Tarantool and Lua dependecies
set(Tarantool_FIND_REQUIRED ON)
find_package(Tarantool)
include_directories(${TARANTOOL_INCLUDE_DIRS})
# Set CFLAGS
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra")
string(RANDOM ALPHABET 0123456789 seed)
add_subdirectory(http)
add_subdirectory(roles)
add_custom_target(luacheck
COMMAND ${LUACHECK} ${PROJECT_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Run luacheck"
)
add_custom_target(luatest-coverage
COMMAND ${LUATEST} -v --coverage --shuffle all:${seed}
BYPRODUCTS ${CODE_COVERAGE_STATS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Run regression tests with coverage"
)
add_custom_target(luatest
COMMAND ${LUATEST} -v --shuffle all:${seed}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Run regression tests without coverage"
)
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} --include ^http --verbose --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"
)
set (LUA_PATH "LUA_PATH=${PROJECT_SOURCE_DIR}/?.lua\\;${PROJECT_SOURCE_DIR}/?/init.lua\\;\\;")
set (LUA_SOURCE_DIR "LUA_SOURCE_DIR=${PROJECT_SOURCE_DIR}")
set_target_properties(luatest-coverage PROPERTIES ENVIRONMENT "${LUA_PATH};${LUA_SOURCE_DIR}")