Skip to content

Commit

Permalink
Adapt CMakeLists to emscripten
Browse files Browse the repository at this point in the history
  • Loading branch information
eliemichel committed Oct 15, 2024
1 parent 36d2b74 commit 9c819ae
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 48 deletions.
44 changes: 7 additions & 37 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ jobs:
- system: MacOS-x64
runner: macos-13

- system: emscripten
runner: ubuntu-latest
webgpu-backend: EMSCRIPTEN
link-type: STATIC
build-type: Release
cmake-wrapper: emcmake

# Latest version of Dawn to not support static linking
exclude:
- webgpu-backend: DAWN
Expand Down Expand Up @@ -109,40 +116,3 @@ jobs:
cmake
--build build
--config ${{ matrix.build-type }}
# Was too annoying to put emscripten in the matrix, so here it is, on its own:
build-web:
strategy:
fail-fast: false
matrix:
system: [ emscripten ]
build-type: [ Debug, Release ]
emsdk-version: [ 3.1.61 ]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install dependencies
if: ${{ matrix.install-deps }}
run: ${{ matrix.install-deps }}

- name: Setup emscripten
if: ${{ matrix.emsdk-version }}
uses: mymindstorm/setup-emsdk@v14
with:
version: ${{ matrix.emsdk-version }}

- name: Configure CMake
run: >
emcmake cmake
-S examples
-B build
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }}
- name: Build
run: >
cmake
--build build
--config ${{ matrix.build-type }}
30 changes: 19 additions & 11 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,25 @@ include(FetchContent)
include(utils.cmake)

# Dependencies
FetchContent_Declare(
glfw-light
URL https://eliemichel.github.io/LearnWebGPU/_downloads/6873a344e35ea9f5e4fc7e5cc85d3ab8/glfw-3.4.0-light.zip
URL_HASH MD5=e6684142080457e9227e4f78a6f84fc2
)
FetchContent_Declare(
webgpu
GIT_REPOSITORY https://github.com/eliemichel/WebGPU-distribution.git
GIT_TAG 7ed61fb96d972a4c61ccc79af1139eba2a0ce4c4 # fetch
)
FetchContent_MakeAvailable(glfw-light webgpu)
if (NOT EMSCRIPTEN)
FetchContent_Declare(
glfw-light
URL https://eliemichel.github.io/LearnWebGPU/_downloads/6873a344e35ea9f5e4fc7e5cc85d3ab8/glfw-3.4.0-light.zip
URL_HASH MD5=e6684142080457e9227e4f78a6f84fc2
)
FetchContent_Declare(
webgpu
GIT_REPOSITORY https://github.com/eliemichel/WebGPU-distribution.git
GIT_TAG 7ed61fb96d972a4c61ccc79af1139eba2a0ce4c4 # fetch
)
FetchContent_MakeAvailable(glfw-light webgpu)
else()
# Emscripten has built-in support for GLFW but requires the `-sUSE_GLFW=3` link option:
add_library(glfw-light INTERFACE)
target_link_options(glfw-light INTERFACE -sUSE_GLFW=3)
add_library(webgpu INTERFACE)
target_link_options(webgpu INTERFACE -sUSE_WEBGPU=1)
endif()

# The glfw3webgpu target
# NB: We specify a second argument only because this is an out-of-tree
Expand Down

0 comments on commit 9c819ae

Please sign in to comment.