summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-01-28 01:10:05 +0100
committerskal <pascal.massimino@gmail.com>2026-01-28 01:10:05 +0100
commit6cd6fb41ed44bd37bd05e5a4abf23661605c00df (patch)
treef3c5fb237b71bc6ad2d67dea62324b2edede51c3 /CMakeLists.txt
parenta7bcf5e9cd6884d010b5cec0146293a0515242fc (diff)
refactor(gpu): Integrate WebGPU via system wgpu-native and glfw3webgpu
Replaces the complex wgpu-native submodule and manual platform-specific surface creation with a system-wide wgpu-native install (via Homebrew) and the glfw3webgpu helper library. - Updates scripts/project_init.sh to fetch glfw3webgpu and ensure wgpu-native is installed. - Refactors CMakeLists.txt to link against the system wgpu-native library. - Simplifies src/platform.cc to use glfwCreateWindowWGPUSurface. - Simplifies src/gpu/gpu.cc to use standard WebGPU headers. - Updates FETCH_DEPS.md with new installation instructions. - Updates PROJECT_CONTEXT.md with the new integration strategy.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt85
1 files changed, 52 insertions, 33 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b06bd6d..fc4ea81 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,30 +6,22 @@ option(DEMO_SIZE_OPT "Enable size optimization flags" OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
-# Search in both debug and release
-set(WGPU_SEARCH_PATHS
- ${CMAKE_CURRENT_SOURCE_DIR}/third_party/wgpu-native/target/debug
- ${CMAKE_CURRENT_SOURCE_DIR}/third_party/wgpu-native/target/release
-)
-
-find_library(
- WGPU_LIBRARY NAMES libwgpu_native.a wgpu_native.lib wgpu_native
- HINTS ${WGPU_SEARCH_PATHS}
- REQUIRED
-)
+# Find wgpu-native (system install)
+find_library(WGPU_LIBRARY NAMES wgpu_native libwgpu_native REQUIRED)
+find_path(WGPU_INCLUDE_DIR NAMES webgpu.h PATH_SUFFIXES webgpu-headers REQUIRED)
include_directories(
src
third_party
- third_party/wgpu-native/ffi
- third_party/wgpu-native/ffi/webgpu-headers
+ ${WGPU_INCLUDE_DIR}
+ third_party/glfw3webgpu
)
find_package(glfw3 REQUIRED)
set(DEMO_LIBS glfw ${WGPU_LIBRARY})
-# Platform-specific dependencies for wgpu-native
+# Platform-specific dependencies
if (APPLE)
set_source_files_properties(src/platform.cc PROPERTIES COMPILE_FLAGS "-x objective-c++")
list(APPEND DEMO_LIBS
@@ -52,6 +44,7 @@ add_executable(demo64k
src/audio/idct.cc
src/audio/window.cc
src/audio/synth.cc
+ third_party/glfw3webgpu/glfw3webgpu.c
)
target_link_libraries(demo64k PRIVATE ${DEMO_LIBS})
@@ -86,31 +79,57 @@ if(DEMO_BUILD_TESTS)
target_include_directories(test_synth PRIVATE src)
add_test(NAME SynthEngineTest COMMAND test_synth)
- add_executable(test_spectool
- src/tests/test_spectool.cc
- src/audio/audio.cc
- src/audio/window.cc
- src/audio/fdct.cc
- src/audio/synth.cc
- src/audio/idct.cc
- )
- target_include_directories(test_spectool PRIVATE src third_party)
+ add_executable(test_spectool
+
+ src/tests/test_spectool.cc
+
+ src/audio/audio.cc
+
+ src/audio/window.cc
+
+ src/audio/fdct.cc
+
+ src/audio/synth.cc
+
+ src/audio/idct.cc
+
+ third_party/glfw3webgpu/glfw3webgpu.c
+
+ )
+
+ target_include_directories(test_spectool PRIVATE
+
+ src
+
+ third_party
+
+ ${WGPU_INCLUDE_DIR}
+
+ third_party/glfw3webgpu
+
+ )
target_link_libraries(test_spectool PRIVATE ${DEMO_LIBS})
add_test(NAME SpectoolEndToEndTest COMMAND test_spectool)
endif()
option(DEMO_BUILD_TOOLS "Build tools" OFF)
if(DEMO_BUILD_TOOLS)
- add_executable(spectool
- tools/spectool.cc
- src/platform.cc
- src/audio/audio.cc
- src/audio/fdct.cc
- src/audio/idct.cc
- src/audio/window.cc
- src/audio/synth.cc
- )
- target_include_directories(spectool PRIVATE src third_party)
+ add_executable(spectool
+ tools/spectool.cc
+ src/platform.cc
+ src/audio/audio.cc
+ src/audio/fdct.cc
+ src/audio/idct.cc
+ src/audio/window.cc
+ src/audio/synth.cc
+ third_party/glfw3webgpu/glfw3webgpu.c
+ )
+ target_include_directories(spectool PRIVATE
+ src
+ third_party
+ ${WGPU_INCLUDE_DIR}
+ third_party/glfw3webgpu
+ )
target_link_libraries(spectool PRIVATE ${DEMO_LIBS})
add_executable(specview