mirror of
https://github.com/KhronosGroup/Vulkan-Headers.git
synced 2025-04-09 14:37:00 +00:00
cmake: Add VULKAN_HEADERS_INSTALL option
Allows add_subdirectory users to install vulkan-headers
This commit is contained in:
parent
9b834aa443
commit
be224ba56e
3 changed files with 45 additions and 3 deletions
19
.github/workflows/linux.yml
vendored
19
.github/workflows/linux.yml
vendored
|
@ -19,6 +19,9 @@ on:
|
|||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
CMAKE_GENERATOR: Ninja
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
@ -32,7 +35,7 @@ jobs:
|
|||
with:
|
||||
cmakeVersion: 3.17.0
|
||||
- name: Configure Vulkan-Headers
|
||||
run: cmake -S . -B build -G "Ninja"
|
||||
run: cmake -S . -B build
|
||||
- name: Install Vulkan-Headers
|
||||
run: cmake --install build --prefix ${{ github.workspace }}/build/install
|
||||
- name: Test Vulkan-Headers find_package support
|
||||
|
@ -46,7 +49,7 @@ jobs:
|
|||
with:
|
||||
cmakeVersion: 3.25.0
|
||||
- name: Configure Vulkan-Headers
|
||||
run: cmake -S . -B build -D BUILD_TESTS=ON --log-level=DEBUG -G "Ninja"
|
||||
run: cmake -S . -B build -D BUILD_TESTS=ON --log-level=DEBUG
|
||||
- name: Build Vulkan-Headers Tests
|
||||
run: cmake --build build
|
||||
|
||||
|
@ -58,6 +61,16 @@ jobs:
|
|||
with:
|
||||
cmakeVersion: 3.15.0
|
||||
- name: Configure Vulkan-Headers
|
||||
run: cmake -S . -B build/ -G "Ninja" --loglevel=DEBUG
|
||||
run: cmake -S . -B build/ --loglevel=DEBUG
|
||||
- name: Install Vulkan-Headers
|
||||
run: cmake --install build/ --prefix build/install
|
||||
|
||||
ubuntu-cmake-add_subdirectory:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: lukka/get-cmake@latest
|
||||
- name: Test add_subdirectory support
|
||||
run: cmake -S tests/add_subdirectory -B tests/add_subdirectory/build
|
||||
- name: Build
|
||||
run: cmake --build tests/add_subdirectory/build
|
||||
|
|
|
@ -57,7 +57,10 @@ if (PROJECT_IS_TOP_LEVEL)
|
|||
if (BUILD_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(VULKAN_HEADERS_INSTALL "Install Vulkan Headers" ${PROJECT_IS_TOP_LEVEL})
|
||||
if (VULKAN_HEADERS_INSTALL)
|
||||
include(GNUInstallDirs)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
|
|
26
tests/add_subdirectory/CMakeLists.txt
Normal file
26
tests/add_subdirectory/CMakeLists.txt
Normal file
|
@ -0,0 +1,26 @@
|
|||
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()
|
||||
|
||||
# By default installation for a subproject should be disabled.
|
||||
# This makes it easier to consume for most projects.
|
||||
# Consuming the vulkan-headers via add_subdirectory and installing
|
||||
# them is the more niche use case.
|
||||
if (VULKAN_HEADERS_INSTALL)
|
||||
message(FATAL_ERROR "VULKAN_HEADERS_INSTALL should be OFF!")
|
||||
endif()
|
||||
|
||||
add_library(foobar STATIC)
|
||||
|
||||
target_link_libraries(foobar PRIVATE Vulkan::Headers)
|
||||
|
||||
target_sources(foobar PRIVATE
|
||||
../vk_icd.c
|
||||
../vk_layer.c
|
||||
)
|
Loading…
Add table
Reference in a new issue