-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
161 lines (137 loc) · 3.64 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENTIONS OFF)
# Define a "project", providing a description and a programming language
project(raytracer
VERSION 1.0
DESCRIPTION "Ray Tracing Project"
LANGUAGES CXX
)
# set PKG_CONFIG_PATH to include lib directory in my conda env
# in order to be found by pkg-config
set(ENV{PKG_CONFIG_PATH} "$ENV{CONDA_PREFIX}/lib/pkgconfig/:$ENV{PKG_CONFIG_PATH}")
# Add libgd library (copying from the links on Tomasi's slides)
# the `pkg_check_modules` function is created with this call
find_package(PkgConfig REQUIRED)
# these calls create special `PkgConfig::<MODULE>` variables
pkg_check_modules(PKG_GDLIB REQUIRED IMPORTED_TARGET gdlib>=2.2.5)
enable_testing()
# Our "project" will be able to build an executable out of a C++ source file
add_executable(raytracer
src/raytracer.cpp
)
# This program runs the automatic tests on the "Color" class
add_executable(colorTest
test/colors.cpp
)
add_executable(HdrImageTest
test/HdrImage.cpp
)
add_executable(geometryTest
test/geometry.cpp
)
add_executable(rayTest
test/ray.cpp
)
add_executable(cameraTest
test/camera.cpp
)
add_executable(imagetracerTest
test/imagetracer.cpp
)
add_executable(shapesTest
test/shapes.cpp
)
add_executable(materialsTest
test/materials.cpp
)
add_executable(renderTest
test/render.cpp
)
add_executable(pcgTest
test/pcg.cpp
)
add_executable(scene_fileTest
test/scene_file.cpp
)
add_executable(scatter_10000_rays
test/scatter_10000_rays.cpp
)
# Our project will be able to build a library
add_library(trace
src/colors.cpp
src/HdrImage.cpp
src/format.cc
src/geometry.cpp
src/shapes.cpp
src/imagetracer.cpp
src/world.cpp
src/materials.cpp
src/render.cpp
src/pcg.cpp
src/scene_file.cpp
)
# This is needed if we keep .h files in the "include" directory
target_include_directories(trace PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# This is needed for our trace library because it use libgd to
# convert Hdr Images to Ldr images.
# No need to specify include_dirs or compile options, cmake takes
# care of it all
target_link_libraries(trace PUBLIC PkgConfig::PKG_GDLIB)
# Target commands tells which dependencies targer exec have
target_link_libraries(
raytracer PUBLIC
trace
)
# The test program too needs to be linked to "trace"
target_link_libraries(colorTest PUBLIC trace)
target_link_libraries(HdrImageTest PUBLIC trace)
target_link_libraries(geometryTest PUBLIC trace)
target_link_libraries(rayTest PUBLIC trace)
target_link_libraries(cameraTest PUBLIC trace)
target_link_libraries(imagetracerTest PUBLIC trace)
target_link_libraries(shapesTest PUBLIC trace)
target_link_libraries(materialsTest PUBLIC trace)
target_link_libraries(renderTest PUBLIC trace)
target_link_libraries(pcgTest PUBLIC trace)
target_link_libraries(scene_fileTest PUBLIC trace)
target_link_libraries(scatter_10000_rays PUBLIC trace)
add_test(NAME colorTest
COMMAND colorTest
)
add_test(NAME HdrImageTest
COMMAND HdrImageTest
)
add_test(NAME geometryTest
COMMAND geometryTest
)
add_test(NAME rayTest
COMMAND rayTest
)
add_test(NAME cameraTest
COMMAND cameraTest
)
add_test(NAME imagetracerTest
COMMAND imagetracerTest
)
add_test(NAME shapesTest
COMMAND shapesTest
)
add_test(NAME materialsTest
COMMAND materialsTest
)
add_test(NAME renderTest
COMMAND renderTest
)
add_test(NAME pcgTest
COMMAND pcgTest
)
add_test(NAME scene_fileTest
COMMAND scene_fileTest
)
# Force the compiler to use the C++17 standard
target_compile_features(raytracer PUBLIC cxx_std_17)