cmake: Use new VulkanHeaders cmake support
authorJuan Ramos <juan@lunarg.com>
Tue, 8 Nov 2022 21:04:18 +0000 (14:04 -0700)
committerJuan Ramos <114601453+juan-lunarg@users.noreply.github.com>
Tue, 8 Nov 2022 21:57:21 +0000 (14:57 -0700)
Removes need to have FindVulkanHeaders.cmake

.github/workflows/build.yml
CMakeLists.txt
cmake/FindVulkanHeaders.cmake [deleted file]
loader/CMakeLists.txt
scripts/known_good.json

index e2d0957fdffb59dc6eba7ac1c41bed4fd1d1ee37..d215274b15ab758fa7dd01b61edf5237c2af94d4 100644 (file)
@@ -96,8 +96,10 @@ jobs:
                 sudo apt-get update
                 sudo apt install --yes --no-install-recommends gcc-multilib g++-multilib libc6-dev-i386 pkg-config-i686-linux-gnu libwayland-dev:i386 libxrandr-dev:i386
             - name: Generate build files
-              run: cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=${{matrix.config}} -DBUILD_TESTS=On -DUPDATE_DEPS=ON -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32
+              run: cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=${{matrix.config}} -DBUILD_TESTS=On -DUPDATE_DEPS=ON
               env:
+                CFLAGS: -m32
+                CXXFLAGS: -m32
                 LDFLAGS: -m32
                 ASFLAGS: --32
                 PKG_CONFIG: i686-pc-linux-gnu-pkg-config
index 90b25b6b7dfa241c49e010d768a2731ab5e40c28..7e0c4d2ed8f1299520cbb8072d7e5d418357b444 100644 (file)
@@ -79,6 +79,9 @@ else()
     message("********************************************************************************")
     find_package(PythonInterp 3 QUIET)
 endif()
+if (VULKAN_HEADERS_INSTALL_DIR)
+    list(APPEND CMAKE_PREFIX_PATH ${VULKAN_HEADERS_INSTALL_DIR})
+endif()
 
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
 find_package(PythonInterp 3 QUIET)
@@ -107,26 +110,7 @@ if(BUILD_STATIC_LOADER)
         "or tested as part of the loader. Use it at your own risk.")
 endif()
 
-if (TARGET Vulkan::Headers)
-    message(STATUS "Using Vulkan headers from Vulkan::Headers target")
-    get_target_property(VulkanHeaders_INCLUDE_DIRS Vulkan::Headers INTERFACE_INCLUDE_DIRECTORIES)
-    get_target_property(VulkanRegistry_DIR Vulkan::Registry INTERFACE_INCLUDE_DIRECTORIES)
-else()
-    find_package(VulkanHeaders)
-    if(NOT ${VulkanHeaders_FOUND})
-        message(FATAL_ERROR "Could not find Vulkan headers path. This can be fixed by setting VULKAN_HEADERS_INSTALL_DIR to an "
-                            "installation of the Vulkan-Headers repository.")
-    endif()
-    if(NOT ${VulkanRegistry_FOUND})
-        message(FATAL_ERROR "Could not find Vulkan registry path. This can be fixed by setting VULKAN_HEADERS_INSTALL_DIR to an "
-                            "installation of the Vulkan-Headers repository.")
-    endif()
-
-    # set up the Vulkan::Headers target for consistency
-    add_library(vulkan-headers INTERFACE)
-    target_include_directories(vulkan-headers SYSTEM INTERFACE "${VulkanHeaders_INCLUDE_DIRS}")
-    add_library(Vulkan::Headers ALIAS vulkan-headers)
-endif()
+find_package(VulkanHeaders REQUIRED CONFIG QUIET)
 
 include(GNUInstallDirs)
 
