wgpu-native
wgpu-native copied to clipboard
Generate CMake distribution in CD
Hello,
I am trying to make the integration of the precompiled binaries in a CMake-based project as easy and portable as possible for my WebGPU C++ guide and I came up with a solution that satisfies me:
- Easy to integrate, with a
webgpuCMake target to link like any library and that manages the pre-compiled binaries - Define a
WEBGPU_BACKEND_WGPUto distinguish this distribution for the Dawn-based alternative that I also provide - Follow modern idioms of CMake
- Works with emscripten
Currently I point my readers to my WebGPU-distribution repository but I think this is something that would be worth making available directly in the release of wgpu-native.
This PR adds to the CD process the generation of a distribution of WebGPU that can be simply copied in a CMake project and integrated with add_subdirectory(webgpu). More info to be found in distribution/REAMD.md.
This is something that I am going to also discuss with Dawn so that ideally we end up with a common way of packaging binaries for CMake. I'll be happy to discuss the details and adapt to as many use cases as possible!
Oh thanks my bad!
This is open for a while even though this is about finished. I think this needs a round of review from someone with more experience (than me) in build systems. cc @rajveermalviya
Is there something I can do to help push this along?
@rajveermalviya Any chance I can help get this wrapped up for the next release?
(Apologies for missing this)
Tbh instead of this, I would prefer a setup where user can clone the repo (or github's download zip) to a directory and then import that directory via add_subdirectory.
Then the CMakeLists.txt at the root in this repo could the have an option like DOWNLOAD_PREBUILT_BINARIES, where default would be false. So, the binaries would be built from source by default & if that option is enabled then the binaries would be downloaded from Github Releases. Such a setup would also allow us to mirror cargo optional features that are currently disabled in the release packages.
But not really sure how emscripten would fit in that.
I agree actually, not my topmost priority at the moment but I'll work on this eventually!
wasmtime does something similar as well. I have it on my list to try to get to this sooner rather than later.
I have a working prototype of this locally now. I'll need #359 to land and then I can start on a series of PRs that get us to (what I hope is) a good place.