mirror of
https://github.com/KhronosGroup/Vulkan-Headers
synced 2024-11-21 06:26:00 -07:00
Use ctest for integration testing
This commit is contained in:
parent
af4fb97d7b
commit
a32b2b412b
6 changed files with 102 additions and 129 deletions
40
.github/workflows/ci.yml
vendored
40
.github/workflows/ci.yml
vendored
|
@ -17,50 +17,18 @@ permissions:
|
|||
contents: read
|
||||
|
||||
jobs:
|
||||
build-tests:
|
||||
name: BUILD_TESTS=ON ${{ matrix.os }}
|
||||
cmake:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
||||
cmake-version: [ '3.15', 'latest']
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: lukka/get-cmake@latest
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
- run: cmake -S . -B build -D BUILD_TESTS=ON --log-level=DEBUG
|
||||
- run: cmake --build build
|
||||
|
||||
test-cmake-minimum:
|
||||
name: Test CMake minimum
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: lukka/get-cmake@latest
|
||||
with:
|
||||
cmakeVersion: 3.15.0
|
||||
- run: cmake -S . -B build/ --loglevel=DEBUG
|
||||
- run: cmake --install build/ --prefix build/install
|
||||
|
||||
find_package:
|
||||
name: Test find_package
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: lukka/get-cmake@latest
|
||||
with:
|
||||
cmakeVersion: 3.17.0
|
||||
- run: cmake -S . -B build
|
||||
- run: cmake --install build --prefix ${{ github.workspace }}/build/install
|
||||
- run: cmake -S tests/find_package -B build/tests/find_package -D CMAKE_PREFIX_PATH=${{ github.workspace }}/build/install
|
||||
|
||||
add_subdirectory:
|
||||
name: Test add_subdirectory
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: lukka/get-cmake@latest
|
||||
- run: cmake -S tests/add_subdirectory -B tests/add_subdirectory/build
|
||||
- run: cmake --build tests/add_subdirectory/build
|
||||
- run: cmake -S . -B build -D BUILD_TESTS=ON --log-level=DEBUG -G Ninja
|
||||
- run: ctest --test-dir build --output-on-failure
|
||||
|
||||
reuse:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
@ -50,6 +50,7 @@ endif()
|
|||
if (PROJECT_IS_TOP_LEVEL)
|
||||
option(BUILD_TESTS "Build the tests")
|
||||
if (BUILD_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -6,41 +6,32 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
# ~~~
|
||||
|
||||
# Test the non-API headers provided by this repo
|
||||
# NOTE: For us testing just means that these header files compile
|
||||
# with reasonable warnings.
|
||||
|
||||
message(STATUS "${PROJECT_NAME} = ${PROJECT_VERSION}")
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_C_EXTENSIONS OFF)
|
||||
|
||||
if(${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)")
|
||||
add_compile_options(
|
||||
-Wpedantic
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
)
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24")
|
||||
set(fresh "--fresh")
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
add_compile_options(
|
||||
/W4
|
||||
/permissive-
|
||||
/WX
|
||||
)
|
||||
endif()
|
||||
# Test add_subdirectory suppport
|
||||
add_test(NAME integration.add_subdirectory
|
||||
COMMAND ${CMAKE_CTEST_COMMAND}
|
||||
--build-and-test ${CMAKE_CURRENT_LIST_DIR}/integration
|
||||
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory
|
||||
--build-generator ${CMAKE_GENERATOR}
|
||||
--build-options -DFIND_PACKAGE_TESTING=OFF "${fresh}"
|
||||
)
|
||||
|
||||
# vk_icd.h
|
||||
add_library(vk_icd MODULE vk_icd.c)
|
||||
target_link_libraries(vk_icd PRIVATE Vulkan::Headers)
|
||||
set(test_install_dir "${CMAKE_CURRENT_BINARY_DIR}/install")
|
||||
add_test(NAME integration.install
|
||||
COMMAND ${CMAKE_COMMAND} --install ${VULKAN_HEADERS_BINARY_DIR} --prefix ${test_install_dir}
|
||||
)
|
||||
|
||||
# vk_layer.h
|
||||
add_library(vk_layer MODULE vk_layer.c)
|
||||
target_link_libraries(vk_layer PRIVATE Vulkan::Headers)
|
||||
# Test find_package suppport
|
||||
add_test(NAME integration.find_package
|
||||
COMMAND ${CMAKE_CTEST_COMMAND}
|
||||
--build-and-test ${CMAKE_CURRENT_LIST_DIR}/integration
|
||||
${CMAKE_CURRENT_BINARY_DIR}/find_package
|
||||
--build-generator ${CMAKE_GENERATOR}
|
||||
--build-options -DFIND_PACKAGE_TESTING=ON -DCMAKE_PREFIX_PATH=${test_install_dir} "${fresh}"
|
||||
)
|
||||
|
||||
if (NOT TARGET Vulkan-Headers)
|
||||
message(FATAL_ERROR "Backcompat for Vulkan-Headers target broken!")
|
||||
endif()
|
||||
# Installing comes before testing
|
||||
set_tests_properties(integration.find_package PROPERTIES DEPENDS integration.install)
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
# ~~~
|
||||
# Copyright 2022-2023 The Khronos Group Inc.
|
||||
# Copyright 2022-2023 Valve Corporation
|
||||
# Copyright 2022-2023 LunarG, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# ~~~
|
||||
cmake_minimum_required(VERSION 3.14.2)
|
||||
|
||||
project(TEST_VULKAN_HEADERS_ADD_SUBDIRECTORY_SUPPORT LANGUAGES C)
|
||||
|
||||
add_subdirectory(../../ ${CMAKE_CURRENT_BINARY_DIR}/headers)
|
||||
|
||||
if (NOT TARGET Vulkan::Headers)
|
||||
message(FATAL_ERROR "Vulkan::Headers target not defined")
|
||||
endif()
|
||||
|
||||
# Consuming vulkan-headers via add_subdirectory should NOT add installation code to the parent CMake project.
|
||||
if (DEFINED CMAKE_INSTALL_INCLUDEDIR)
|
||||
message(FATAL_ERROR "CMAKE_INSTALL_INCLUDEDIR was defined!")
|
||||
endif()
|
||||
|
||||
add_library(foobar STATIC)
|
||||
|
||||
target_link_libraries(foobar PRIVATE Vulkan::Headers)
|
||||
|
||||
target_sources(foobar PRIVATE
|
||||
../vk_icd.c
|
||||
../vk_layer.c
|
||||
)
|
|
@ -1,30 +0,0 @@
|
|||
# ~~~
|
||||
# Copyright 2022-2023 The Khronos Group Inc.
|
||||
# Copyright 2022-2023 Valve Corporation
|
||||
# Copyright 2022-2023 LunarG, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# ~~~
|
||||
cmake_minimum_required(VERSION 3.14.2)
|
||||
|
||||
project(TEST_VULKAN_HEADERS_FIND_PACKAGE_SUPPORT LANGUAGES C)
|
||||
|
||||
find_package(VulkanHeaders REQUIRED CONFIG)
|
||||
|
||||
if (NOT TARGET Vulkan::Headers)
|
||||
message(FATAL_ERROR "Vulkan::Headers target not defined")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED VulkanHeaders_VERSION)
|
||||
message(FATAL_ERROR "VulkanHeaders_VERSION not defined!")
|
||||
endif()
|
||||
message(STATUS "VulkanHeaders_VERSION = ${VulkanHeaders_VERSION}")
|
||||
|
||||
add_library(foobar STATIC)
|
||||
|
||||
target_link_libraries(foobar PRIVATE Vulkan::Headers)
|
||||
|
||||
target_sources(foobar PRIVATE
|
||||
../vk_icd.c
|
||||
../vk_layer.c
|
||||
)
|
73
tests/integration/CMakeLists.txt
Normal file
73
tests/integration/CMakeLists.txt
Normal file
|
@ -0,0 +1,73 @@
|
|||
# ~~~
|
||||
# Copyright 2022-2023 The Khronos Group Inc.
|
||||
# Copyright 2022-2023 Valve Corporation
|
||||
# Copyright 2022-2023 LunarG, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# ~~~
|
||||
cmake_minimum_required(VERSION 3.14.2)
|
||||
|
||||
project(API LANGUAGES C)
|
||||
|
||||
if (FIND_PACKAGE_TESTING)
|
||||
find_package(VulkanHeaders REQUIRED CONFIG)
|
||||
else()
|
||||
add_subdirectory(../../ ${CMAKE_CURRENT_BINARY_DIR}/headers)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET Vulkan::Headers)
|
||||
message(FATAL_ERROR "Vulkan::Headers target not defined")
|
||||
endif()
|
||||
|
||||
if (FIND_PACKAGE_TESTING)
|
||||
if (NOT DEFINED VulkanHeaders_VERSION)
|
||||
message(FATAL_ERROR "VulkanHeaders_VERSION not defined!")
|
||||
endif()
|
||||
message(STATUS "VulkanHeaders_VERSION = ${VulkanHeaders_VERSION}")
|
||||
endif()
|
||||
|
||||
if (NOT FIND_PACKAGE_TESTING)
|
||||
# Consuming vulkan-headers via add_subdirectory should NOT add installation code to the parent CMake project.
|
||||
if (DEFINED CMAKE_INSTALL_INCLUDEDIR)
|
||||
message(FATAL_ERROR "CMAKE_INSTALL_INCLUDEDIR was defined!")
|
||||
endif()
|
||||
|
||||
# NOTE: Some users may not be using the namespace target.
|
||||
# Don't accidentally break them unless we have to.
|
||||
if (NOT TARGET Vulkan-Headers)
|
||||
message(FATAL_ERROR "Backcompat for Vulkan-Headers target broken!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_C_EXTENSIONS OFF)
|
||||
|
||||
if(${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)")
|
||||
add_compile_options(
|
||||
-Wpedantic
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
)
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
add_compile_options(
|
||||
/W4
|
||||
/permissive-
|
||||
/WX
|
||||
)
|
||||
endif()
|
||||
|
||||
# Test the non-API headers provided by this repo
|
||||
# NOTE: For us testing just means that these header files compile
|
||||
# with reasonable warnings.
|
||||
|
||||
# vk_icd.h
|
||||
add_library(vk_icd MODULE ../vk_icd.c)
|
||||
target_link_libraries(vk_icd PRIVATE Vulkan::Headers)
|
||||
|
||||
# vk_layer.h
|
||||
add_library(vk_layer MODULE ../vk_layer.c)
|
||||
target_link_libraries(vk_layer PRIVATE Vulkan::Headers)
|
Loading…
Reference in a new issue