diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 988aa2f58..69259a4bb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -70,11 +70,6 @@ jobs: - run: cmake --build build - run: ctest --output-on-failure --test-dir build/ - run: cmake --install build --prefix /tmp - # NOTE: This check is NOT sufficient to ensure vulkan.pc is actually valid - - name: Check vulkan.pc exists and validate it - run: | - cat /tmp/lib/pkgconfig/vulkan.pc - pkg-config --validate /tmp/lib/pkgconfig/vulkan.pc codegen: runs-on: ubuntu-latest diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4941cce3e..5c2e938fd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -85,3 +85,32 @@ if(NOT CMAKE_CROSSCOMPILING) else() gtest_add_tests(TARGET test_regression) endif() + +# When APPLE_STATIC_LOADER is ON installation is disabled +if (APPLE_STATIC_LOADER) + return() +endif() + +# Test installation +set(test_install_dir "${CMAKE_CURRENT_BINARY_DIR}/install") +add_test(NAME integration.install + COMMAND ${CMAKE_COMMAND} --install ${PROJECT_BINARY_DIR} --prefix ${test_install_dir} --config $ +) + +# find_package testing currently doesn't work well under cross-compilation scenarios. +if (CMAKE_CROSSCOMPILING OR + NOT CMAKE_SIZEOF_VOID_P EQUAL 8) + return() +endif() + +# 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 -DCMAKE_PREFIX_PATH=${test_install_dir} +) + +# Installing comes before testing +set_tests_properties(integration.find_package PROPERTIES DEPENDS integration.install) diff --git a/tests/integration/CMakeLists.txt b/tests/integration/CMakeLists.txt new file mode 100644 index 000000000..f15685222 --- /dev/null +++ b/tests/integration/CMakeLists.txt @@ -0,0 +1,39 @@ +# ~~~ +# Copyright (c) 2023 Valve Corporation +# Copyright (c) 2023 LunarG, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ~~~ +cmake_minimum_required(VERSION 3.17.2) + +project(INTEGRATION LANGUAGES C) + +find_package(VulkanLoader REQUIRED CONFIG) + +# The intent is ensuring we don't accidentally change the names of these +# targets. Since it would break downstream users. +if (NOT TARGET Vulkan::Loader) + message(FATAL_ERROR "Vulkan::Loader target not defined!") +endif() + +if (NOT DEFINED VulkanLoader_VERSION) + message(FATAL_ERROR "VulkanLoader_VERSION not defined!") +endif() +message(STATUS "VulkanLoader_VERSION = ${VulkanLoader_VERSION}") + +# NOTE: This check is NOT sufficient to ensure vulkan.pc is actually valid +find_package(PkgConfig) +if(PKG_CONFIG_FOUND) + find_file(VULKAN_PC vulkan.pc PATH_SUFFIXES lib/pkgconfig REQUIRED) + execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --validate ${VULKAN_PC}) +endif()