Skip to content

Commit ed2d482

Browse files
committed
Prepare for a future sdl3 emscripten port
1 parent dfbb7aa commit ed2d482

File tree

2 files changed

+42
-22
lines changed

2 files changed

+42
-22
lines changed

.github/workflows/cmake.yml

-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ jobs:
9595
-DWEBGPU_BACKEND=${{ matrix.webgpu-backend }}
9696
-D${{ matrix.webgpu-backend }}_LINK_TYPE=${{ matrix.link-type }}
9797
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }}
98-
${{ matrix.extra-cmake-args }}
9998
10099
- name: Build (MSYS)
101100
if: ${{ matrix.msystem }}

examples/CMakeLists.txt

+42-21
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,46 @@ include(FetchContent)
66
include(utils.cmake)
77

88
# 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()
2049

2150
# The sdl3webgpu target
2251
# 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)
3160

3261
# Copy wgpu-native or Dawn dll/so/dylib next to the executable
3362
target_copy_webgpu_binaries(hello-sdl3webgpu)
34-
3563
# 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

Comments
 (0)