diff --git a/cmake/FindVulkanHeaders.cmake b/cmake/FindVulkanHeaders.cmake
deleted file mode 100644 (file)
index 0b4585d..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-#.rst:
-# FindVulkanHeaders
-# -----------------
-#
-# Try to find Vulkan Headers and Registry.
-#
-# This module is intended to be used by projects that build Vulkan
-# "system" components such as the loader and layers.
-# Vulkan applications should instead use the FindVulkan (or similar)
-# find module that locates the headers and the loader library.
-#
-# When using this find module to locate the headers and registry
-# in a Vulkan-Headers repository, the Vulkan-Headers repository
-# should be built with 'install' target and the following environment
-# or CMake variable set to the location of the install directory.
-#
-#    VULKAN_HEADERS_INSTALL_DIR
-#
-# IMPORTED Targets
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines no IMPORTED targets
-#
-# Result Variables
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines the following variables::
-#
-#   VulkanHeaders_FOUND          - True if VulkanHeaders was found
-#   VulkanHeaders_INCLUDE_DIRS   - include directories for VulkanHeaders
-#
-#   VulkanRegistry_FOUND         - True if VulkanRegistry was found
-#   VulkanRegistry_DIRS          - directories for VulkanRegistry
-#
-#   VulkanHeaders_VERSION_MAJOR  - The Major API version of the latest version
-#                                  contained in the Vulkan header
-#   VulkanHeaders_VERSION_MINOR  - The Minor API version of the latest version
-#                                  contained in the Vulkan header
-#   VulkanHeaders_VERSION_PATCH  - The Patch API version of the latest version
-#                                  contained in the Vulkan header
-#
-# The module will also define two cache variables::
-#
-#   VulkanHeaders_INCLUDE_DIR    - the VulkanHeaders include directory
-#   VulkanRegistry_DIR           - the VulkanRegistry directory
-#
-
-# Probe command-line arguments and the environment to see if they specify the
-# Vulkan headers installation path.
-if(NOT DEFINED VULKAN_HEADERS_INSTALL_DIR)
-  if (DEFINED ENV{VULKAN_HEADERS_INSTALL_DIR})
-    set(VULKAN_HEADERS_INSTALL_DIR "$ENV{VULKAN_HEADERS_INSTALL_DIR}")
-  elseif(DEFINED ENV{VULKAN_SDK})
-    set(VULKAN_HEADERS_INSTALL_DIR "$ENV{VULKAN_SDK}/include")
-  endif()
-endif()
-
-if(DEFINED VULKAN_HEADERS_INSTALL_DIR)
-  # When CMAKE_FIND_ROOT_PATH_INCLUDE is set to ONLY, the HINTS in find_path()
-  # are re-rooted, which prevents VULKAN_HEADERS_INSTALL_DIR to work as
-  # expected. So use NO_CMAKE_FIND_ROOT_PATH to avoid it.
-
-  # Use HINTS instead of PATH to search these locations before
-  # searching system environment variables like $PATH that may
-  # contain SDK directories.
-  find_path(VulkanHeaders_INCLUDE_DIR
-      NAMES vulkan/vulkan.h
-      HINTS ${VULKAN_HEADERS_INSTALL_DIR}/include
-      NO_CMAKE_FIND_ROOT_PATH)
-  find_path(VulkanRegistry_DIR
-      NAMES vk.xml
-      HINTS ${VULKAN_HEADERS_INSTALL_DIR}/share/vulkan/registry
-      NO_CMAKE_FIND_ROOT_PATH)
-else()
-  # If VULKAN_HEADERS_INSTALL_DIR, or one of its variants was not specified,
-  # do a normal search without hints.
-  find_path(VulkanHeaders_INCLUDE_DIR NAMES vulkan/vulkan.h HINTS "${CMAKE_CURRENT_SOURCE_DIR}/external/Vulkan-Headers/include" NO_CMAKE_FIND_ROOT_PATH)
-  get_filename_component(VULKAN_REGISTRY_PATH_HINT ${VulkanHeaders_INCLUDE_DIR} DIRECTORY)
-  find_path(VulkanRegistry_DIR NAMES vk.xml HINTS ${VULKAN_REGISTRY_PATH_HINT}/share/vulkan/registry
-    "${VULKAN_REGISTRY_PATH_HINT}/registry" NO_CMAKE_FIND_ROOT_PATH)
-endif()
-
-set(VulkanHeaders_INCLUDE_DIRS ${VulkanHeaders_INCLUDE_DIR})
-set(VulkanRegistry_DIRS ${VulkanRegistry_DIR})
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(VulkanHeaders
-    DEFAULT_MSG
-    VulkanHeaders_INCLUDE_DIR)
-set(FPHSA_NAME_MISMATCHED TRUE)
-find_package_handle_standard_args(VulkanRegistry
-    DEFAULT_MSG
-    VulkanRegistry_DIR)
-unset(FPHSA_NAME_MISMATCHED)
-
-mark_as_advanced(VulkanHeaders_INCLUDE_DIR VulkanRegistry_DIR)
-
-# Determine the major/minor/patch version from the vulkan header
-set(VulkanHeaders_VERSION_MAJOR "0")
-set(VulkanHeaders_VERSION_MINOR "0")
-set(VulkanHeaders_VERSION_PATCH "0")
-
-# First, determine which header we need to grab the version information from.
-# Starting with Vulkan 1.1, we should use vulkan_core.h, but prior to that,
-# the information was in vulkan.h.
-if (EXISTS "${VulkanHeaders_INCLUDE_DIR}/vulkan/vulkan_core.h")
-    set(VulkanHeaders_main_header ${VulkanHeaders_INCLUDE_DIR}/vulkan/vulkan_core.h)
-else()
-    set(VulkanHeaders_main_header ${VulkanHeaders_INCLUDE_DIR}/vulkan/vulkan.h)
-endif()
-
-# Find all lines in the header file that contain any version we may be interested in
-#  NOTE: They start with #define and then have other keywords
-file(STRINGS
-        ${VulkanHeaders_main_header}
-        VulkanHeaders_lines
-        REGEX "^#define VK_HEADER_VERSION(_COMPLETE)? ")
-
-foreach(VulkanHeaders_line ${VulkanHeaders_lines})
-
-    # First, handle the case where we have a major/minor version
-    #   Format is:
-    #        #define VK_HEADER_VERSION_COMPLETE VK_MAKE_API_VERSION(0, X, Y, VK_HEADER_VERSION)
-    #   We grab the major version (X) and minor version (Y) out of the parentheses
-    string(REGEX MATCH "VK_HEADER_VERSION_COMPLETE VK_MAKE_API_VERSION\\(.*\\)" VulkanHeaders_out ${VulkanHeaders_line})
-    string(REGEX MATCHALL "[0-9]+" VulkanHeaders_MAJOR_MINOR "${VulkanHeaders_out}")
-    if (VulkanHeaders_MAJOR_MINOR)
-        list (GET VulkanHeaders_MAJOR_MINOR 1 VulkanHeaders_cur_major)
-        list (GET VulkanHeaders_MAJOR_MINOR 2 VulkanHeaders_cur_minor)
-        if (${VulkanHeaders_cur_major} GREATER ${VulkanHeaders_VERSION_MAJOR})
-            set(VulkanHeaders_VERSION_MAJOR ${VulkanHeaders_cur_major})
-            set(VulkanHeaders_VERSION_MINOR ${VulkanHeaders_cur_minor})
-        endif()
-        if (${VulkanHeaders_cur_major} EQUAL ${VulkanHeaders_VERSION_MAJOR} AND
-            ${VulkanHeaders_cur_minor} GREATER ${VulkanHeaders_VERSION_MINOR})
-            set(VulkanHeaders_VERSION_MINOR ${VulkanHeaders_cur_minor})
-        endif()
-    endif()
-
-    # Second, handle the case where we have the patch version
-    #   Format is:
-    #      #define VK_HEADER_VERSION Z
-    #   Where Z is the patch version which we just grab off the end
-    string(REGEX MATCH "define.*VK_HEADER_VERSION[^_].*[0-9]+" VulkanHeaders_out ${VulkanHeaders_line})
-    list(LENGTH VulkanHeaders_out VulkanHeaders_len)
-    if (VulkanHeaders_len)
-        string(REGEX MATCH "[0-9]+" VulkanHeaders_VERSION_PATCH "${VulkanHeaders_out}")
-    endif()
-
-endforeach()
-MESSAGE(STATUS
-        "Detected Vulkan Version ${VulkanHeaders_VERSION_MAJOR}."
-        "${VulkanHeaders_VERSION_MINOR}."
-        "${VulkanHeaders_VERSION_PATCH}")
index e46a36725623f2ff65a76e5e930f5a9c51c0d0dd..17c0d638698fac2082fead5c03a1ecd652e3e0d4 100644 (file)
@@ -334,6 +334,7 @@ else()
         # Use GLOB_RECURSE to find all the header files and populate the vulkan.framework headers with them
         # Use CONFIGURE_DEPENDS to ensure that if the header files are updated, this list is also updated
         # Note: CONFIGURE_DEPENDS is a 3.12 feature - gate it for now and remove when CMake minimum version is higher
+        get_target_property(VulkanHeaders_INCLUDE_DIRS Vulkan::Headers INTERFACE_INCLUDE_DIRECTORIES)
         if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0")
             file(GLOB_RECURSE CONFIGURE_DEPENDS FRAMEWORK_HEADERS ${VulkanHeaders_INCLUDE_DIRS})
         else()
index 85e078c949be5e055364e4eb0d0a57207aa57de2..990d639f1c228875c3e363973c7e6b05420926ac 100644 (file)
@@ -6,7 +6,7 @@
             "sub_dir": "Vulkan-Headers",
             "build_dir": "Vulkan-Headers/build",
             "install_dir": "Vulkan-Headers/build/install",
-            "commit": "v1.3.233"
+            "commit": "ef96d229cb3d9d58b71c832aafd79f9dda306375"
         },
         {
             "name": "googletest",