-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
102 lines (80 loc) · 2.81 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
cmake_minimum_required(VERSION 3.10)
project(rays LANGUAGES CUDA CXX C)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# set(CMAKE_CXX_FLAGS_DEBUG "-g")
# set(CMAKE_CUDA_FLAGS_DEBUG "-g -G")
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# Skip LTO to avoid issue with nvcc passthrough
set(PYBIND11_LTO_CXX_FLAGS "")
find_package(Boost 1.56 REQUIRED COMPONENTS filesystem)
find_package(OptiX REQUIRED)
add_library(ptx_files OBJECT optix/optix_kernel.cu)
target_include_directories(ptx_files PUBLIC include)
target_include_directories(ptx_files PUBLIC "${OptiX_INCLUDE}")
target_include_directories(ptx_files PUBLIC "${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}")
set_property(TARGET ptx_files PROPERTY CUDA_PTX_COMPILATION ON)
set_property(TARGET ptx_files PROPERTY POSITION_INDEPENDENT_CODE ON)
add_custom_target(
ptx_headers
COMMAND ${CMAKE_COMMAND}
"-DCPP_FILE=${CMAKE_CURRENT_SOURCE_DIR}/optix/optix_kernel.h"
"-DPTX_FILE=$<TARGET_OBJECTS:ptx_files>"
"-DVARIABLE_NAME=ptxSource"
"-DCUDA_BIN2C_EXECUTABLE=bin2c"
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/ptx2cpp.cmake"
DEPENDS ptx_files
COMMENT "Convert ptx files to header file"
)
add_library(rays STATIC
src/cuda_globals.cu
src/framebuffer.cu
src/hit_test.cu
src/world.cu
src/render_session.cu
src/scene.cu
src/scene_data.cu
src/scene_model.cu
src/spp_optimizer.cpp
src/transform.cu
src/core/camera.cu
src/io/image.cpp
src/lights/environment_light.cu
src/materials/lambertian.cu
src/materials/material_lookup.cu
src/materials/mirror.cu
src/math/distribution.cu
src/parsers/mtl_parser.cpp
src/parsers/obj_parser.cpp
src/parsers/ply_parser.cpp
src/parsers/string_util.cpp
src/primitives/sphere.cu
src/primitives/triangle.cu
src/renderers/g_buffer.cu
src/renderers/optix.cpp
src/renderers/optix_tracer.cu
src/renderers/path_tracer.cu
src/renderers/renderer.cpp
)
target_include_directories(rays PUBLIC include optix vendor)
target_include_directories(rays PUBLIC "${OptiX_INCLUDE}")
target_include_directories(rays PUBLIC "${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}")
target_link_libraries(rays Boost::filesystem)
set_property(TARGET rays PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET rays PROPERTY CUDA_SEPARABLE_COMPILATION ON)
# target_compile_options(rays PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-D__CUDACC__>)
add_dependencies(rays ptx_headers)
add_subdirectory(pybind11)
pybind11_add_module(path_tracer bindings/path_tracer_bindings.cu)
target_link_libraries(path_tracer rays)
find_package(Qt5 COMPONENTS Widgets REQUIRED)
# Test application for profiling
add_executable(app
app/main.cpp
app/gl_widget.cpp
)
target_include_directories(app PRIVATE app)
target_link_libraries(app rays Qt5::Core Qt5::Widgets)
# Catch2 tests
add_subdirectory(test)