-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
62 lines (53 loc) · 1.97 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
# Specify the minimum version for CMake
cmake_minimum_required(VERSION 3.0...3.27)
# Project meta data
project(
LearnWebGPU # name of the project, which will also be the name of the visual studio solution if you use it
VERSION 0.1.0 # any version number
LANGUAGES CXX C # programming languages used by the project
)
# Include the file that defines target_treat_all_warnings_as_errors
# (I do this because I reuse this function across many projects and
# want to keep this main file easy to read).
include(utils.cmake)
# Include glfw directory, to define the 'glfw' target
add_subdirectory(glfw)
# Include webgpu directory, to define the 'webgpu' target
add_subdirectory(webgpu)
# Helper to get surface for current OS
add_subdirectory(glfw3webgpu)
# Resolve webgpu cpp wrapper depending on backend
string(TOUPPER ${WEBGPU_BACKEND} WEBGPU_BACKEND_U)
if (WEBGPU_BACKEND_U STREQUAL "WGPU")
set(WEBGPU_CPPWRAPPER, "webgpu-cppwrapper/wgpu-native/webgpu.hpp")
endif()
if (WEBGPU_BACKEND_U STREQUAL "DAWN")
set(WEBGPU_CPPWRAPPER, "webgpu-cppwrapper/dawn/webgpu.hpp")
endif()
# Add main.cpp as executable
add_executable(${PROJECT_NAME}
main.cpp
${WEBGPU_CPPWRAPPER}
)
# Add the dependencies to link
target_link_libraries(${PROJECT_NAME} PRIVATE
glfw
webgpu
glfw3webgpu
)
# Use C++17
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)
# Turn all warnings on and treat them as errors so that are not
# tempted to ignore them (See utils.cmake for details).
target_treat_all_warnings_as_errors(${PROJECT_NAME})
# 1) Tell XCode how to generate scheme
# 2) Enable frame capture for GPU debugging
if(XCODE)
set_target_properties(${PROJECT_NAME} PROPERTIES
XCODE_GENERATE_SCHEME ON
XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE "Metal")
endif()
# The application's binary must find wgpu.dll or libwgpu.so at runtime,
# so we automatically copy it (it's called WGPU_RUNTIME_LIB in general)
# next to the binary.
target_copy_webgpu_binaries(${PROJECT_NAME})