2022-04-06 19:37:27 +00:00
# Copyright 2022 The Dawn & Tint Authors
2020-02-05 17:16:05 +00:00
#
# 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.
2021-09-28 16:48:01 +00:00
# Don't build testing in third_party dependencies
set ( BUILD_TESTING OFF )
2020-02-05 17:16:05 +00:00
if ( NOT TARGET SPIRV-Headers )
2020-04-10 17:04:31 +00:00
set ( SPIRV_HEADERS_SKIP_EXAMPLES ON CACHE BOOL "" FORCE )
set ( SPIRV_HEADERS_SKIP_INSTALL ON CACHE BOOL "" FORCE )
2020-02-05 17:16:05 +00:00
message ( STATUS "Dawn: using SPIRV-Headers at ${DAWN_SPIRV_HEADERS_DIR}" )
2021-09-28 16:48:01 +00:00
add_subdirectory ( ${ DAWN_SPIRV_HEADERS_DIR } "${CMAKE_CURRENT_BINARY_DIR}/spirv-headers" )
2020-02-05 17:16:05 +00:00
endif ( )
2022-04-07 20:39:24 +00:00
# Needs to come before SPIR-V Tools
if ( ( ${ TINT_BUILD_SPIRV_TOOLS_FUZZER } OR ${ TINT_BUILD_AST_FUZZER } ) AND
2022-05-16 09:11:21 +00:00
( N O T T A R G E T p r o t o b u f : : l i b p r o t o b u f O R N O T T A R G E T p r o t o b u f : : p r o t o c ) )
set ( protobuf_BUILD_TESTS OFF CACHE BOOL "Controls whether protobuf tests are built" FORCE )
set ( protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Controls whether a protobuf static runtime is built" FORCE )
add_subdirectory ( ${ CMAKE_CURRENT_SOURCE_DIR } /protobuf/cmake )
2022-04-06 19:37:27 +00:00
endif ( )
2020-02-05 17:16:05 +00:00
if ( NOT TARGET SPIRV-Tools )
2020-04-10 17:04:31 +00:00
set ( SPIRV_SKIP_TESTS ON CACHE BOOL "" FORCE )
set ( SPIRV_SKIP_EXECUTABLES ON CACHE BOOL "" FORCE )
set ( SKIP_SPIRV_TOOLS_INSTALL ON CACHE BOOL "" FORCE )
2020-02-05 17:16:05 +00:00
2022-04-06 19:37:27 +00:00
if ( ${ TINT_BUILD_SPV_READER } OR ${ TINT_BUILD_SPV_WRITER } )
2022-05-16 09:11:21 +00:00
set ( SPIRV_SKIP_TESTS ON CACHE BOOL "Controls whether SPIR-V tests are run" FORCE )
set ( SPIRV_WERROR OFF CACHE BOOL OFF FORCE )
if ( ${ TINT_BUILD_SPIRV_TOOLS_FUZZER } )
set ( SPIRV_BUILD_FUZZER ON CACHE BOOL "Controls whether spirv-fuzz is built" FORCE )
endif ( )
2022-04-06 19:37:27 +00:00
endif ( )
2020-02-05 17:16:05 +00:00
message ( STATUS "Dawn: using SPIRV-Tools at ${DAWN_SPIRV_TOOLS_DIR}" )
2022-04-06 19:37:27 +00:00
add_subdirectory ( ${ DAWN_SPIRV_TOOLS_DIR } "${CMAKE_CURRENT_BINARY_DIR}/spirv-tools" EXCLUDE_FROM_ALL )
2020-02-05 17:16:05 +00:00
endif ( )
2022-05-16 09:11:21 +00:00
if ( NOT TARGET glslang AND ${ TINT_BUILD_GLSL_WRITER } AND ${ TINT_BUILD_SAMPLES } )
set ( SKIP_GLSLANG_INSTALL ON CACHE BOOL "" FORCE )
add_subdirectory ( "${DAWN_THIRD_PARTY_DIR}/vulkan-deps/glslang/src" "${CMAKE_CURRENT_BINARY_DIR}/glslang" EXCLUDE_FROM_ALL )
endif ( )
2022-04-06 19:37:27 +00:00
if ( NOT TARGET glfw )
2021-09-23 20:13:53 +00:00
set ( GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE )
set ( GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE )
set ( GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE )
2020-02-05 17:16:05 +00:00
2021-09-23 20:13:53 +00:00
message ( STATUS "Dawn: using GLFW at ${DAWN_GLFW_DIR}" )
2021-09-28 16:48:01 +00:00
add_subdirectory ( ${ DAWN_GLFW_DIR } "${CMAKE_CURRENT_BINARY_DIR}/glfw" )
2021-09-23 20:13:53 +00:00
endif ( )
2020-02-05 17:16:05 +00:00
2021-09-23 20:36:03 +00:00
if ( NOT TARGET libabsl )
message ( STATUS "Dawn: using Abseil at ${DAWN_ABSEIL_DIR}" )
2023-01-07 23:09:14 +00:00
if ( ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) OR
( " $ { C M A K E _ C X X _ C O M P I L E R _ I D } " S T R E Q U A L " A p p l e C l a n g " ) )
add_compile_options (
- W n o - a r r a y - p a r a m e t e r
- W n o - d e p r e c a t e d - b u i l t i n s
- W n o - u n k n o w n - w a r n i n g - o p t i o n
)
endif ( )
2021-09-28 16:48:01 +00:00
add_subdirectory ( ${ DAWN_ABSEIL_DIR } "${CMAKE_CURRENT_BINARY_DIR}/abseil" )
2021-09-23 20:36:03 +00:00
endif ( )
2022-04-02 03:02:40 +00:00
if ( NOT TARGET Vulkan-Headers )
message ( STATUS "Dawn: using Vulkan-Headers at ${DAWN_VULKAN_HEADERS_DIR}" )
add_subdirectory ( ${ DAWN_VULKAN_HEADERS_DIR } "${CMAKE_CURRENT_BINARY_DIR}/vulkan-headers" )
endif ( )
2020-02-15 00:39:13 +00:00
# Header-only library for khrplatform.h
add_library ( dawn_khronos_platform INTERFACE )
2020-10-20 17:43:00 +00:00
target_sources ( dawn_khronos_platform INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/khronos/KHR/khrplatform.h" )
target_include_directories ( dawn_khronos_platform INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/khronos" )
2022-04-06 19:37:27 +00:00
# Header-only library for Vulkan headers
add_library ( dawn_vulkan_headers INTERFACE )
target_sources ( dawn_vulkan_headers INTERFACE
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / k h r o n o s / v u l k a n / v k _ i c d . h "
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / k h r o n o s / v u l k a n / v k _ l a y e r . h "
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / k h r o n o s / v u l k a n / v k _ p l a t f o r m . h "
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / k h r o n o s / v u l k a n / v k _ s d k _ p l a t f o r m . h "
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / k h r o n o s / v u l k a n / v u l k a n . h "
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / k h r o n o s / v u l k a n / v u l k a n _ c o r e . h "
)
target_include_directories ( dawn_vulkan_headers INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/khronos" )
2022-05-16 09:11:21 +00:00
if ( NOT TARGET vk_swiftshader AND ${ DAWN_ENABLE_SWIFTSHADER } )
2022-04-11 16:48:43 +00:00
set ( SWIFTSHADER_BUILD_TESTS OFF CACHE BOOL "" FORCE )
set ( SWIFTSHADER_BUILD_BENCHMARKS OFF CACHE BOOL "" FORCE )
message ( STATUS "Dawn: using Swiftshader at ${DAWN_SWIFTSHADER_DIR}" )
add_subdirectory ( ${ DAWN_SWIFTSHADER_DIR } "${CMAKE_CURRENT_BINARY_DIR}/swiftshader" )
endif ( )
2022-01-18 18:58:16 +00:00
if ( ${ TINT_BUILD_BENCHMARKS } )
2022-05-16 09:11:21 +00:00
set ( BENCHMARK_ENABLE_TESTING FALSE CACHE BOOL FALSE FORCE )
add_subdirectory ( ${ CMAKE_CURRENT_SOURCE_DIR } /benchmark EXCLUDE_FROM_ALL )
2022-01-18 18:58:16 +00:00
endif ( )
2022-05-16 09:11:21 +00:00
if ( NOT TARGET gmock AND ${ TINT_BUILD_TESTS } )
set ( gtest_force_shared_crt ON CACHE BOOL "Controls whether a shared run-time library should be used even when Google Test is built as static library" FORCE )
add_subdirectory ( ${ CMAKE_CURRENT_SOURCE_DIR } /googletest EXCLUDE_FROM_ALL )
2020-06-26 22:29:27 +00:00
endif ( )