-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
156 lines (123 loc) · 6.92 KB
/
CMakeLists.txt
File metadata and controls
156 lines (123 loc) · 6.92 KB
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
# This file is part of the AMD & HSC Work Graph Playground.
#
# Copyright (C) 2025 Advanced Micro Devices, Inc. and Coburg University of Applied Sciences and Arts.
# All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files(the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions :
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
cmake_minimum_required(VERSION 3.17)
project(WorkGraphPlayground VERSION 1.1)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_EXECUTABLE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
add_compile_definitions(UNICODE _UNICODE)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
option(PLAYGROUND_ENABLE_MESH_NODES "Enable experimental mesh node support" OFF)
set(PLAYGROUND_COPY_TUTORIAL_MODE "none" CACHE STRING "Mode for copying tutorial files to output bin folder.\n none: do not copy tutorial files.\n copy: copy tutorial files after build step.\n symlink: create symlinks for tutorial folder to bin folder.")
set_property(CACHE PLAYGROUND_COPY_TUTORIAL_MODE PROPERTY STRINGS none copy symlink)
add_subdirectory(imported)
add_executable(${PROJECT_NAME})
if (PLAYGROUND_ENABLE_MESH_NODES)
target_compile_definitions(${PROJECT_NAME} PRIVATE ENABLE_MESH_NODES)
endif()
# collect & add C++ source files
file(GLOB PROJECT_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/*.h
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_FILES})
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
# link NuGet packages and ImGui
target_link_libraries(${PROJECT_NAME} PRIVATE
Microsoft.Direct3D.D3D12
Microsoft.Direct3D.DXC
Microsoft.Direct3D.WARP
d3d12
dxcompiler
dxgi
dxguid
imgui)
set_target_properties(${PROJECT_NAME} PROPERTIES
# set playground app to be DPI aware, i.e. disable scaling in Windows compositor
VS_DPI_AWARE "PerMonitor"
# set working directory to current directory
VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# set playground as startup project
set_property(DIRECTORY "." PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})
set(TUTORIAL_FOLDER_LIST "")
function(add_tutorial_folder TUTORIAL_FOLDER PREFIX SOURCE_GROUP)
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${TUTORIAL_FOLDER})
message(FATAL "Tutorial folder ${TUTORIAL_FOLDER} not found in current source directory!")
endif()
# collect tutorial source files
file(GLOB_RECURSE TUTORIAL_FILES
${CMAKE_CURRENT_SOURCE_DIR}/${TUTORIAL_FOLDER}/*.md
${CMAKE_CURRENT_SOURCE_DIR}/${TUTORIAL_FOLDER}/*.png
${CMAKE_CURRENT_SOURCE_DIR}/${TUTORIAL_FOLDER}/*.h
${CMAKE_CURRENT_SOURCE_DIR}/${TUTORIAL_FOLDER}/*.hlsl)
# add tutorial source files and disable compilation of HLSL files
target_sources(${PROJECT_NAME} PRIVATE ${TUTORIAL_FILES})
set_source_files_properties(${TUTORIAL_FILES} PROPERTIES VS_TOOL_OVERRIDE "Text")
if ("${PLAYGROUND_COPY_TUTORIAL_MODE}" STREQUAL "copy")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/${TUTORIAL_FOLDER}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>/${TUTORIAL_FOLDER})
elseif("${PLAYGROUND_COPY_TUTORIAL_MODE}" STREQUAL "symlink")
# To allow for easy copying of the playground and all tutorials, we support creating symlinks for all
# tutorial folders to the bin output folder. As shader source files are not part of the build process
# changes to these files are not tracked by the build system.
# To still keep all the shader source files in the bin folder up-to-date, we create a symlink for each folder.
# This way, updates to the shader source file are automatically propagated to the bin folder,
# allowing you to copy/move/compress the bin folder with the latest version of your shader file.
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/${TUTORIAL_FOLDER}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>/${TUTORIAL_FOLDER})
endif()
# set source group for shader files & link to bin folder
foreach(TUTORIAL_FILE ${TUTORIAL_FILES})
get_filename_component(TUTORIAL_FILE_DIRECTORY ${TUTORIAL_FILE} DIRECTORY)
get_filename_component(TUTORIAL_FILE_NAME ${TUTORIAL_FILE} NAME)
file(RELATIVE_PATH TUTORIAL_FILE_DIRECTORY_RELATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${TUTORIAL_FOLDER} ${TUTORIAL_FILE_DIRECTORY})
if ("${TUTORIAL_FILE_DIRECTORY_RELATIVE_PATH}" STREQUAL "")
source_group("${SOURCE_GROUP}" FILES ${TUTORIAL_FILE})
else()
source_group("${SOURCE_GROUP}/${TUTORIAL_FILE_DIRECTORY_RELATIVE_PATH}" FILES ${TUTORIAL_FILE})
endif()
endforeach()
set(TUTORIAL_FOLDER_LIST "${TUTORIAL_FOLDER_LIST}std::make_pair(\"${TUTORIAL_FOLDER}\", \"${PREFIX}\")," PARENT_SCOPE)
endfunction(add_tutorial_folder)
add_tutorial_folder(tutorials "Tutorial" "Shader Source Files")
if (PLAYGROUND_ENABLE_MESH_NODES)
# Add mesh node tutorials. These are only included if mesh nodes are enabled.
add_tutorial_folder(mesh-node-tutorials "Mesh Node Tutorial" "Shader Source Files/Mesh Nodes")
endif()
########################################################################################################
# Add new tutorial folders here
#
# Example:
# add_tutorial_folder(./path/to/your/folder "My Tutorial Prefix" "Shader Source Files/My New Tutorials")
#
# Tutorials in this folder will show up in the UI as "My Tutorial Prefix #: Tutorial Name" and
# show up in the solution under "Shader Source Files/My New Tutorials"
#
########################################################################################################
# Once all tutorials are added, set define for app to scan all tutorial folders at runtime
target_compile_definitions(${PROJECT_NAME} PRIVATE TUTORIAL_FOLDER_LIST=${TUTORIAL_FOLDER_LIST})