blob: b59daa5b7cb15a037df5668885ac5ad8d4425388 (
plain) (
blame)
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
108
109
110
111
|
cmake_minimum_required (VERSION 2.8.8)
project (usdx-cpp)
set(cflags "-Wall -Werror -pedantic")
set(cxxflags "${cflags} -std=c++1y")
set(debug "-g -O0")
set(coverage "-coverage")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${cflags}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${debug}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cxxflags}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${debug}")
#
# dependency handling
#
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
set(Boost_USE_MULTITHREADED "ON")
include("Require")
require(FTGL)
require(Freetype)
require(SDL)
require(SDL_image)
require(SDL_gfx)
require(log4cpp)
require(Boost COMPONENTS filesystem locale program_options system thread)
require(OpenGL)
#
# get main sources
#
include_directories(src/)
file(GLOB_RECURSE sources src/*.cpp)
list(REMOVE_ITEM sources "${CMAKE_SOURCE_DIR}/src/main.cpp")
add_library(objects OBJECT ${sources})
#
# main usdx binary
#
add_executable(usdx "src/main.cpp" $<TARGET_OBJECTS:objects>)
target_link_libraries(usdx ${LIBS})
#
# make run
#
add_custom_target(run
COMMAND usdx
DEPENDS usdx
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
#
# tests
#
include(CTest)
if(BUILD_TESTING)
require_test(CppUnit)
file(GLOB_RECURSE testing_sources test/*.cpp)
add_executable(usdx-test ${testing_sources} $<TARGET_OBJECTS:objects>)
target_link_libraries(usdx-test ${LIBS} ${TEST_LIBS})
add_test(NAME test
COMMAND usdx-test
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/test/"
)
endif()
#
# usdx binary with coverage information
#
add_library(objects-coverage EXCLUDE_FROM_ALL
OBJECT ${sources})
set_target_properties(objects-coverage
PROPERTIES COMPILE_FLAGS "${debug} -fprofile-arcs -ftest-coverage")
add_executable(usdx-coverage EXCLUDE_FROM_ALL
"src/main.cpp" $<TARGET_OBJECTS:objects-coverage>)
target_link_libraries(usdx-coverage ${LIBS} ${coverage})
#
# tests with coverage
#
if(BUILD_TESTING)
add_executable(usdx-test-coverage EXCLUDE_FROM_ALL
${testing_sources} $<TARGET_OBJECTS:objects-coverage>)
target_link_libraries(usdx-test-coverage ${LIBS} ${TEST_LIBS} ${coverage})
set(coverage-dir "${PROJECT_BINARY_DIR}/coverage")
add_custom_target(test-coverage WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/test/"
# prepare coverage checks
COMMAND rm -f .error
COMMAND mkdir -p "${coverage-dir}"
COMMAND lcov --directory "${PROJECT_SOURCE_DIR}" --zerocounters
# running checks and save result for later use
COMMAND sh -c \"$<TARGET_FILE:usdx-test-coverage> || touch .error\"
# building coverage pages
COMMAND lcov --directory "${PROJECT_SOURCE_DIR}" --capture --output-file "${coverage-dir}/coverage.info.tmp"
COMMAND lcov --extract "${coverage-dir}/coverage.info.tmp" "'${PROJECT_SOURCE_DIR}/src/*'" -o "${coverage-dir}/coverage.info"
COMMAND genhtml "${coverage-dir}/coverage.info" -o "${coverage-dir}/html/" -p "${PROJECT_SOURCE_DIR}/src"
# returing check status
COMMAND test ! -e .error
)
add_dependencies(test-coverage usdx-test-coverage)
endif()
|