Only add include paths for xcb, x11, & directfb instead of linking
authorCharles Giessen <charles@lunarg.com>
Fri, 13 Sep 2024 20:33:58 +0000 (15:33 -0500)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Fri, 13 Sep 2024 23:01:12 +0000 (17:01 -0600)
Previously, the loader linked to various windowing libraries but never
made any calls into them. These can safely be removed, as including
the libraries locations in the header search paths is sufficient.

Because vulkan_core.h includes directfb.h without a path, it is
necessary to add the search path found from pkg-config as well as
the same path with `/directfb` appended to get vulkan_core.h to be
able to find the header. This may be a bug in the vulkan_core.h
or just an inconsistency with the way directfb is packaged on
ubuntu 24, the system the change was developed on.

CMakeLists.txt

index 46217bcedd9c4e7bdb7d4d0d403dd19f0396feb2..800b953fed74e33a483cc36c4979977f54ae2a40 100644 (file)
@@ -118,21 +118,25 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|BSD|DragonFly|GNU")
 
     if(BUILD_WSI_XCB_SUPPORT)
         pkg_check_modules(XCB REQUIRED QUIET IMPORTED_TARGET xcb)
+        pkg_get_variable(XCB_INCLUDE_DIRS xcb includedir)
         target_compile_definitions(platform_wsi INTERFACE VK_USE_PLATFORM_XCB_KHR)
-        target_link_libraries(platform_wsi INTERFACE PkgConfig::XCB)
+        target_include_directories(platform_wsi INTERFACE ${XCB_INCLUDE_DIRS})
     endif()
     if(BUILD_WSI_XLIB_SUPPORT)
         pkg_check_modules(X11 REQUIRED QUIET IMPORTED_TARGET x11)
+        pkg_get_variable(XLIB_INCLUDE_DIRS x11 includedir)
         target_compile_definitions(platform_wsi INTERFACE VK_USE_PLATFORM_XLIB_KHR VK_USE_PLATFORM_XLIB_XRANDR_EXT)
-        target_link_libraries(platform_wsi INTERFACE PkgConfig::X11)
+        target_include_directories(platform_wsi INTERFACE ${XLIB_INCLUDE_DIRS})
     endif()
     if(BUILD_WSI_WAYLAND_SUPPORT)
         target_compile_definitions(platform_wsi INTERFACE VK_USE_PLATFORM_WAYLAND_KHR)
     endif()
     if(BUILD_WSI_DIRECTFB_SUPPORT)
         pkg_check_modules(DirectFB QUIET REQUIRED IMPORTED_TARGET directfb)
+        pkg_get_variable(DIRECTFB_INCLUDE_DIRS directfb includedir)
         target_compile_definitions(platform_wsi INTERFACE VK_USE_PLATFORM_DIRECTFB_EXT)
-        target_link_libraries(platform_wsi INTERFACE PkgConfig::DirectFB)
+        # vulkan_core.h includes <directfb.h> but the header is installed to directfb/directfb.h
+        target_include_directories(platform_wsi INTERFACE ${DIRECTFB_INCLUDE_DIRS} ${DIRECTFB_INCLUDE_DIRS}/directfb)
     endif()
 elseif(CMAKE_SYSTEM_NAME MATCHES "QNX")
     message(FATAL_ERROR "See BUILD.md for QNX build")