Got all the libraries working apparently

This commit is contained in:
Warwick 2025-06-12 16:58:01 +01:00
parent 415f3589b6
commit 5e05d36370
8 changed files with 39 additions and 70 deletions

3
.gitignore vendored
View file

@ -4,4 +4,5 @@ webgpu
## Meson ## Meson
subprojects/ subprojects/
!subprojects/*.wrap !subprojects/*.wrap
!subprojects/dawn !subprojects/wgpu-native
.cache/

6
.gitmodules vendored
View file

@ -1,3 +1,3 @@
[submodule "dawn"] [submodule "subprojects/wgpu-native"]
path = subprojects/dawn path = subprojects/wgpu-native
url = git@github.com:google/dawn.git url = git@github.com:gfx-rs/wgpu-native.git

View file

@ -1,64 +0,0 @@
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
project(webgpu
VERSION 0
DESCRIPTION "Simple Engine Experiment in C"
HOMEPAGE_URL "https://git.warwick-new.co.uk/"
LANGUAGES C
)
set(CMAKE_C_STANDARD 17)
# Since nix include dirs isn't appearing in compile_commands.json we're gonna
# force cmake to link it's includes more explicitly
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
if(CMAKE_EXPORT_COMPILE_COMMANDS)
set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES
${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES})
endif()
# Use environment set by nix-shell to find wgpu include and library
find_path(WGPU_INCLUDE webgpu)
find_library(WGPU_LIBRARY libwgpu_native.so)
message(STATUS "wgpu lib: ${WGPU_LIBRARY}")
message(STATUS "wgpu include dir: ${WGPU_INCLUDE}")
find_package(SDL3 REQUIRED)
find_package(SDL3_image REQUIRED)
find_package(cglm REQUIRED)
find_package(Vulkan REQUIRED)
include(FeatureSummary)
feature_summary(WHAT PACKAGES_FOUND)
file(GLOB_RECURSE SOURCE_FILES
${CMAKE_SOURCE_DIR}/src/*.c)
file(GLOB_RECURSE HEADER_FILES
${CMAKE_SOURCE_DIR}/src/*.h)
add_executable(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES})
# Error on memory address issues in debug mode
if(CMAKE_BUILD_TYPE MATCHES "Debug")
set(
CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -Werror -fsanitize=undefined -fsanitize=address"
)
target_link_options(${PROJECT_NAME}
BEFORE PUBLIC -fsanitize=undefined PUBLIC -fsanitize=address
)
endif()
target_include_directories(${PROJECT_NAME} PRIVATE
${WGPU_INCLUDE}
${SDL3_INCLUDE_DIRS}
${SDL3_image_INCLUDE_DIRS}
${GLFW_INCLUDE_DIRS}
${CGLM_INCLUDE_DIRS}
${Vulkan_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
${WGPU_LIBRARY}
${SDL3_LIBRARIES}
${SDL3_image_LIBRARIES}
${CGLM_LIBRARIES}
${Vulkan_LIBRARIES}
)

3
README.md Normal file
View file

@ -0,0 +1,3 @@
## Teething problems
Currently can't link the meson build in the wgpu-native subproject so just use
mason to install that library system wide for now.

View file

@ -1,10 +1,26 @@
project('webgpu', 'c', project('webgpu', 'c',
default_options: 'default_library=static') default_options: 'default_library=static')
vulkan_dep = dependency('vulkan-headers', fallback: ['vulkan-headers', 'vulkan_headers_dep'])
sdl3_deps = [dependency('sdl3'), dependency('sdl3_image')] sdl3_deps = [dependency('sdl3'), dependency('sdl3_image')]
cglm_dep = dependency('cglm') cglm_dep = dependency('cglm')
wgpu_native_dep = dependency('wgpu-native')
pkg = import('pkgconfig')
#wgpu_native_dep = dependency('wgpu-native', fallback: ['wgpu-native','webgpunative_dep'])
#cmake = import('cmake')
#dawn_cmakeopts = cmake.subproject_options()
#dawn_cmakeopts.add_cmake_defines({'DAWN_FETCH_DEPENDENCIES': 'ON'})
#dawn_cmakeopts.add_cmake_defines({'DAWN_ENABLE_INSTALL': 'ON'})
#dawn_cmakeopts.add_cmake_defines({'CMAKE_BUILD_TYPE': 'Release'})
#dawn = cmake.subproject('dawn', options: dawn_cmakeopts)
##message('CMake targets:\n - ' + '\n - '.join(dawn.target_list()))
#webgpu_dawn_dep = dawn.dependency('webgpu_dawn')
executable('webgpu', 'src/main.c', executable('webgpu', 'src/main.c',
win_subsystem: 'windows', win_subsystem: 'windows',
dependencies: [sdl3_deps,cglm_dep] dependencies: [sdl3_deps, cglm_dep, wgpu_native_dep, vulkan_dep]
) )

@ -1 +0,0 @@
Subproject commit 6f6debdb05bf29b63a93c47428d043357ca2311e

View file

@ -0,0 +1,13 @@
[wrap-file]
directory = Vulkan-Headers-1.3.283
source_url = https://github.com/KhronosGroup/Vulkan-Headers/archive/v1.3.283.tar.gz
source_filename = vulkan-headers-1.3.283.tar.gz
source_hash = a76ff77815012c76abc9811215c2167128a73a697bcc23948e858d1f7dd54a85
patch_filename = vulkan-headers_1.3.283-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/vulkan-headers_1.3.283-1/get_patch
patch_hash = 00e30d35117ae90a19b5b8878746fceaf31b41778b817ca9e6b3ae6063be8233
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/vulkan-headers_1.3.283-1/vulkan-headers-1.3.283.tar.gz
wrapdb_version = 1.3.283-1
[provide]
vulkanheaders = vulkan_headers_dep

@ -0,0 +1 @@
Subproject commit 662f9dc44eb86c63a445526cc21b9326a279aca8