-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
155 lines (132 loc) · 5.02 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
cmake_minimum_required(VERSION 3.15)
project(pt-playground)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_subdirectory(external)
if(MSVC)
# /wd4201 silences warning about nameless structs and unions used by GLM.
add_compile_options(/W4 /WX /wd4201)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
else()
# -Wno-deprecated silences warnings about deprecated use of volatile qualifier by GLM.
add_compile_options(-W -Wall -Wextra -pedantic -Werror -Wno-deprecated)
endif()
# common
set(COMMON_SOURCE_FILES
buffer_stream.cpp
bvh.cpp
camera.cpp
cgltf.c
flattened_model.cpp
file_stream.cpp
gltf_model.cpp
ray_intersection.cpp
stb_image.c
stb_image_write.c
texture.cpp)
list(TRANSFORM COMMON_SOURCE_FILES PREPEND src/common/)
add_library(common ${COMMON_SOURCE_FILES})
target_include_directories(common PUBLIC ${CMAKE_SOURCE_DIR}/src ${CGLTF_INCLUDE_DIR} ${STB_INCLUDE_DIR})
target_link_libraries(common PRIVATE glm::glm fmt)
# glf3webgpu
add_library(glfw3webgpu src/glfw3webgpu/glfw3webgpu.c)
target_include_directories(glfw3webgpu PUBLIC ${CMAKE_SOURCE_DIR}/src/glfw3webgpu)
target_link_libraries(glfw3webgpu PRIVATE glfw webgpu_dawn)
if(APPLE)
target_compile_options(glfw3webgpu PRIVATE -x objective-c)
target_link_libraries(glfw3webgpu PRIVATE "-framework Cocoa" "-framework CoreVideo" "-framework IOKit" "-framework QuartzCore")
endif()
# hosekwilkie-skylightmodel-source
add_library(hosekwilkie-skylightmodel src/hosekwilkie-skylightmodel-source-1.4a/ArHosekSkyModel.c)
target_include_directories(hosekwilkie-skylightmodel PUBLIC ${CMAKE_SOURCE_DIR}/src)
# hw-skymodel
add_library(hw-skymodel src/hw-skymodel/hw_skymodel.c)
target_include_directories(hw-skymodel PUBLIC ${CMAKE_SOURCE_DIR}/src)
# hw-skymodel-demo
add_executable(hw-skymodel-demo src/hw-skymodel-demo/main.cpp)
target_link_libraries(hw-skymodel-demo PRIVATE common hw-skymodel glm::glm)
# hw-sunmodel-integrator
add_executable(hw-sunmodel-integrator src/hw-sunmodel-integrator/main.cpp)
target_link_libraries(hw-sunmodel-integrator PRIVATE common hosekwilkie-skylightmodel fmt glm::glm)
# pt-format
add_library(pt-format src/pt-format/pt_format.cpp)
target_include_directories(pt-format PUBLIC ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(pt-format PRIVATE common fmt glm::glm)
# pt-format-tool
add_executable(pt-format-tool src/pt-format-tool/main.cpp)
target_link_libraries(pt-format-tool PRIVATE common fmt pt-format glm::glm)
# bake-wgsl
set(WGSL_SHADER_FILES
reference_path_tracer.wgsl
deferred_renderer_gbuffer_pass.wgsl
deferred_renderer_debug_pass.wgsl
deferred_renderer_lighting_pass.wgsl
deferred_renderer_resolve_pass.wgsl)
set(SHADER_SOURCE_HEADER_FILE src/pt/shader_source.hpp)
include(cmake/BakeWgslSource.cmake)
add_custom_command(
OUTPUT ${SHADER_SOURCE_HEADER_FILE}
COMMAND ${CMAKE_COMMAND} -DCALL_BAKE_WGSL_SOURCE=1 -DOUTPUT_FILE=${SHADER_SOURCE_HEADER_FILE} -DWGSL_FILES="${WGSL_SHADER_FILES}" -P ${CMAKE_SOURCE_DIR}/cmake/BakeWgslSource.cmake
COMMENT "Generating ${SHADER_SOURCE_HEADER_FILE} from .wgsl files"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
add_custom_target(bake-wgsl DEPENDS ${SHADER_SOURCE_HEADER_FILE})
# pt
set(PT_SOURCE_FILES
blue_noise.c
fly_camera_controller.cpp
main.cpp
gpu_bind_group.cpp
gpu_bind_group_layout.cpp
gpu_buffer.cpp
gpu_context.cpp
gui.cpp
deferred_renderer.cpp
reference_path_tracer.cpp
window.cpp)
list(TRANSFORM PT_SOURCE_FILES PREPEND src/pt/)
add_executable(pt ${PT_SOURCE_FILES})
add_dependencies(pt bake-wgsl)
target_link_libraries(pt PRIVATE common fmt glfw glfw3webgpu glm::glm hw-skymodel imgui pt-format webgpu_dawn)
set_target_properties(pt PROPERTIES COMPILE_WARNING_AS_ERROR ON)
# bvh-visualizer
add_executable(bvh-visualizer src/bvh-visualizer/main.cpp)
target_link_libraries(bvh-visualizer PRIVATE common glm::glm)
add_custom_command(
TARGET bvh-visualizer POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/assets/Duck.glb
$<TARGET_FILE_DIR:bvh-visualizer>/Duck.glb
COMMENT "Copying $<TARGET_FILE_DIR:bvh-visualizer>/Duck.glb"
)
# tests
set(TESTS_SOURCE_FILES
aabb.cpp
angle.cpp
bit_flags.cpp
bvh.cpp
gltf.cpp
intersection.cpp
math.cpp
pt_format.cpp
stream.cpp
vector_set.cpp)
list(TRANSFORM TESTS_SOURCE_FILES PREPEND src/tests/)
add_executable(tests ${TESTS_SOURCE_FILES})
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain common fmt pt-format glm::glm)
add_custom_command(
TARGET tests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/assets/Duck.glb
$<TARGET_FILE_DIR:tests>/Duck.glb
COMMENT "Copying $<TARGET_FILE_DIR:tests>/Duck.glb"
)
add_executable(textractor src/textractor/main.cpp)
target_link_libraries(textractor PRIVATE common fmt glm::glm)
add_custom_command(
TARGET textractor POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/assets/Duck.glb
$<TARGET_FILE_DIR:textractor>/Duck.glb
COMMENT "Copying $<TARGET_FILE_DIR:textractor>/Duck.glb"
)