Use GLOBs to get macOS vulkan framework headers
authorCharles Giessen <charles@lunarg.com>
Wed, 3 Nov 2021 21:04:48 +0000 (15:04 -0600)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Wed, 9 Mar 2022 22:06:30 +0000 (15:06 -0700)
This commit recitfies the situation that this list of header files is out of
date with the upstream Vulkan-Headers repo. It uses GLOB_RECURSE to find all
the files and subdirectories in the vulkan headers include directory.
In a perfect world, the list of headers would be removed because users should
be using the Vulkan-Headers for that purpose. But to maintain any existing
users it will be retained.

CMake 3.12 added CONFIGURE_DEPENDS to globs to better support changes in the
list being caught by CMake. Since this repo uses 3.11 as the minimum, it will
not be added unless supported by the currently installed CMake version. While
better, it is not perfect at catching all changing file lists, and thus it
may still be necessary to re-run CMake manually to get an updated list of
headers files.

Note that this commit is a part of a series of commits and not intended to
work standalone.

loader/CMakeLists.txt

index 66872f587a99ebf1979243f2049b8cd8ff2d5cca..62333938d110763daee2163a3b2c6c6740ef7f02 100644 (file)
@@ -301,24 +301,14 @@ else()
         target_link_libraries(vulkan "-framework CoreFoundation")
 
         # Build vulkan.framework
-        set(FRAMEWORK_HEADERS
-            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vk_icd.h
-            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vk_layer.h
-            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vk_platform.h
-            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vk_sdk_platform.h
-            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_android.h
-            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_core.h
-            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_ios.h
-            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_macos.h
-            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_vi.h
-            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_wayland.h
-            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_win32.h
-            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_xcb.h
-            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_xlib.h
-            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_xlib_xrandr.h
-            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_screen.h
-            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan.h
-            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan.hpp)
+        # 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
+        if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12)
+            file(GLOB_RECURSE FRAMEWORK_HEADERS ${VulkanHeaders_INCLUDE_DIRS} CONFIGURE_DEPENDS)
+        else()
+            file(GLOB_RECURSE FRAMEWORK_HEADERS ${VulkanHeaders_INCLUDE_DIRS} CONFIGURE_DEPENDS)
+        endif()
         if(BUILD_STATIC_LOADER)
             add_library(vulkan-framework STATIC ${NORMAL_LOADER_SRCS} ${OPT_LOADER_SRCS} ${FRAMEWORK_HEADERS})
         else()