-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
85 lines (74 loc) · 2.93 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
cmake_minimum_required(VERSION 3.20)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
project(RushExamples)
# Multithreaded compilation in MSVC
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
# Dependencies
add_subdirectory("External")
# Custom build rules
find_program(GLSLC NAMES glslc PATHS
$ENV{VULKAN_SDK}/Bin
$ENV{VK_SDK_PATH}/Bin
$ENV{PATH}
"~/bin"
)
find_program(glslangValidator NAMES glslangValidator PATHS
$ENV{VULKAN_SDK}/Bin
$ENV{VK_SDK_PATH}/Bin
$ENV{PATH}
"~/bin"
)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
find_program(spirv-cross NAMES spirv-cross PATHS
$ENV{VK_SDK_PATH}/Bin
$ENV{PATH}
"~/bin"
)
function(hlsl_shader_compile_rule shaderName stage)
add_custom_command(
OUTPUT ${CMAKE_CFG_INTDIR}/${shaderName}.metal
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CFG_INTDIR}
COMMAND ${GLSLC} -O -x hlsl -fentry-point=main -fshader-stage=${stage} -o ${CMAKE_CFG_INTDIR}/${shaderName}.bin ${CMAKE_CURRENT_SOURCE_DIR}/${shaderName}
COMMAND ${spirv-cross} --msl --msl-version 200000 --msl-argument-buffers ${extra_args} ${CMAKE_CFG_INTDIR}/${shaderName}.bin > ${CMAKE_CFG_INTDIR}/${shaderName}.metal
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${shaderName}
)
endfunction(hlsl_shader_compile_rule)
function(glsl_shader_compile_rule shaderName)
add_custom_command(
OUTPUT ${CMAKE_CFG_INTDIR}/${shaderName}.metal
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CFG_INTDIR}
COMMAND ${GLSLC} -O -o ${CMAKE_CFG_INTDIR}/${shaderName}.bin ${CMAKE_CURRENT_SOURCE_DIR}/${shaderName}
COMMAND ${spirv-cross} --msl --msl-version 200000 --msl-argument-buffers ${spirv-cross-args} ${CMAKE_CFG_INTDIR}/${shaderName}.bin > ${CMAKE_CFG_INTDIR}/${shaderName}.metal
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${shaderName}
)
endfunction(glsl_shader_compile_rule)
else()
function(hlsl_shader_compile_rule shaderName stage)
add_custom_command(
OUTPUT ${CMAKE_CFG_INTDIR}/${shaderName}.bin
COMMAND ${GLSLC} -O -x hlsl -fentry-point=main -fshader-stage=${stage} -o ${CMAKE_CFG_INTDIR}/${shaderName}.bin ${CMAKE_CURRENT_SOURCE_DIR}/${shaderName}
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${shaderName}
)
endfunction(hlsl_shader_compile_rule)
function(glsl_shader_compile_rule shaderName)
add_custom_command(
OUTPUT ${CMAKE_CFG_INTDIR}/${shaderName}.bin
COMMAND ${GLSLC} -O -o ${CMAKE_CFG_INTDIR}/${shaderName}.bin ${CMAKE_CURRENT_SOURCE_DIR}/${shaderName}
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${shaderName}
)
endfunction(glsl_shader_compile_rule)
endif()
# Example apps
add_subdirectory("Common")
add_subdirectory("01-HelloWorld")
add_subdirectory("02-WindowEvents")
add_subdirectory("03-Primitives")
add_subdirectory("04-Shaders")
add_subdirectory("05-Compute")
add_subdirectory("06-Instancing")
add_subdirectory("07-VSyncTest")
add_subdirectory("08-ModelViewer")
add_subdirectory("09-ImGui")
add_subdirectory("10-MSAA")
add_subdirectory("11-RayTracing")
add_subdirectory("12-PathTracer")