-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
66 lines (54 loc) · 2.04 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
63
64
65
# This example comes from https://eliemichel.github.io/LearnWebGPU
cmake_minimum_required(VERSION 3.11.0...3.25.0)
project(sdl3webgpu-examples VERSION 1.0.0 LANGUAGES C)
include(FetchContent)
include(utils.cmake)
# Dependencies
if (EMSCRIPTEN)
add_library(SDL3_SDL3 INTERFACE)
target_compile_options(SDL3_SDL3 INTERFACE --use-port=sdl3) # NB: This port does not exist yet, emscripten is not supported
target_link_options(SDL3_SDL3 INTERFACE --use-port=sdl3) # NB: This port does not exist yet, emscripten is not supported
add_library(SDL3::SDL3 ALIAS SDL3_SDL3)
function(target_copy_sdl3_binaries)
endfunction()
add_library(webgpu INTERFACE)
target_link_options(webgpu INTERFACE -sUSE_WEBGPU=1)
function(target_copy_webgpu_binaries)
endfunction()
else()
FetchContent_Declare(
sdl3
URL https://github.com/libsdl-org/SDL/archive/refs/tags/release-3.2.8.zip
URL_HASH MD5=1a4affbf987808da38a0d6c8aa802a5e
)
FetchContent_Declare(
webgpu
URL https://github.com/eliemichel/WebGPU-distribution/archive/refs/tags/main-v0.3.0-alpha.zip
URL_HASH MD5=ea1195dc6c7661c36aa13ea5b734b86e
)
FetchContent_MakeAvailable(sdl3 webgpu)
function(target_copy_sdl3_binaries Target)
add_custom_command(
TARGET ${Target}
POST_BUILD
COMMAND
${CMAKE_COMMAND}
-E copy_if_different
$<TARGET_FILE:SDL3::SDL3>
$<TARGET_FILE_DIR:${Target}>
)
endfunction()
endif()
# The sdl3webgpu target
# NB: We specify a second argument only because this is an out-of-tree
# directory, no need to do this in your case.
add_subdirectory(.. sdl3webgpu)
# Example
add_executable(hello-sdl3webgpu hello-sdl3webgpu.c)
target_link_libraries(hello-sdl3webgpu PRIVATE SDL3::SDL3 webgpu sdl3webgpu)
set_target_properties(hello-sdl3webgpu PROPERTIES CXX_STANDARD 17)
target_treat_all_warnings_as_errors(hello-sdl3webgpu)
# Copy wgpu-native or Dawn dll/so/dylib next to the executable
target_copy_webgpu_binaries(hello-sdl3webgpu)
# Copy SDL3.dll/so/dylib next to the executable
target_copy_sdl3_binaries(hello-sdl3webgpu)