Skip to content

CMake: C++20-Module installation and integration testing #538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
with:
cmakeVersion: ${{ matrix.cmake-version }}
- uses: ilammy/msvc-dev-cmd@v1
- run: cmake -S . -B build -D VULKAN_HEADERS_ENABLE_TESTS=ON -D VULKAN_HEADERS_ENABLE_INSTALL=ON -G Ninja
- run: cmake -S . -B build -D VULKAN_HEADERS_ENABLE_TESTS=ON -D VULKAN_HEADERS_ENABLE_INSTALL=ON -G ${{env.CMAKE_GENERATOR}}
- run: cmake --build ./build
- run: cmake --install build/ --prefix build/install
- run: ctest --output-on-failure
Expand All @@ -46,7 +46,7 @@ jobs:
with:
cmakeVersion: ${{ matrix.cmake-version }}
- uses: ilammy/msvc-dev-cmd@v1
- run: cmake -S . -B build -D VULKAN_HEADERS_ENABLE_TESTS=ON -D VULKAN_HEADERS_ENABLE_INSTALL=ON -G Ninja
- run: cmake -S . -B build -D VULKAN_HEADERS_ENABLE_TESTS=ON -D VULKAN_HEADERS_ENABLE_INSTALL=ON -G ${{env.CMAKE_GENERATOR}}
- run: cmake --build ./build
- run: cmake --install build/ --prefix build/install
- run: ctest --output-on-failure
Expand All @@ -68,7 +68,7 @@ jobs:
-D CMAKE_BUILD_TYPE=Release `
-D VULKAN_HEADERS_ENABLE_TESTS=ON `
-D VULKAN_HEADERS_ENABLE_INSTALL=ON `
-G Ninja
-G ${{env.CMAKE_GENERATOR}}
- run: cmake --build ./build
- run: cmake --install build/ --prefix build/install
- run: ctest --output-on-failure
Expand All @@ -95,7 +95,7 @@ jobs:
-D VULKAN_HEADERS_ENABLE_MODULE=ON \
-D VULKAN_HEADERS_ENABLE_MODULE_STD=OFF \
-D CMAKE_CXX_COMPILER=${{ matrix.compiler }} \
-G Ninja
-G ${{env.CMAKE_GENERATOR}}
- run: cmake --build ./build
- run: cmake --install build/ --prefix build/install
- run: CXX=${{ matrix.compiler }} ctest --output-on-failure
Expand All @@ -120,7 +120,7 @@ jobs:
-D VULKAN_HEADERS_ENABLE_INSTALL=ON `
-D VULKAN_HEADERS_ENABLE_MODULE=ON `
-D VULKAN_HEADERS_ENABLE_MODULE_STD=OFF `
-G Ninja
-G ${{env.CMAKE_GENERATOR}}
- run: cmake --build ./build
- run: cmake --install build/ --prefix build/install
- run: ctest --output-on-failure
Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ if (VULKAN_HEADERS_ENABLE_INSTALL)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/registry" DESTINATION "${CMAKE_INSTALL_DATADIR}/vulkan" USE_SOURCE_PERMISSIONS)

set_target_properties(Vulkan-Headers PROPERTIES EXPORT_NAME "Headers")
install(TARGETS Vulkan-Headers EXPORT VulkanHeadersConfig INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if (VULKAN_HEADERS_ENABLE_MODULE)
set_target_properties(Vulkan-HppModule PROPERTIES EXPORT_NAME "HppModule")
install(TARGETS Vulkan-Headers Vulkan-HppModule EXPORT VulkanHeadersConfig INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
else()
install(TARGETS Vulkan-Headers EXPORT VulkanHeadersConfig INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()

install(EXPORT VulkanHeadersConfig NAMESPACE "Vulkan::" DESTINATION "share/cmake/VulkanHeaders")

Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ add_test(NAME integration.find_package
--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}
--build-options -DFIND_PACKAGE_TESTING=ON -DCMAKE_PREFIX_PATH=${test_install_dir} -DVULKAN_HEADERS_ENABLE_MODULE=${VULKAN_HEADERS_ENABLE_MODULE}
)

# Installing comes before testing
Expand Down
4 changes: 1 addition & 3 deletions tests/integration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ if (FIND_PACKAGE_TESTING)
message(FATAL_ERROR "VulkanHeaders_VERSION not defined!")
endif()
message(STATUS "VulkanHeaders_VERSION = ${VulkanHeaders_VERSION}")
endif()

if (NOT FIND_PACKAGE_TESTING)
else()
# 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!")
Expand Down
4 changes: 2 additions & 2 deletions tests/vk_hpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
#include <vulkan/vulkan.hpp>

int header_version()
int test_version()
{
return VK_HEADER_VERSION;
return static_cast<int>(vk::makeApiVersion(1, 0, 0, 0));
}
Loading