blob: 136c848ff0aab629fa5b1ce77ea93d8fd7c9661f [file] [log] [blame]
Corentin Wallez7fe6efb2020-02-05 17:16:05 +00001# Copyright 2020 The Dawn Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Aleksi Sapon9a106742021-09-28 16:48:01 +000015# Don't build testing in third_party dependencies
16set(BUILD_TESTING OFF)
17
Corentin Wallez7fe6efb2020-02-05 17:16:05 +000018if (NOT TARGET SPIRV-Headers)
Corentin Wallez42450c62020-04-10 17:04:31 +000019 set(SPIRV_HEADERS_SKIP_EXAMPLES ON CACHE BOOL "" FORCE)
20 set(SPIRV_HEADERS_SKIP_INSTALL ON CACHE BOOL "" FORCE)
Corentin Wallez7fe6efb2020-02-05 17:16:05 +000021
22 message(STATUS "Dawn: using SPIRV-Headers at ${DAWN_SPIRV_HEADERS_DIR}")
Aleksi Sapon9a106742021-09-28 16:48:01 +000023 add_subdirectory(${DAWN_SPIRV_HEADERS_DIR} "${CMAKE_CURRENT_BINARY_DIR}/spirv-headers")
Corentin Wallez7fe6efb2020-02-05 17:16:05 +000024endif()
25
26if (NOT TARGET SPIRV-Tools)
Corentin Wallez42450c62020-04-10 17:04:31 +000027 set(SPIRV_SKIP_TESTS ON CACHE BOOL "" FORCE)
28 set(SPIRV_SKIP_EXECUTABLES ON CACHE BOOL "" FORCE)
29 set(SKIP_SPIRV_TOOLS_INSTALL ON CACHE BOOL "" FORCE)
Corentin Wallez7fe6efb2020-02-05 17:16:05 +000030
31 message(STATUS "Dawn: using SPIRV-Tools at ${DAWN_SPIRV_TOOLS_DIR}")
Aleksi Sapon9a106742021-09-28 16:48:01 +000032 add_subdirectory(${DAWN_SPIRV_TOOLS_DIR} "${CMAKE_CURRENT_BINARY_DIR}/spirv-tools")
Corentin Wallez7fe6efb2020-02-05 17:16:05 +000033endif()
34
Alexander Vestinf2556ab2022-03-25 13:18:46 +000035if (NOT TARGET glfw AND DAWN_SUPPORTS_GLFW_FOR_WINDOWING)
Ben Clayton0ecd67a2021-09-23 20:13:53 +000036 set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
37 set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
38 set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
39
40 message(STATUS "Dawn: using GLFW at ${DAWN_GLFW_DIR}")
Aleksi Sapon9a106742021-09-28 16:48:01 +000041 add_subdirectory(${DAWN_GLFW_DIR} "${CMAKE_CURRENT_BINARY_DIR}/glfw")
Ben Clayton0ecd67a2021-09-23 20:13:53 +000042endif()
43
Corentin Walleza9439192021-03-22 21:23:36 +000044if (NOT TARGET libtint)
45 message(STATUS "Dawn: using Tint at ${DAWN_TINT_DIR}")
Stephen White25b3ed12022-02-08 15:32:00 +000046 set(TINT_BUILD_GLSL_WRITER ON)
47 # Don't build the samples because they require glslang and Dawn does not
48 # provide this third_party dependency.
49 set(TINT_BUILD_SAMPLES OFF)
James Price38197e72022-01-11 16:34:55 +000050 # TODO(crbug.com/tint/455): Tint does not currently build with CMake when
51 # BUILD_SHARED_LIBS=1, so always build it as static for now.
52 set(BUILD_SHARED_LIBS_SAVED ${BUILD_SHARED_LIBS})
53 set(BUILD_SHARED_LIBS 0)
Aleksi Sapon9a106742021-09-28 16:48:01 +000054 add_subdirectory(${DAWN_TINT_DIR} "${CMAKE_CURRENT_BINARY_DIR}/tint")
James Price38197e72022-01-11 16:34:55 +000055 set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_SAVED})
dan sinclairbb3d7982020-10-23 13:10:20 +000056endif()
57
Brandon Jonesa04663c2021-09-23 20:36:03 +000058if (NOT TARGET libabsl)
59 message(STATUS "Dawn: using Abseil at ${DAWN_ABSEIL_DIR}")
Aleksi Sapon9a106742021-09-28 16:48:01 +000060 add_subdirectory(${DAWN_ABSEIL_DIR} "${CMAKE_CURRENT_BINARY_DIR}/abseil")
Brandon Jonesa04663c2021-09-23 20:36:03 +000061endif()
62
Corentin Wallez215b5372020-02-15 00:39:13 +000063# Header-only library for khrplatform.h
64add_library(dawn_khronos_platform INTERFACE)
dan sinclairecd46ab2020-10-20 17:43:00 +000065target_sources(dawn_khronos_platform INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/khronos/KHR/khrplatform.h")
66target_include_directories(dawn_khronos_platform INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/khronos")
Corentin Wallezd353ca02020-02-18 02:12:35 +000067
68# Header-only library for Vulkan headers
69add_library(dawn_vulkan_headers INTERFACE)
70target_sources(dawn_vulkan_headers INTERFACE
dan sinclairecd46ab2020-10-20 17:43:00 +000071 "${CMAKE_CURRENT_SOURCE_DIR}/khronos/vulkan/vk_icd.h"
72 "${CMAKE_CURRENT_SOURCE_DIR}/khronos/vulkan/vk_layer.h"
73 "${CMAKE_CURRENT_SOURCE_DIR}/khronos/vulkan/vk_platform.h"
74 "${CMAKE_CURRENT_SOURCE_DIR}/khronos/vulkan/vk_sdk_platform.h"
75 "${CMAKE_CURRENT_SOURCE_DIR}/khronos/vulkan/vulkan.h"
76 "${CMAKE_CURRENT_SOURCE_DIR}/khronos/vulkan/vulkan_core.h"
Corentin Wallezd353ca02020-02-18 02:12:35 +000077)
dan sinclairecd46ab2020-10-20 17:43:00 +000078target_include_directories(dawn_vulkan_headers INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/khronos")