Skip to content

Commit 82b9b67

Browse files
committed
Add WASM support
1 parent 082b5f6 commit 82b9b67

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

.github/workflows/cmake-multi-platform.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,57 @@ jobs:
253253
shell: bash
254254
run: |
255255
cmake --build cmake-build/build/android-release-vcpkg --target unit_tests omath
256+
257+
##############################################################################
258+
# 6) WebAssembly (Emscripten) – Clang / Ninja / wasm32-emscripten
259+
##############################################################################
260+
wasm-build-and-test:
261+
name: WebAssembly (Emscripten) (wasm32-emscripten)
262+
runs-on: ubuntu-latest
263+
env:
264+
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
265+
steps:
266+
- name: Checkout repository (with sub-modules)
267+
uses: actions/checkout@v4
268+
with:
269+
submodules: recursive
270+
271+
- name: Install basic tool-chain
272+
shell: bash
273+
run: |
274+
sudo apt-get update
275+
sudo apt-get install -y ninja-build
276+
277+
- name: Setup Emscripten
278+
uses: mymindstorm/setup-emsdk@v14
279+
with:
280+
version: 'latest'
281+
282+
- name: Verify Emscripten
283+
shell: bash
284+
run: |
285+
echo "EMSDK=$EMSDK"
286+
emcc --version
287+
# Verify toolchain file exists
288+
ls -la "$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
289+
290+
- name: Set up vcpkg
291+
shell: bash
292+
run: |
293+
git clone https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
294+
cd "$VCPKG_ROOT"
295+
./bootstrap-vcpkg.sh
296+
297+
- name: Configure (cmake --preset)
298+
shell: bash
299+
run: |
300+
cmake --preset wasm-release-vcpkg \
301+
-DVCPKG_INSTALL_OPTIONS="--allow-unsupported" \
302+
-DOMATH_BUILD_TESTS=ON \
303+
-DOMATH_BUILD_BENCHMARK=OFF \
304+
-DVCPKG_MANIFEST_FEATURES="imgui;tests"
305+
306+
- name: Build
307+
shell: bash
308+
run: |
309+
cmake --build cmake-build/build/wasm-release-vcpkg --target unit_tests omath

CMakePresets.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,44 @@
327327
"cacheVariables": {
328328
"CMAKE_BUILD_TYPE": "Release"
329329
}
330+
},
331+
{
332+
"name": "wasm-base",
333+
"hidden": true,
334+
"generator": "Ninja",
335+
"binaryDir": "${sourceDir}/cmake-build/build/${presetName}",
336+
"installDir": "${sourceDir}/cmake-build/install/${presetName}",
337+
"cacheVariables": {
338+
"CMAKE_MAKE_PROGRAM": "ninja"
339+
}
340+
},
341+
{
342+
"name": "wasm-base-vcpkg",
343+
"hidden": true,
344+
"inherits": "wasm-base",
345+
"cacheVariables": {
346+
"OMATH_BUILD_VIA_VCPKG": "ON",
347+
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
348+
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "$env{EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake",
349+
"VCPKG_INSTALLED_DIR": "${sourceDir}/cmake-build/vcpkg_installed",
350+
"VCPKG_TARGET_TRIPLET": "wasm32-emscripten"
351+
}
352+
},
353+
{
354+
"name": "wasm-debug-vcpkg",
355+
"displayName": "WASM Debug Vcpkg",
356+
"inherits": "wasm-base-vcpkg",
357+
"cacheVariables": {
358+
"CMAKE_BUILD_TYPE": "Debug"
359+
}
360+
},
361+
{
362+
"name": "wasm-release-vcpkg",
363+
"displayName": "WASM Release Vcpkg",
364+
"inherits": "wasm-base-vcpkg",
365+
"cacheVariables": {
366+
"CMAKE_BUILD_TYPE": "Release"
367+
}
330368
}
331369
]
332370
}

0 commit comments

Comments
 (0)