@@ -6,17 +6,46 @@ include(FetchContent)
6
6
include (utils.cmake)
7
7
8
8
# Dependencies
9
- FetchContent_Declare(
10
- sdl3
11
- GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
12
- GIT_TAG preview-3.1.3
13
- )
14
- FetchContent_Declare(
15
- webgpu
16
- GIT_REPOSITORY https://github.com/eliemichel/WebGPU-distribution.git
17
- GIT_TAG 479541d24699fddb60a903da081203bdbe4735a7 # fetch
18
- )
19
- FetchContent_MakeAvailable(sdl3 webgpu)
9
+ if (EMSCRIPTEN)
10
+
11
+ add_library (SDL3_SDL3 INTERFACE )
12
+ target_compile_options (SDL3_SDL3 INTERFACE --use-port=sdl3) # NB: This port does not exist yet, emscripten is not supported
13
+ add_library (SDL3::SDL3 ALIAS SDL3_SDL3)
14
+ function (target_copy_sdl3_binaries)
15
+ endfunction ()
16
+
17
+ add_library (webgpu INTERFACE )
18
+ target_link_options (webgpu INTERFACE -sUSE_WEBGPU=1)
19
+ function (target_copy_webgpu_binaries)
20
+ endfunction ()
21
+
22
+ else ()
23
+
24
+ FetchContent_Declare(
25
+ sdl3
26
+ GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
27
+ GIT_TAG preview-3.1.3
28
+ )
29
+ FetchContent_Declare(
30
+ webgpu
31
+ GIT_REPOSITORY https://github.com/eliemichel/WebGPU-distribution.git
32
+ GIT_TAG 479541d24699fddb60a903da081203bdbe4735a7 # fetch
33
+ )
34
+ FetchContent_MakeAvailable(sdl3 webgpu)
35
+
36
+ function (target_copy_sdl3_binaries Target )
37
+ add_custom_command (
38
+ TARGET ${Target}
39
+ POST_BUILD
40
+ COMMAND
41
+ ${CMAKE_COMMAND}
42
+ -E copy_if_different
43
+ $<TARGET_FILE:SDL3::SDL3>
44
+ $<TARGET_FILE_DIR:${Target} >
45
+ )
46
+ endfunction ()
47
+
48
+ endif ()
20
49
21
50
# The sdl3webgpu target
22
51
# NB: We specify a second argument only because this is an out-of-tree
@@ -31,14 +60,6 @@ target_treat_all_warnings_as_errors(hello-sdl3webgpu)
31
60
32
61
# Copy wgpu-native or Dawn dll/so/dylib next to the executable
33
62
target_copy_webgpu_binaries(hello-sdl3webgpu)
34
-
35
63
# Copy SDL3.dll/so/dylib next to the executable
36
- add_custom_command (
37
- TARGET hello-sdl3webgpu
38
- POST_BUILD
39
- COMMAND
40
- ${CMAKE_COMMAND}
41
- -E copy_if_different
42
- $<TARGET_FILE:SDL3::SDL3>
43
- $<TARGET_FILE_DIR:hello-sdl3webgpu>
44
- )
64
+ target_copy_sdl3_binaries(hello-sdl3webgpu)
65
+
0 commit comments