Skip to content

Instantly share code, notes, and snippets.

@sortofsleepy
Created June 8, 2023 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sortofsleepy/393eee084f1005d13d3146579598d869 to your computer and use it in GitHub Desktop.
Save sortofsleepy/393eee084f1005d13d3146579598d869 to your computer and use it in GitHub Desktop.
Building Google Dawn w/ CMake
cmake_minimum_required(VERSION 3.25)
project(dawn_compile)
set(CMAKE_CXX_STANDARD 17)
add_executable(dawn_compile main.cpp)
include_directories(dawn_compile ${CMAKE_CURRENT_SOURCE_DIR}/libraries/dawn/include)
include_directories(dawn_compile ${CMAKE_CURRENT_SOURCE_DIR}/libraries/dawn/gen/include)
# 12-16 Assumes you built with DirectX - adjust as needed
find_library(DIRECTX_LIBRARY NAMES d3d11)
find_library(DIRECTX_DXGUID NAMES dxguid)
target_link_libraries(dawn_compile "${DIRECTX_LIBRARY}")
target_link_libraries(dawn_compile "${DIRECTX_DXGUID}")
target_link_libraries(dawn_compile libraries/libs/webgpu_dawn.lib)
target_link_libraries(dawn_compile libraries/libs/dawn_native.lib)
target_link_libraries(dawn_compile libraries/libs/dawn_common.lib)
target_link_libraries(dawn_compile libraries/libs/dawn_headers.lib)
target_link_libraries(dawn_compile libraries/libs/dawn_platform.lib)
target_link_libraries(dawn_compile libraries/libs/dawn_proc.lib)
target_link_libraries(dawn_compile libraries/libs/dawncpp.lib)
target_link_libraries(dawn_compile libraries/libs/dawncpp_headers.lib)
target_link_libraries(dawn_compile libraries/libs/tint.lib)
target_link_libraries(dawn_compile libraries/libs/tint_utils_io.lib)
target_link_libraries(dawn_compile libraries/libs/tint_val.lib)
target_link_libraries(dawn_compile libraries/libs/tint_diagnostic_utils.lib)
target_link_libraries(dawn_compile libraries/libs/absl_str_format_internal.lib)
target_link_libraries(dawn_compile libraries/libs/absl_strings.lib)
target_link_libraries(dawn_compile libraries/libs/absl_base.lib)
target_link_libraries(dawn_compile libraries/libs/absl_strings_internal.lib)
target_link_libraries(dawn_compile libraries/libs/absl_int128.lib)
target_link_libraries(dawn_compile libraries/libs/absl_malloc_internal.lib)
target_link_libraries(dawn_compile libraries/libs/absl_raw_logging_internal.lib)
target_link_libraries(dawn_compile libraries/libs/absl_throw_delegate.lib)
target_link_libraries(dawn_compile libraries/libs/SPIRV-Tools.lib)
target_link_libraries(dawn_compile libraries/libs/SPIRV-Tools-opt.lib)
@sortofsleepy
Copy link
Author

sortofsleepy commented Jun 8, 2023

This is more for my own reference but for anyone that stumbles across this - this is so far the basics of what's needed to compile a standard build of Google's Dawn library as of 6/8/2023.

This assumes some things

  • That you're doing a standard build with no real changes to the default options other than possibly not building some optional dependencies like GTest, etc.
  • That you're including DirectX support
  • All of the libraries are located in a folder called libraries at your root

As far as header files, I have the include folder at the root of the Dawn repo in the root of my project folder. I also include the gen folder that is generated once you build Dawn. The project folder basically looks like

  libraries
    - dawn 
      - gen 
      - include
   - libs

So far this is enough to declare a dawn::native::Instance object without errors; that said it might still need more adjustments for Dawn to be fully usable.

Adjust as needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment