Add initial CMakeLists.txt files

Adds CMake support for:
 - Generating the Dawn headers and C++ wrappers
 - libdawn_wire
 - libdawn_native with the Metal backend for now
 - All the examples.

Bug: dawn:333

Change-Id: I6ffbe090b0bd21d6a805c03a507ad51fda0275ca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15720
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Corentin Wallez
2020-02-05 17:16:05 +00:00
committed by Commit Bot service account
parent 47b15048a1
commit 7fe6efba4a
11 changed files with 928 additions and 10 deletions

48
src/common/CMakeLists.txt Normal file
View File

@@ -0,0 +1,48 @@
# Copyright 2020 The Dawn Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
add_library(dawn_common STATIC ${DAWN_DUMMY_FILE})
target_sources(dawn_common PRIVATE
"Assert.cpp"
"Assert.h"
"BitSetIterator.h"
"Compiler.h"
"Constants.h"
"DynamicLib.cpp"
"DynamicLib.h"
"GPUInfo.cpp"
"GPUInfo.h"
"HashUtils.h"
"Log.cpp"
"Log.h"
"Math.cpp"
"Math.h"
"Platform.h"
"Result.cpp"
"Result.h"
"Serial.h"
"SerialMap.h"
"SerialQueue.h"
"SerialStorage.h"
"SwapChainUtils.h"
"SystemUtils.cpp"
"SystemUtils.h"
"vulkan_platform.h"
"windows_with_undefs.h"
"xlib_with_undefs.h"
)
target_link_libraries(dawn_common PRIVATE dawn_internal_config)
# TODO Android Log support
# TODO Vulkan headers support

75
src/dawn/CMakeLists.txt Normal file
View File

@@ -0,0 +1,75 @@
# Copyright 2020 The Dawn Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
# Dawn headers
###############################################################################
DawnJSONGenerator(
TARGET "dawn_headers"
PRINT_NAME "Dawn headers"
RESULT_VARIABLE "DAWN_HEADERS_GEN_SOURCES"
)
add_library(dawn_headers INTERFACE)
target_sources(dawn_headers INTERFACE
"${DAWN_INCLUDE_DIR}/dawn/dawn_wsi.h"
${DAWN_HEADERS_GEN_SOURCES}
)
target_link_libraries(dawn_headers INTERFACE dawn_public_config)
###############################################################################
# Dawn C++ headers
###############################################################################
DawnJSONGenerator(
TARGET "dawncpp_headers"
PRINT_NAME "Dawn C++ headers"
RESULT_VARIABLE "DAWNCPP_HEADERS_GEN_SOURCES"
)
add_library(dawncpp_headers INTERFACE)
target_sources(dawncpp_headers INTERFACE
"${DAWN_INCLUDE_DIR}/dawn/EnumClassBitmasks.h"
${DAWNCPP_HEADERS_GEN_SOURCES}
)
target_link_libraries(dawncpp_headers INTERFACE dawn_headers)
###############################################################################
# Dawn C++ wrapper
###############################################################################
DawnJSONGenerator(
TARGET "dawncpp"
PRINT_NAME "Dawn C++ wrapper"
RESULT_VARIABLE "DAWNCPP_GEN_SOURCES"
)
add_library(dawncpp STATIC ${DAWN_DUMMY_FILE})
target_sources(dawncpp PRIVATE ${DAWNCPP_GEN_SOURCES})
target_link_libraries(dawncpp PUBLIC dawncpp_headers)
###############################################################################
# libdawn_proc
###############################################################################
DawnJSONGenerator(
TARGET "dawn_proc"
PRINT_NAME "Dawn C++ wrapper"
RESULT_VARIABLE "DAWNPROC_GEN_SOURCES"
)
add_library(dawn_proc STATIC ${DAWN_DUMMY_FILE})
target_sources(dawn_proc PRIVATE ${DAWNPROC_GEN_SOURCES})
target_link_libraries(dawn_proc PUBLIC dawn_headers)

View File

@@ -0,0 +1,237 @@
# Copyright 2020 The Dawn Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
DawnJSONGenerator(
TARGET "dawn_native_utils"
PRINT_NAME "Dawn native utilities"
RESULT_VARIABLE "DAWN_NATIVE_UTILS_GEN_SOURCES"
)
add_library(dawn_native STATIC ${DAWN_DUMMY_FILE})
target_sources(dawn_native PRIVATE
"${DAWN_INCLUDE_DIR}/dawn_native/DawnNative.h"
"${DAWN_INCLUDE_DIR}/dawn_native/dawn_native_export.h"
${DAWN_NATIVE_UTILS_GEN_SOURCES}
"Adapter.cpp"
"Adapter.h"
"AttachmentState.cpp"
"AttachmentState.h"
"BackendConnection.cpp"
"BackendConnection.h"
"BindGroup.cpp"
"BindGroup.h"
"BindGroupLayout.cpp"
"BindGroupLayout.h"
"BindGroupTracker.h"
"BuddyAllocator.cpp"
"BuddyAllocator.h"
"BuddyMemoryAllocator.cpp"
"BuddyMemoryAllocator.h"
"Buffer.cpp"
"Buffer.h"
"CachedObject.cpp"
"CachedObject.h"
"CommandAllocator.cpp"
"CommandAllocator.h"
"CommandBuffer.cpp"
"CommandBuffer.h"
"CommandBufferStateTracker.cpp"
"CommandBufferStateTracker.h"
"CommandEncoder.cpp"
"CommandEncoder.h"
"CommandValidation.cpp"
"CommandValidation.h"
"Commands.cpp"
"Commands.h"
"ComputePassEncoder.cpp"
"ComputePassEncoder.h"
"ComputePipeline.cpp"
"ComputePipeline.h"
"Device.cpp"
"Device.h"
"DynamicUploader.cpp"
"DynamicUploader.h"
"EncodingContext.cpp"
"EncodingContext.h"
"Error.cpp"
"Error.h"
"ErrorData.cpp"
"ErrorData.h"
"ErrorInjector.cpp"
"ErrorInjector.h"
"ErrorScope.cpp"
"ErrorScope.h"
"ErrorScopeTracker.cpp"
"ErrorScopeTracker.h"
"Extensions.cpp"
"Extensions.h"
"Fence.cpp"
"Fence.h"
"FenceSignalTracker.cpp"
"FenceSignalTracker.h"
"Format.cpp"
"Format.h"
"Forward.h"
"Instance.cpp"
"Instance.h"
"ObjectBase.cpp"
"ObjectBase.h"
"PassResourceUsage.h"
"PassResourceUsageTracker.cpp"
"PassResourceUsageTracker.h"
"PerStage.cpp"
"PerStage.h"
"Pipeline.cpp"
"Pipeline.h"
"PipelineLayout.cpp"
"PipelineLayout.h"
"ProgrammablePassEncoder.cpp"
"ProgrammablePassEncoder.h"
"Queue.cpp"
"Queue.h"
"RefCounted.cpp"
"RefCounted.h"
"RenderBundle.cpp"
"RenderBundle.h"
"RenderBundleEncoder.cpp"
"RenderBundleEncoder.h"
"RenderEncoderBase.cpp"
"RenderEncoderBase.h"
"RenderPassEncoder.cpp"
"RenderPassEncoder.h"
"RenderPipeline.cpp"
"RenderPipeline.h"
"ResourceHeap.h"
"ResourceHeapAllocator.h"
"ResourceMemoryAllocation.cpp"
"ResourceMemoryAllocation.h"
"RingBufferAllocator.cpp"
"RingBufferAllocator.h"
"Sampler.cpp"
"Sampler.h"
"ShaderModule.cpp"
"ShaderModule.h"
"StagingBuffer.cpp"
"StagingBuffer.h"
"Surface.cpp"
"Surface.h"
"SwapChain.cpp"
"SwapChain.h"
"Texture.cpp"
"Texture.h"
"ToBackend.h"
"Toggles.cpp"
"Toggles.h"
"dawn_platform.h"
)
target_link_libraries(dawn_native
PUBLIC dawncpp_headers
PRIVATE dawn_common
dawn_platform
dawn_internal_config
shaderc_spvc
spirv-cross-core
)
if (DAWN_ENABLE_D3D12)
#TODO
endif()
if (DAWN_ENABLE_METAL)
target_sources(dawn_native PRIVATE
"${DAWN_INCLUDE_DIR}/dawn_native/MetalBackend.h"
"Surface_metal.mm"
"metal/BackendMTL.h"
"metal/BackendMTL.mm"
"metal/BufferMTL.h"
"metal/BufferMTL.mm"
"metal/CommandBufferMTL.h"
"metal/CommandBufferMTL.mm"
"metal/CommandRecordingContext.h"
"metal/CommandRecordingContext.mm"
"metal/ComputePipelineMTL.h"
"metal/ComputePipelineMTL.mm"
"metal/DeviceMTL.h"
"metal/DeviceMTL.mm"
"metal/Forward.h"
"metal/PipelineLayoutMTL.h"
"metal/PipelineLayoutMTL.mm"
"metal/QueueMTL.h"
"metal/QueueMTL.mm"
"metal/RenderPipelineMTL.h"
"metal/RenderPipelineMTL.mm"
"metal/SamplerMTL.h"
"metal/SamplerMTL.mm"
"metal/ShaderModuleMTL.h"
"metal/ShaderModuleMTL.mm"
"metal/StagingBufferMTL.h"
"metal/StagingBufferMTL.mm"
"metal/SwapChainMTL.h"
"metal/SwapChainMTL.mm"
"metal/TextureMTL.h"
"metal/TextureMTL.mm"
"metal/UtilsMetal.h"
"metal/UtilsMetal.mm"
)
target_link_libraries(dawn_native PRIVATE
"-framework Cocoa"
"-framework IOKit"
"-framework IOSurface"
"-framework QuartzCore"
)
endif()
if (DAWN_ENABLE_NULL)
target_sources(dawn_native PRIVATE
"${DAWN_INCLUDE_DIR}/dawn_native/NullBackend.h"
"null/DeviceNull.cpp"
"null/DeviceNull.h"
)
endif()
if (DAWN_ENABLE_OPENGL)
DawnGenerator(
SCRIPT "${Dawn_SOURCE_DIR}/generator/opengl_loader_generator.py"
PRINT_NAME "OpenGL function loader"
ARGS "--gl-xml"
"${Dawn_SOURCE_DIR}/third_party/khronos/gl.xml"
"--supported-extensions"
"${Dawn_SOURCE_DIR}/src/dawn_native/opengl/supported_extensions.json"
RESULT_VARIABLE "DAWN_NATIVE_OPENGL_AUTOGEN_SOURCES"
)
# TODO
endif()
if (DAWN_ENABLE_VULKAN)
# TODO
endif()
# TODO how to do the component build in CMake?
target_sources(dawn_native PRIVATE "DawnNative.cpp")
if (DAWN_ENABLE_D3D12)
target_sources(dawn_native PRIVATE "d3d12/D3D12Backend.cpp")
endif()
if (DAWN_ENABLE_METAL)
target_sources(dawn_native PRIVATE "metal/MetalBackend.mm")
endif()
if (DAWN_ENABLE_NULL)
target_sources(dawn_native PRIVATE "null/NullBackend.cpp")
endif()
if (DAWN_ENABLE_OPENGL)
target_sources(dawn_native PRIVATE "opengl/OpenGLBackend.cpp")
endif()
if (DAWN_ENABLE_VULKAN)
target_sources(dawn_native PRIVATE "vulkan/VulkanBackend.cpp")
endif()

View File

@@ -0,0 +1,22 @@
# Copyright 2020 The Dawn Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
add_library(dawn_platform STATIC ${DAWN_DUMMY_FILE})
target_sources(dawn_platform PRIVATE
"${DAWN_INCLUDE_DIR}/dawn_platform/DawnPlatform.h"
"tracing/EventTracer.cpp"
"tracing/EventTracer.h"
"tracing/TraceEvent.h"
)
target_link_libraries(dawn_platform PRIVATE dawn_internal_config dawn_common)

View File

@@ -0,0 +1,57 @@
# Copyright 2020 The Dawn Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
DawnJSONGenerator(
TARGET "dawn_wire"
PRINT_NAME "Dawn wire"
RESULT_VARIABLE "DAWN_WIRE_GEN_SOURCES"
)
add_library(dawn_wire STATIC ${DAWN_DUMMY_FILE})
target_sources(dawn_wire PRIVATE
"${DAWN_INCLUDE_DIR}/dawn_wire/Wire.h"
"${DAWN_INCLUDE_DIR}/dawn_wire/WireClient.h"
"${DAWN_INCLUDE_DIR}/dawn_wire/WireServer.h"
"${DAWN_INCLUDE_DIR}/dawn_wire/dawn_wire_export.h"
${DAWN_WIRE_GEN_SOURCES}
"WireClient.cpp"
"WireDeserializeAllocator.cpp"
"WireDeserializeAllocator.h"
"WireServer.cpp"
"client/ApiObjects.h"
"client/ApiProcs.cpp"
"client/Buffer.cpp"
"client/Buffer.h"
"client/Client.cpp"
"client/Client.h"
"client/ClientDoers.cpp"
"client/ClientInlineMemoryTransferService.cpp"
"client/Device.cpp"
"client/Device.h"
"client/Fence.cpp"
"client/Fence.h"
"client/ObjectAllocator.h"
"server/ObjectStorage.h"
"server/Server.cpp"
"server/Server.h"
"server/ServerBuffer.cpp"
"server/ServerDevice.cpp"
"server/ServerFence.cpp"
"server/ServerInlineMemoryTransferService.cpp"
"server/ServerQueue.cpp"
)
target_link_libraries(dawn_wire
PUBLIC dawn_headers
PRIVATE dawn_common dawn_internal_config
)

