add_library(videowebgpu
  VideoBackend.cpp
  VideoBackend.h
  WebGPUGfx.cpp
  WebGPUGfx.h
  WebGPUCommandStream.cpp
  WebGPUCommandStream.h
  WebGPUShaderTranslator.cpp
  WebGPUShaderTranslator.h
  WebGPUVertexManager.cpp
  WebGPUVertexManager.h
  WebGPUTexture.cpp
  WebGPUTexture.h
  WebGPUUboPacket.h
)

target_link_libraries(videowebgpu
PUBLIC
  common
  videocommon
  videosoftware
)

# Day-30 probe: SPIRV-Tools disassembler (now vendored under glslang
# for ENABLE_OPT) to dump the SPIR-V Naga rejects, pinpointing the
# common construct behind the systematic "invalid id %14".
# SPIRV-Tools is already linked transitively via glslang's optimizer;
# we just need its public include dir on this target.
target_include_directories(videowebgpu PRIVATE
  "${CMAKE_SOURCE_DIR}/Externals/glslang/glslang/External/spirv-tools/include")

if(EMSCRIPTEN)
  # Day-15 (wasm-dolphin): the dolphin_web_core target links with
  # --use-port=emdawnwebgpu, which pulls the WebGPU C bindings at link
  # time. But the include path for <webgpu/webgpu.h> is only set up
  # when the compiler also sees the port flag. Adding the port at
  # compile time here resolves the include search for VideoBackend.cpp
  # / WebGPUGfx.cpp without affecting OGL/Software backends.
  target_compile_options(videowebgpu PRIVATE "--use-port=emdawnwebgpu")
endif()

if(MSVC)
  # Add precompiled header
  target_link_libraries(videowebgpu PRIVATE use_pch)
endif()
