-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
362 lines (308 loc) · 10.2 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# This is the main CMake build file used to compile Nori
cmake_minimum_required(VERSION 3.12)
project(nori)
if(WIN32)
include(CmakeDependentOption)
endif()
option(NORI_USE_GUI "Build the GUI" ON)
option(NORI_USE_IMGUI "Use ImGui instead of NanoGui, warptest always uses NanoGUI" ON)
option(NORI_USE_VDB "Enable Volumes" ON)
option(NORI_BUILD_DOCS "Build Nori Docs" OFF)
option(NORI_USE_OPTIX "Enable OptiX, requires CUDA" ON)
if(WIN32)
cmake_dependent_option(NORI_OPTIX_RELEASE "Enable OptiX release mode" ON "CMAKE_BUILD_TYPE STREQUAL Release" OFF)
endif()
# This file included below takes care of compiling dependencies
# and setting compiler flags on different platforms
include("CMakeConfig.txt")
include_directories(ext)
if(NORI_BUILD_DOCS)
add_subdirectory(docs)
endif(NORI_BUILD_DOCS)
# The following lines build the main executable. If you add a source
# code file to Nori, be sure to include it in this list.
add_executable(nori
# Header files
include/nori/bbox.h
include/nori/bitmap.h
include/nori/block.h
include/nori/bsdf.h
include/nori/bvh.h
include/nori/camera.h
include/nori/perspective.h
include/nori/color.h
include/nori/common.h
include/nori/dpdf.h
include/nori/frame.h
include/nori/integrator.h
include/nori/emitter.h
include/nori/kdtree.h
include/nori/mesh.h
include/nori/sphere.h
include/nori/object.h
include/nori/parser.h
include/nori/proplist.h
include/nori/photon.h
include/nori/ray.h
include/nori/render.h
include/nori/rfilter.h
include/nori/sampler.h
include/nori/scene.h
include/nori/shape.h
include/nori/texture.h
include/nori/timer.h
include/nori/transform.h
include/nori/vector.h
include/nori/warp.h
include/nori/HDRLoader.h
include/nori/denoiser.h
include/nori/medium.h
include/nori/phase.h
include/nori/environmentmap.h
# Source code files
src/utils/bitmap.cpp
src/utils/block.cpp
src/utils/bvh.cpp
src/utils/chi2test.cpp
src/utils/common.cpp
src/utils/main.cpp
src/utils/object.cpp
src/utils/parser.cpp
src/utils/proplist.cpp
src/utils/render.cpp
src/utils/ttest.cpp
src/utils/scene.cpp
src/utils/warp.cpp
src/utils/photon.cpp
src/utils/transform.cpp
src/textures/consttexture.cpp
src/textures/checkerboard.cpp
src/textures/PNGTexture.cpp
src/bsdf/diffuse.cpp
src/bsdf/microfacet.cpp
src/bsdf/mirror.cpp
src/bsdf/dielectric.cpp
src/bsdf/disney.cpp
src/bsdf/isophase.cpp
src/bsdf/anisophase.cpp
src/bsdf/schlickphase.cpp
src/integrators/photonmapper.cpp
src/integrators/direct.cpp
src/integrators/direct_ems.cpp
src/integrators/direct_mats.cpp
src/integrators/direct_mis.cpp
src/integrators/path_mats.cpp
src/integrators/path_mis.cpp
src/integrators/normals.cpp
src/integrators/av.cpp
src/integrators/PreviewIntegrator.cpp
src/integrators/path_vol_mats.cpp
src/integrators/path_vol_mis.cpp
src/integrators/EnvMapTester.cpp
src/shapes/mesh.cpp
src/shapes/obj.cpp
src/shapes/shape.cpp
src/shapes/sphere.cpp
src/cameras/camera.cpp
src/cameras/perspective.cpp
src/cameras/rfilter.cpp
src/emitters/spotlight.cpp
src/emitters/emitter.cpp
src/emitters/arealight.cpp
src/emitters/pointlight.cpp
src/emitters/environmentmap.cpp
src/emitters/volumelight.cpp
src/emitters/directionalLight.cpp
src/denoiser/simple.cpp
src/samplers/adaptive.cpp
src/samplers/independent.cpp
src/media/medium.cpp
src/media/vacuum.cpp
src/media/homogmedium.cpp
src/media/heterogmedium.cpp
)
if(NORI_USE_VDB)
target_sources(nori PRIVATE
include/nori/NvdbVolume.h
src/textures/NvdbVolume.vdb.cpp
src/textures/NvdbVolume.cpp
)
endif()
add_executable(tonemapper
include/nori/bitmap.h
src/utils/bitmap.cpp
src/utils/common.cpp
src/utils/hdrToLdr.cpp)
if(NORI_USE_GUI)
# Append additional gui sources
if(NORI_USE_IMGUI)
target_sources(nori PRIVATE
include/nori/ImguiScreen.h
src/utils/ImguiScreen.cpp
include/nori/ImguiHelpers.h
src/utils/ImGuiHelpers.cpp
include/nori/glutil.h
src/utils/glutil.cpp
)
else(NORI_USE_IMGUI)
target_sources(nori PRIVATE
include/nori/gui.h
src/utils/gui.cpp
)
endif(NORI_USE_IMGUI)
# The following lines build the warping test application
add_executable(warptest
include/nori/warp.h
src/utils/warp.cpp
src/utils/warptest.cpp
src/bsdf/microfacet.cpp
src/bsdf/isophase.cpp
src/bsdf/anisophase.cpp
src/bsdf/schlickphase.cpp
src/utils/object.cpp
src/utils/proplist.cpp
src/utils/common.cpp
)
add_dependencies(warptest nori)
target_link_libraries(warptest nanogui glew ${extra_libs})
target_compile_definitions(warptest PRIVATE -DNORI_USE_NANOGUI)
endif(NORI_USE_GUI)
if(NORI_USE_OPTIX)
# Based on NanoVDB OptiX viewer
cmake_policy(SET CMP0074 NEW) # find_package: Search in <PackageName>_ROOT variable
set(OptiX_ROOT ${CMAKE_SOURCE_DIR}/ext/optix)
find_package(CUDA)
find_package(OptiX)
if(CUDA_FOUND AND OptiX_FOUND)
set(CMAKE_CUDA_STANDARD 14)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
set(NANOVDB_CUDA_EXTENDED_LAMBDA "--expt-extended-lambda")
if(CUDA_VERSION_MAJOR GREATER_EQUAL 11)
set(NANOVDB_CUDA_EXTENDED_LAMBDA "--extended-lambda")
endif()
set(CMAKE_CUDA_FLAGS
"${NANOVDB_CUDA_EXTENDED_LAMBDA} -use_fast_math -lineinfo")
# find NVRTC library.
find_library(
CUDA_nvrtc_LIBRARY nvrtc "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64"
"${CUDA_TOOLKIT_ROOT_DIR}/lib64" "${CUDA_TOOLKIT_ROOT_DIR}/lib/Win32")
# workaround for win32 bug when nvcc "--keep" is used.
if(WIN32)
if(NANOVDB_CUDA_KEEP_PTX)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x64/Release")
set(CMAKE_CUDA_FLAGS_RELEASE
" --source-in-ptx --keep ${CMAKE_CUDA_FLAGS_RELEASE}")
endif()
endif()
enable_language(CUDA)
target_include_directories(nori PRIVATE
${CUDA_INCLUDE_DIRS}
${OptiX_INCLUDE_DIR}
)
target_compile_definitions(nori PRIVATE
"-DNORI_USE_OPTIX"
"-DNORI_NVRTC_OPTIX_DIR=\"${OptiX_INCLUDE_DIR}\""
"-DNORI_NVRTC_CUDA_DIR=\"${CUDA_INCLUDE_DIRS}\""
"-DNORI_NVRTC_NANOVDB_DIR=\"${CMAKE_SOURCE_DIR}/ext/nanovdb\"")
if(NORI_OPTIX_RELEASE)
target_compile_definitions(nori PRIVATE "-DNORI_OPTIX_RELEASE")
endif()
target_link_libraries(nori
${CUDA_LIBRARIES}
${CUDA_nvrtc_LIBRARY}
# OptiX is header only
)
set(NORI_CU_FILES
include/nori/optix/cuda/raygen.cpp
include/nori/optix/cuda/shading.cpp
include/nori/optix/cuda/geometry.sphere.cpp
include/nori/optix/cuda/geometry.nvdb.cpp
include/nori/optix/cuda/RadiancePrd.h
include/nori/optix/cuda/ShadowrayPrd.h
include/nori/optix/cuda/shaders/bsdf.h
include/nori/optix/cuda/shaders/emitter.h
include/nori/optix/cuda/shaders/camera.h
include/nori/optix/cuda_shared/LaunchParams.h
include/nori/optix/cuda_shared/RayParams.h
include/nori/optix/cuda_shared/GeometryData.h
include/nori/optix/cuda_shared/BsdfData.h
include/nori/optix/cuda_shared/MediumData.h
include/nori/optix/cuda_shared/EmitterData.h
include/nori/optix/cuda_shared/RaygenData.h
include/nori/optix/cuda_shared/IntegratorData.h
include/nori/optix/cuda/sutil/exception.h
include/nori/optix/cuda/sutil/helpers.h
include/nori/optix/cuda/sutil/vec_math.h
include/nori/optix/cuda/sutil/random.h
include/nori/optix/cuda/sutil/warp.h
include/nori/optix/cuda/sutil/shader_helpers.h
include/nori/optix/cuda/sutil/LocalGeometry.h
include/nori/optix/cuda/sutil/stddef.h
include/nori/optix/cuda/sutil/stdint.h
include/nori/optix/cuda/sutil/limits.h
)
target_sources(nori PRIVATE
include/nori/optix/OptixRenderer.h
include/nori/optix/OptixRenderer.cpp
include/nori/optix/OptixState.h
include/nori/optix/OptixState.cpp
include/nori/optix/OptixState.rtc.cpp
include/nori/optix/OptixState.as.cpp
include/nori/optix/OptixState.render.cpp
include/nori/optix/OptixState.denoiser.cpp
include/nori/optix/OptixSbtTypes.h
include/nori/optix/sutil/Exception.h
include/nori/optix/sutil/CUDAOutputBuffer.h
include/nori/optix/sutil/host_vec_math.h
${NORI_CU_FILES}
)
# Don't compile cu files, nvrtc will be used
set_source_files_properties(${NORI_CU_FILES} PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties(${NORI_CU_FILES} PROPERTIES LANGUAGE CUDA)
message(STATUS "Nori uses OptiX")
endif()
endif()
# -- Add C++ defines
# The following C++ macros may be defined:
# DISABLE_NORI_GUI
# NORI_USE_IMGUI
# NORI_USE_NANOGUI
# NORI_USE_VDB
if(NOT NORI_USE_GUI)
message(STATUS "NORI_USE_GUI is off")
# Disable flag for preprocessor
target_compile_definitions(nori PRIVATE -DDISABLE_NORI_GUI)
else()
if(NORI_USE_IMGUI)
target_compile_definitions(nori PRIVATE -DNORI_USE_IMGUI)
message(STATUS "Nori uses ImGui")
else()
target_compile_definitions(nori PRIVATE -DNORI_USE_NANOGUI)
message(STATUS "Nori uses Nanogui")
endif()
endif()
if(NORI_USE_VDB)
message(STATUS "Nori uses Volumes")
target_compile_definitions(nori PUBLIC -DNORI_USE_VDB)
else()
message(STATUS "Nori doesn't use Volumes")
endif()
# Nori depends on some libraries created in CMakeConfig.txt. The following two
# lines ensure that Nori is built *after* those libraries have been created.
#add_dependencies(nori OpenEXR_p)
#add_dependencies(nori tbb_p)
add_dependencies(nori pugixml)
add_dependencies(nori lodepng)
#add_dependencies(nori openvdb_p)
add_dependencies(tonemapper nori)
# Link to dependency libraries
target_link_libraries(tonemapper ${extra_libs})
target_link_libraries(nori ${extra_libs})
set_target_properties(nori PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED TRUE
CUDA_STANDARD 14
CUDA_STANDARD_REQUIRED TRUE
CXX_EXTENSIONS NO
)
# vim: set et ts=2 sw=2 ft=cmake nospell: