CMake: update backend selection

The single DAWN_ENABLE_OPENGL flag in the root CMakeLists.txt did not define
DAWN_ENABLE_BACKEND_DESKTOP_GL or DAWN_ENABLE_BACKEND_OPENGLES, so examples
with `-b opengl` reported `Backend isn't present` and failed to start.

ENABLE_OPENGL flag in root CMakeLists.txt was replaced by ENABLE_DESKTOP_GL
and ENABLE_OPENGLES flags, repeating the logic of similar flags
in GN buildsystem as done in src/common/BUILD.gn
and scripts/dawn_features.gni.

Change-Id: I6302de7aa98436ddc0aa002d83dd6b3e7102e49c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56283
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Sergey K <sergey.ext@gmail.com>
This commit is contained in:
Sergey Karchevsky 2021-06-30 15:06:43 +00:00 committed by Dawn LUCI CQ
parent bf832f07d6
commit 3a75b1cea8
1 changed files with 17 additions and 3 deletions

View File

@ -50,7 +50,8 @@ set(DAWN_DUMMY_FILE "${DAWN_SRC_DIR}/Dummy.cpp")
# Default values for the backend-enabling options # Default values for the backend-enabling options
set(ENABLE_D3D12 OFF) set(ENABLE_D3D12 OFF)
set(ENABLE_METAL OFF) set(ENABLE_METAL OFF)
set(ENABLE_OPENGL OFF) set(ENABLE_OPENGLES OFF)
set(ENABLE_DESKTOP_GL OFF)
set(ENABLE_VULKAN OFF) set(ENABLE_VULKAN OFF)
set(USE_X11 OFF) set(USE_X11 OFF)
set(BUILD_EXAMPLE OFF) set(BUILD_EXAMPLE OFF)
@ -64,7 +65,8 @@ if (WIN32)
elseif(APPLE) elseif(APPLE)
set(ENABLE_METAL ON) set(ENABLE_METAL ON)
elseif(UNIX) elseif(UNIX)
set(ENABLE_OPENGL ON) set(ENABLE_OPENGLES ON)
set(ENABLE_DESKTOP_GL ON)
set(ENABLE_VULKAN ON) set(ENABLE_VULKAN ON)
set(USE_X11 ON) set(USE_X11 ON)
endif() endif()
@ -82,7 +84,8 @@ endif()
option(DAWN_ENABLE_D3D12 "Enable compilation of the D3D12 backend" ${ENABLE_D3D12}) option(DAWN_ENABLE_D3D12 "Enable compilation of the D3D12 backend" ${ENABLE_D3D12})
option(DAWN_ENABLE_METAL "Enable compilation of the Metal backend" ${ENABLE_METAL}) option(DAWN_ENABLE_METAL "Enable compilation of the Metal backend" ${ENABLE_METAL})
option(DAWN_ENABLE_NULL "Enable compilation of the Null backend" ON) 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_DESKTOP_GL "Enable compilation of the OpenGL backend" ${ENABLE_DESKTOP_GL})
option(DAWN_ENABLE_OPENGLES "Enable compilation of the OpenGL ES backend" ${ENABLE_OPENGLES})
option(DAWN_ENABLE_VULKAN "Enable compilation of the Vulkan backend" ${ENABLE_VULKAN}) option(DAWN_ENABLE_VULKAN "Enable compilation of the Vulkan backend" ${ENABLE_VULKAN})
option(DAWN_ALWAYS_ASSERT "Enable assertions on all build types" OFF) option(DAWN_ALWAYS_ASSERT "Enable assertions on all build types" OFF)
option(DAWN_USE_X11 "Enable support for X11 surface" ${USE_X11}) option(DAWN_USE_X11 "Enable support for X11 surface" ${USE_X11})
@ -99,6 +102,11 @@ set(DAWN_SPIRV_HEADERS_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-deps/spirv-headers/sr
set(DAWN_SPIRV_TOOLS_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-deps/spirv-tools/src" CACHE STRING "Directory in which to find SPIRV-Tools") set(DAWN_SPIRV_TOOLS_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-deps/spirv-tools/src" 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") set(DAWN_TINT_DIR "${DAWN_THIRD_PARTY_DIR}/tint" CACHE STRING "Directory in which to find Tint")
# Much of the backend code is shared among desktop OpenGL and OpenGL ES
if (${DAWN_ENABLE_DESKTOP_GL} OR ${DAWN_ENABLE_OPENGLES})
set(DAWN_ENABLE_OPENGL ON)
endif()
################################################################################ ################################################################################
# Dawn's public and internal "configs" # Dawn's public and internal "configs"
################################################################################ ################################################################################
@ -131,6 +139,12 @@ endif()
if (DAWN_ENABLE_NULL) if (DAWN_ENABLE_NULL)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_NULL") target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_NULL")
endif() endif()
if (DAWN_ENABLE_DESKTOP_GL)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_DESKTOP_GL")
endif()
if (DAWN_ENABLE_OPENGLES)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_OPENGLES")
endif()
if (DAWN_ENABLE_OPENGL) if (DAWN_ENABLE_OPENGL)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_OPENGL") target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_OPENGL")
endif() endif()