-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
117 lines (99 loc) · 3.61 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
108
109
110
111
112
113
114
115
116
117
cmake_minimum_required(VERSION 3.5)
project(VTRAY CXX)
# require a C++11 compiler
# use it for all targets
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# configure Qt
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Qt5 COMPONENTS Gui REQUIRED)
# EDIT: add your (non-test) source files to this list
set(src
color.hpp color.cpp
vec3.hpp vec3.cpp
ray.hpp ray.cpp
object.hpp object.cpp
sphere.hpp sphere.cpp
plane.hpp plane.cpp
light.hpp light.cpp
camera.hpp camera.cpp
scene.hpp scene.cpp
ray_tracer.hpp ray_tracer.cpp
message_queue.h
)
# EDIT: add any additional test source files to this list
set(test_src
catch.hpp
unittests.cpp
test_color.cpp
test_vec3.cpp
test_ray.cpp
test_sphere.cpp
test_plane.cpp
test_light.cpp
test_camera.cpp
test_scene.cpp
test_ray_tracer.cpp
)
# You should not need to edit below this line
#-----------------------------------------------------------------------
#-----------------------------------------------------------------------
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
# create unittests
add_executable(unittests catch.hpp ${test_src} ${src})
if(UNIX AND CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(unittests Qt5::Gui pthread)
else(UNIX AND CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(unittests Qt5::Gui)
endif()
# create the vtray executable
add_executable(vtray vtray.cpp ${src})
if(UNIX AND CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(vtray Qt5::Gui pthread)
else(UNIX AND CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(vtray Qt5::Gui)
endif()
enable_testing()
# unit tests
add_test(unit unittests)
# integration tests
add_test(test0 vtray ${CMAKE_SOURCE_DIR}/tests/scene0.json output0.png)
add_test(test1 vtray ${CMAKE_SOURCE_DIR}/tests/scene1.json output1.png)
add_test(test2 vtray ${CMAKE_SOURCE_DIR}/tests/scene2.json output2.png)
add_test(test3 vtray ${CMAKE_SOURCE_DIR}/tests/scene3.json output3.png)
add_test(test4 vtray ${CMAKE_SOURCE_DIR}/tests/scene4.json output4.png)
set_tests_properties(test3 PROPERTIES WILL_FAIL ON)
set_tests_properties(test4 PROPERTIES WILL_FAIL ON)
# look for perceptualdiff
find_program(PDIFF perceptualdiff)
if(PDIFF)
add_test(test0diff perceptualdiff --sum-errors --output output0diff.png
${CMAKE_SOURCE_DIR}/tests/scene0.png output0.png )
add_test(test1diff perceptualdiff --threshold 200000 --sum-errors --output output1diff.png
${CMAKE_SOURCE_DIR}/tests/scene1.png output1.png )
add_test(test2diff perceptualdiff --threshold 400000 --sum-errors --output output2diff.png
${CMAKE_SOURCE_DIR}/tests/scene2.png output2.png)
endif()
# On Linux, using GCC, to enable coverage on tests -DCOVERAGE=TRUE
if(UNIX AND NOT APPLE AND CMAKE_COMPILER_IS_GNUCXX AND COVERAGE)
message("Enabling Test Coverage")
SET(GCC_COVERAGE_COMPILE_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
set_target_properties(unittests PROPERTIES COMPILE_FLAGS ${GCC_COVERAGE_COMPILE_FLAGS} )
target_link_libraries(unittests gcov)
add_custom_target(coverage
COMMAND ${CMAKE_COMMAND} -E env "ROOT=${CMAKE_CURRENT_SOURCE_DIR}"
${CMAKE_CURRENT_SOURCE_DIR}/scripts/coverage.sh)
endif()
# On Linux, using GCC, to enable coverage on tests -DMEMORY=TRUE
if(UNIX AND NOT APPLE AND CMAKE_COMPILER_IS_GNUCXX AND MEMORY)
add_custom_target(memtest
COMMAND valgrind ${CMAKE_BINARY_DIR}/unittests)
endif()
# enable clang-tidy with -DTIDY=TRUE
if(UNIX AND NOT APPLE AND CMAKE_COMPILER_IS_GNUCXX AND TIDY)
add_custom_target(tidy
COMMAND ${CMAKE_COMMAND} -E env "source=${CMAKE_CURRENT_SOURCE_DIR}" env "build=${CMAKE_CURRENT_BINARY_DIR}"
${CMAKE_CURRENT_SOURCE_DIR}/scripts/tidy.sh
)
endif()