1e8556ba3Sopenharmony_ci# ~~~
2e8556ba3Sopenharmony_ci# Copyright 2022-2023 The Khronos Group Inc.
3e8556ba3Sopenharmony_ci# Copyright 2022-2023 Valve Corporation
4e8556ba3Sopenharmony_ci# Copyright 2022-2023 LunarG, Inc.
5e8556ba3Sopenharmony_ci#
6e8556ba3Sopenharmony_ci# SPDX-License-Identifier: Apache-2.0
7e8556ba3Sopenharmony_ci# ~~~
8e8556ba3Sopenharmony_cicmake_minimum_required(VERSION 3.14.2)
9e8556ba3Sopenharmony_ci
10e8556ba3Sopenharmony_ciproject(API LANGUAGES C)
11e8556ba3Sopenharmony_ci
12e8556ba3Sopenharmony_ciif (FIND_PACKAGE_TESTING)
13e8556ba3Sopenharmony_ci    find_package(VulkanHeaders REQUIRED CONFIG)
14e8556ba3Sopenharmony_cielse()
15e8556ba3Sopenharmony_ci    add_subdirectory(../../ ${CMAKE_CURRENT_BINARY_DIR}/headers)
16e8556ba3Sopenharmony_ciendif()
17e8556ba3Sopenharmony_ci
18e8556ba3Sopenharmony_ciif (NOT TARGET Vulkan::Headers)
19e8556ba3Sopenharmony_ci    message(FATAL_ERROR "Vulkan::Headers target not defined")
20e8556ba3Sopenharmony_ciendif()
21e8556ba3Sopenharmony_ci
22e8556ba3Sopenharmony_ciif (FIND_PACKAGE_TESTING)
23e8556ba3Sopenharmony_ci    if (NOT DEFINED VulkanHeaders_VERSION)
24e8556ba3Sopenharmony_ci        message(FATAL_ERROR "VulkanHeaders_VERSION not defined!")
25e8556ba3Sopenharmony_ci    endif()
26e8556ba3Sopenharmony_ci    message(STATUS "VulkanHeaders_VERSION = ${VulkanHeaders_VERSION}")
27e8556ba3Sopenharmony_ciendif()
28e8556ba3Sopenharmony_ci
29e8556ba3Sopenharmony_ciif (NOT FIND_PACKAGE_TESTING)
30e8556ba3Sopenharmony_ci    # Consuming vulkan-headers via add_subdirectory should NOT add installation code to the parent CMake project.
31e8556ba3Sopenharmony_ci    if (DEFINED CMAKE_INSTALL_INCLUDEDIR)
32e8556ba3Sopenharmony_ci        message(FATAL_ERROR "CMAKE_INSTALL_INCLUDEDIR was defined!")
33e8556ba3Sopenharmony_ci    endif()
34e8556ba3Sopenharmony_ci
35e8556ba3Sopenharmony_ci    # NOTE: Some users may not be using the namespace target.
36e8556ba3Sopenharmony_ci    # Don't accidentally break them unless we have to.
37e8556ba3Sopenharmony_ci    if (NOT TARGET Vulkan-Headers)
38e8556ba3Sopenharmony_ci        message(FATAL_ERROR "Backcompat for Vulkan-Headers target broken!")
39e8556ba3Sopenharmony_ci    endif()
40e8556ba3Sopenharmony_ciendif()
41e8556ba3Sopenharmony_ci
42e8556ba3Sopenharmony_ciset(CMAKE_C_STANDARD 99)
43e8556ba3Sopenharmony_ciset(CMAKE_C_STANDARD_REQUIRED ON)
44e8556ba3Sopenharmony_ciset(CMAKE_C_EXTENSIONS OFF)
45e8556ba3Sopenharmony_ci
46e8556ba3Sopenharmony_ciif(${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)")
47e8556ba3Sopenharmony_ci    add_compile_options(
48e8556ba3Sopenharmony_ci        -Wpedantic
49e8556ba3Sopenharmony_ci        -Wall
50e8556ba3Sopenharmony_ci        -Wextra
51e8556ba3Sopenharmony_ci        -Werror
52e8556ba3Sopenharmony_ci    )
53e8556ba3Sopenharmony_ciendif()
54e8556ba3Sopenharmony_ci
55e8556ba3Sopenharmony_ciif (MSVC)
56e8556ba3Sopenharmony_ci    add_compile_options(
57e8556ba3Sopenharmony_ci        /W4
58e8556ba3Sopenharmony_ci        /permissive-
59e8556ba3Sopenharmony_ci        /WX
60e8556ba3Sopenharmony_ci    )
61e8556ba3Sopenharmony_ciendif()
62e8556ba3Sopenharmony_ci
63e8556ba3Sopenharmony_ci# Test the non-API headers provided by this repo
64e8556ba3Sopenharmony_ci# NOTE: For us testing just means that these header files compile
65e8556ba3Sopenharmony_ci# with reasonable warnings.
66e8556ba3Sopenharmony_ci
67e8556ba3Sopenharmony_ci# vk_icd.h
68e8556ba3Sopenharmony_ciadd_library(vk_icd MODULE ../vk_icd.c)
69e8556ba3Sopenharmony_citarget_link_libraries(vk_icd PRIVATE Vulkan::Headers)
70e8556ba3Sopenharmony_ci
71e8556ba3Sopenharmony_ci# vk_layer.h
72e8556ba3Sopenharmony_ciadd_library(vk_layer MODULE ../vk_layer.c)
73e8556ba3Sopenharmony_citarget_link_libraries(vk_layer PRIVATE Vulkan::Headers)
74