78
src/utils/CMakeLists.txt Normal file
View File

@@ -0,0 +1,78 @@
# Copyright 2020 The Dawn Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
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"
"SystemUtils.cpp"
"SystemUtils.h"
"TerribleCommandBuffer.cpp"
"TerribleCommandBuffer.h"
"Timer.h"
"WGPUHelpers.cpp"
"WGPUHelpers.h"
)
target_link_libraries(dawn_utils
PUBLIC dawncpp_headers
PRIVATE dawn_internal_config
dawn_common
dawn_native
dawn_wire
shaderc
glfw
)
if(WIN32)
target_sources(dawn_utils PRIVATE "WindowsTimer.cpp")
elseif(APPLE)
target_sources(dawn_utils PRIVATE
"OSXTimer.cpp"
"ObjCUtils.h"
"ObjCUtils.mm"
)
target_link_libraries(dawn_utils PRIVATE "-framework QuartzCore")
elseif(UNIX)
target_sources(dawn_utils PRIVATE "PosixTimer.cpp")
endif()
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()
if (DAWN_ENABLE_NULL)
target_sources(dawn_utils PRIVATE "NullBinding.cpp")
endif()
if (DAWN_ENABLE_OPENGL)
target_sources(dawn_utils PRIVATE "OpenGLBinding.cpp")
endif()
if (DAWN_ENABLE_VULKAN)
target_sources(dawn_utils PRIVATE "VulkanBinding.cpp")
endif()