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