CMake updates.

This CL updates the CMake file to allow building Dawn with WGSL support
enabled. A few other required fixes are included.

Bug: None
Change-Id: I11a09710f0ad075a07e23c44ff884826850655e7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/30841
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
dan sinclair 2020-10-23 13:10:20 +00:00 committed by Commit Bot service account
parent 24e6369261
commit bb3d7981ec
3 changed files with 20 additions and 3 deletions

View File

@ -69,6 +69,7 @@ option(DAWN_ENABLE_METAL "Enable compilation of the Metal backend" ${ENABLE_META
option(DAWN_ENABLE_NULL "Enable compilation of the Null backend" ON)
option(DAWN_ENABLE_OPENGL "Enable compilation of the OpenGL backend" ${ENABLE_OPENGL})
option(DAWN_ENABLE_VULKAN "Enable compilation of the Vulkan backend" ${ENABLE_VULKAN})
option(DAWN_ENABLE_WGSL "Enable WGSL support" OFF)
option(DAWN_ALWAYS_ASSERT "Enable assertions on all build types" OFF)
option(DAWN_USE_X11 "Enable support for X11 surface" ${USE_X11})
@ -84,6 +85,7 @@ set(DAWN_SHADERC_DIR "${DAWN_THIRD_PARTY_DIR}/shaderc" CACHE STRING "Directory i
set(DAWN_SPIRV_CROSS_DIR "${DAWN_THIRD_PARTY_DIR}/spirv-cross" CACHE STRING "Directory in which to find SPIRV-Cross")
set(DAWN_SPIRV_HEADERS_DIR "${DAWN_THIRD_PARTY_DIR}/spirv-headers" CACHE STRING "Directory in which to find SPIRV-Headers")
set(DAWN_SPIRV_TOOLS_DIR "${DAWN_THIRD_PARTY_DIR}/SPIRV-Tools" CACHE STRING "Directory in which to find SPIRV-Tools")
set(DAWN_TINT_DIR "${DAWN_THIRD_PARTY_DIR}/tint" CACHE STRING "Directory in which to find Tint")
################################################################################
# Dawn's public and internal "configs"
@ -123,6 +125,9 @@ endif()
if (DAWN_ENABLE_VULKAN)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_VULKAN")
endif()
if (DAWN_ENABLE_WGSL)
target_compile_definitions(dawn_internal_config INTERFACE "-DDAWN_ENABLE_WGSL=1")
endif()
if (DAWN_USE_X11)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_X11")
endif()
@ -130,7 +135,6 @@ if (WIN32)
target_compile_definitions(dawn_internal_config INTERFACE "NOMINMAX" "WIN32_LEAN_AND_MEAN")
endif()
set(CMAKE_CXX_STANDARD "14")
################################################################################
@ -144,6 +148,8 @@ add_subdirectory(src/dawn)
add_subdirectory(src/dawn_platform)
add_subdirectory(src/dawn_native)
add_subdirectory(src/dawn_wire)
# TODO(dawn:269): Remove once the implementation-based swapchains are removed.
add_subdirectory(src/utils)
if (DAWN_BUILD_EXAMPLES)
add_subdirectory(src/utils)

View File

@ -25,6 +25,10 @@ if(BUILD_SHARED_LIBS)
target_compile_definitions(dawn_native PRIVATE "DAWN_NATIVE_SHARED_LIBRARY")
endif()
if(DAWN_ENABLE_WGSL)
target_link_libraries(dawn_native PRIVATE libtint)
endif()
target_sources(dawn_native PRIVATE
"${DAWN_INCLUDE_DIR}/dawn_native/DawnNative.h"
"${DAWN_INCLUDE_DIR}/dawn_native/dawn_native_export.h"
@ -159,7 +163,7 @@ target_link_libraries(dawn_native
spirv-cross-glsl
spirv-cross-hlsl
spirv-cross-msl
SPIRV-Tools
SPIRV-Tools-opt
)
if (DAWN_USE_X11)
@ -207,7 +211,7 @@ if (DAWN_ENABLE_D3D12)
"d3d12/HeapAllocatorD3D12.h"
"d3d12/HeapD3D12.cpp"
"d3d12/HeapD3D12.h"
"d3d12/IntegerTypes.h"
"d3d12/IntegerTypes.h"
"d3d12/NativeSwapChainImplD3D12.cpp"
"d3d12/NativeSwapChainImplD3D12.h"
"d3d12/PageableD3D12.cpp"

View File

@ -78,6 +78,13 @@ if (DAWN_BUILD_EXAMPLES)
endif()
endif()
if (DAWN_BUILD_WGSL)
if (NOT TARGET libtint)
message(STATUS "Dawn: using Tint at ${DAWN_TINT_DIR}")
add_subdirectory(${DAWN_TINT_DIR})
endif()
endif()
# Header-only library for khrplatform.h
add_library(dawn_khronos_platform INTERFACE)
target_sources(dawn_khronos_platform INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/khronos/KHR/khrplatform.h")