Add UWP compilation support in CMake

Set BUILD_EXAMPLE to OFF in UWP.
Disable Vulkan in UWP.
Compile GLFW related sources only on supported platform.
Remove linking to user32.lib in UWP.
Add linking to dxgi.lib only in debug configuration.
Use EmptyDebugLogger in UWP.

Bug: dawn:766

Change-Id: I3e6149058048d1b597267dfb9d63342b6a54e0af
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/55260
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
陈俊嘉 2021-06-24 07:00:16 +00:00 committed by Dawn LUCI CQ
parent 1af81e3128
commit b2bc57ad22
3 changed files with 60 additions and 24 deletions

View File

@ -53,9 +53,14 @@ set(ENABLE_METAL OFF)
set(ENABLE_OPENGL OFF)
set(ENABLE_VULKAN OFF)
set(USE_X11 OFF)
set(BUILD_EXAMPLE OFF)
if (WIN32)
set(ENABLE_D3D12 ON)
if (not WINDOWS_STORE)
# Enable Vulkan in win32 compilation only
# since UWP only supports d3d
set(ENABLE_VULKAN ON)
endif()
elseif(APPLE)
set(ENABLE_METAL ON)
elseif(UNIX)
@ -64,6 +69,16 @@ elseif(UNIX)
set(USE_X11 ON)
endif()
# GLFW is not supported in UWP
if((WIN32 AND NOT WINDOWS_STORE) OR UNIX)
set(DAWN_SUPPORTS_GLFW_FOR_WINDOWING ON)
endif()
# Current examples are depend on GLFW
if (DAWN_SUPPORTS_GLFW_FOR_WINDOWING)
set(BUILD_EXAMPLE ON)
endif()
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_NULL "Enable compilation of the Null backend" ON)
@ -72,7 +87,7 @@ option(DAWN_ENABLE_VULKAN "Enable compilation of the Vulkan backend" ${ENABLE_VU
option(DAWN_ALWAYS_ASSERT "Enable assertions on all build types" OFF)
option(DAWN_USE_X11 "Enable support for X11 surface" ${USE_X11})
option(DAWN_BUILD_EXAMPLES "Enables building Dawn's exmaples" ON)
option(DAWN_BUILD_EXAMPLES "Enables building Dawn's exmaples" ${BUILD_EXAMPLE})
set(DAWN_THIRD_PARTY_DIR "${Dawn_SOURCE_DIR}/third_party" CACHE STRING "Directory in which to find third-party dependencies.")

View File

@ -191,10 +191,22 @@ if (DAWN_USE_X11)
)
endif()
if (WIN32)
# Only win32 app needs to link with user32.lib
# In UWP, all availiable APIs are defined in WindowsApp.lib
# and is automatically linked when WINDOWS_STORE set
if (WIN32 AND NOT WINDOWS_STORE)
target_link_libraries(dawn_native PRIVATE user32.lib)
endif()
# DXGIGetDebugInterface1 is defined in dxgi.lib
# But this API is tagged as a development-only capability
# which implies that linking to this function will cause
# the application to fail Windows store certification
# So we only link to it in debug build when compiling for UWP.
# In win32 we load dxgi.dll using LoadLibrary
# so no need for static linking.
target_link_libraries(dawn_native PRIVATE debug dxgi.lib)
if (DAWN_ENABLE_D3D12)
target_sources(dawn_native PRIVATE
"${DAWN_INCLUDE_DIR}/dawn_native/D3D12Backend.h"

View File

@ -14,14 +14,10 @@
add_library(dawn_utils STATIC ${DAWN_DUMMY_FILE})
target_sources(dawn_utils PRIVATE
"BackendBinding.cpp"
"BackendBinding.h"
"ComboRenderBundleEncoderDescriptor.cpp"
"ComboRenderBundleEncoderDescriptor.h"
"ComboRenderPipelineDescriptor.cpp"
"ComboRenderPipelineDescriptor.h"
"GLFWUtils.cpp"
"GLFWUtils.h"
"PlatformDebugLogger.h"
"SystemUtils.cpp"
"SystemUtils.h"
@ -48,7 +44,7 @@ target_link_libraries(dawn_utils
glfw
)
if(WIN32)
if(WIN32 AND NOT WINDOWS_STORE)
target_sources(dawn_utils PRIVATE "WindowsDebugLogger.cpp")
else()
target_sources(dawn_utils PRIVATE "EmptyDebugLogger.cpp")
@ -67,26 +63,39 @@ elseif(UNIX)
target_sources(dawn_utils PRIVATE "PosixTimer.cpp")
endif()
if (DAWN_ENABLE_D3D12)
target_sources(dawn_utils PRIVATE "D3D12Binding.cpp")
if (DAWN_ENABLE_METAL)
target_link_libraries(dawn_utils PRIVATE "-framework Metal")
endif()
if (DAWN_ENABLE_METAL)
if(DAWN_SUPPORTS_GLFW_FOR_WINDOWING)
target_sources(dawn_utils PRIVATE
"BackendBinding.cpp"
"BackendBinding.h"
"GLFWUtils.cpp"
"GLFWUtils.h"
)
target_link_libraries(dawn_utils PRIVATE glfw)
if (DAWN_ENABLE_D3D12)
target_sources(dawn_utils PRIVATE "D3D12Binding.cpp")
endif()
if (DAWN_ENABLE_METAL)
target_sources(dawn_utils PRIVATE
"GLFWUtils_metal.mm"
"MetalBinding.mm"
)
target_link_libraries(dawn_utils PRIVATE "-framework Metal")
endif()
endif()
if (DAWN_ENABLE_NULL)
if (DAWN_ENABLE_NULL)
target_sources(dawn_utils PRIVATE "NullBinding.cpp")
endif()
endif()
if (DAWN_ENABLE_OPENGL)
if (DAWN_ENABLE_OPENGL)
target_sources(dawn_utils PRIVATE "OpenGLBinding.cpp")
endif()
endif()
if (DAWN_ENABLE_VULKAN)
if (DAWN_ENABLE_VULKAN)
target_sources(dawn_utils PRIVATE "VulkanBinding.cpp")
endif()
endif()