-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
webgpu.cmake
94 lines (77 loc) · 3.6 KB
/
webgpu.cmake
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
# This file is part of the "Learn WebGPU for C++" book.
# https://eliemichel.github.io/LearnWebGPU
#
# MIT License
# Copyright (c) 2022-2024 Elie Michel and the wgpu-native authors
#
# 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.
include(FetchContent)
set(WEBGPU_BACKEND "WGPU" CACHE STRING "Backend implementation of WebGPU. Possible values are EMSCRIPTEN, WGPU, WGPU_STATIC and DAWN (it does not matter when using emcmake)")
set_property(CACHE WEBGPU_BACKEND PROPERTY STRINGS EMSCRIPTEN WGPU WGPU_STATIC DAWN)
# FetchContent's GIT_SHALLOW option is buggy and does not actually do a shallow
# clone. This macro takes care of it.
macro(FetchContent_DeclareShallowGit Name GIT_REPOSITORY GitRepository GIT_TAG GitTag)
FetchContent_Declare(
"${Name}"
# This is what it'd look line if GIT_SHALLOW was indeed working:
#GIT_REPOSITORY "${GitRepository}"
#GIT_TAG "${GitTag}"
#GIT_SHALLOW ON
# Manual download mode instead:
DOWNLOAD_COMMAND
cd "${FETCHCONTENT_BASE_DIR}/${Name}-src" &&
git init &&
git fetch --depth=1 "${GitRepository}" "${GitTag}" &&
git reset --hard FETCH_HEAD
)
endmacro()
if (NOT TARGET webgpu)
string(TOUPPER ${WEBGPU_BACKEND} WEBGPU_BACKEND_U)
if (EMSCRIPTEN OR WEBGPU_BACKEND_U STREQUAL "EMSCRIPTEN")
FetchContent_DeclareShallowGit(
webgpu-backend-emscripten
GIT_REPOSITORY https://github.com/eliemichel/WebGPU-distribution
GIT_TAG fa0b54d68841fb33188403b07959d403b24511de # emscripten-v3.1.61 + fix
)
FetchContent_MakeAvailable(webgpu-backend-emscripten)
elseif (WEBGPU_BACKEND_U STREQUAL "WGPU")
FetchContent_DeclareShallowGit(
webgpu-backend-wgpu
GIT_REPOSITORY https://github.com/eliemichel/WebGPU-distribution
GIT_TAG 54a60379a9d792848a2311856375ceef16db150e # wgpu-v0.19.4.1 + fix
)
FetchContent_MakeAvailable(webgpu-backend-wgpu)
elseif (WEBGPU_BACKEND_U STREQUAL "WGPU_STATIC")
FetchContent_DeclareShallowGit(
webgpu-backend-wgpu-static
GIT_REPOSITORY https://github.com/eliemichel/WebGPU-distribution
GIT_TAG a54a378066e52358098c51552fe541cf47c44d66 # wgpu-static-v0.19.4.1 + fix
)
FetchContent_MakeAvailable(webgpu-backend-wgpu-static)
elseif (WEBGPU_BACKEND_U STREQUAL "DAWN")
FetchContent_DeclareShallowGit(
webgpu-backend-dawn
GIT_REPOSITORY https://github.com/eliemichel/WebGPU-distribution
GIT_TAG 50a5be486cd97fda8cd98693bf2561d4d4f86597 # dawn-6536 + fix
)
FetchContent_MakeAvailable(webgpu-backend-dawn)
else()
message(FATAL_ERROR "Invalid value for WEBGPU_BACKEND: possible values are EMSCRIPTEN, WGPU, WGPU_STATIC and DAWN, but '${WEBGPU_BACKEND_U}' was provided.")
endif()
endif()