Hi,
I'm an experienced developer, but I don't know C++ or CMake very well. I recently tried following tutorials like
https://developer.chrome.com/docs/web-platform/webgpu/build-app , but despite trying to follow the instructions precisely, had a heck of a time getting it working. As soon as I run my exe, I get console output like: "Process finished with exit code -1073741515 (0xC0000135)". I tried many things, but none of them helped.
It was only when I happened to run the exe from CLion in "debug" mode (not "Debug" release but like, with a debugger attached), that I got a meaningful error message, basically, "webgpu_dawn.dll was not found".
It seems that the instructions assume that the built exe will end up in the same directory as webgpu_dawn.dll. However, instead the built DLL was in "./dawn" relative to the exe, therefore it couldn't be found. After doing some searching, I added this to my CMakeLists.txt which fixes the issue by copying the DLL into the same directory as the exe. I don't know if this is the "best" solution, but it works well enough for me.
add_custom_command(TARGET myapp POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:myapp> $<TARGET_FILE_DIR:myapp>
COMMAND_EXPAND_LISTS
)
I don't know if my scenario is specific to Windows, CMake, or CLion. But it seems like the build config or the tutorial instructions may need some improvement to produce a reliable outcome. In any case, maybe this will help someone else.
D:\projects\oss\dawn>cmake --install out/Release --prefix install/Release
-- Install configuration: "Release"
CMake Error at out/Release/src/dawn/native/cmake_install.cmake:51 (file):
file INSTALL cannot find
"D:/projects/oss/dawn/out/Release/Release/webgpu_dawn.dll": File exists.
Call Stack (most recent call first):
out/Release/src/dawn/cmake_install.cmake:62 (include)
out/Release/cmake_install.cmake:62 (include)
Also, during "cmake --build out/Release" I notice a lot of suspicious looking mentions of "Debug" even though it's supposed to be a Release build. For example:
SPIRV-Tools-static.vcxproj -> D:\projects\oss\dawn\out\Release\third_party\spirv-tools\source\Debug\SPIRV-Tools.lib
SPIRV-Tools-opt.vcxproj -> D:\projects\oss\dawn\out\Release\third_party\spirv-tools\source\opt\Debug\SPIRV-Tools-opt.
lib
....
webgpu_dawn.vcxproj -> D:\projects\oss\dawn\out\Release\Debug\webgpu_dawn.dll
-Shannon