@@ -22,8 +22,29 @@ if(PKG_CONFIG_FOUND)
2222 pkg_search_module (WAYLAND_CLIENT wayland-client )
2323endif ()
2424
25+ include (CMakeDependentOption )
26+ cmake_dependent_option (
27+ BUILD_WITH_XLIB_HEADERS "Build with support for X11/Xlib-related features." ON "X11_FOUND" OFF
28+ )
29+ cmake_dependent_option (
30+ BUILD_WITH_XCB_HEADERS "Build with support for XCB-related features." ON "X11_FOUND AND XCB_FOUND" OFF
31+ )
32+ cmake_dependent_option (
33+ BUILD_WITH_WAYLAND_HEADERS "Build with support for Wayland-related features." ON "WAYLAND_CLIENT_FOUND"
34+ OFF
35+ )
36+
37+ message (STATUS "BUILD_WITH_XLIB_HEADERS: ${BUILD_WITH_XLIB_HEADERS} " )
38+ message (STATUS "BUILD_WITH_XCB_HEADERS: ${BUILD_WITH_XCB_HEADERS} " )
39+ message (STATUS "BUILD_WITH_WAYLAND_HEADERS: ${BUILD_WITH_WAYLAND_HEADERS} " )
2540
2641if (PRESENTATION_BACKEND MATCHES "xlib" )
42+ if (NOT BUILD_WITH_XLIB_HEADERS)
43+ message (
44+ FATAL_ERROR
45+ "xlib backend selected, but BUILD_WITH_XLIB_HEADERS either disabled or unavailable due to missing dependencies."
46+ )
47+ endif ()
2748 if (BUILD_TESTS AND (NOT X11_Xxf86vm_LIB OR NOT X11_Xrandr_LIB))
2849 message (FATAL_ERROR "OpenXR tests using xlib backend requires Xxf86vm and Xrandr" )
2950 endif ()
@@ -40,6 +61,12 @@ if(PRESENTATION_BACKEND MATCHES "xlib")
4061 endif ()
4162 endif ()
4263elseif (PRESENTATION_BACKEND MATCHES "xcb" )
64+ if (NOT BUILD_WITH_XCB_HEADERS)
65+ message (
66+ FATAL_ERROR
67+ "xcb backend selected, but BUILD_WITH_XCB_HEADERS either disabled or unavailable due to missing dependencies."
68+ )
69+ endif ()
4370 pkg_search_module (XCB_RANDR REQUIRED xcb-randr )
4471 pkg_search_module (XCB_KEYSYMS REQUIRED xcb-keysyms )
4572 pkg_search_module (XCB_GLX REQUIRED xcb-glx )
@@ -55,6 +82,12 @@ elseif(PRESENTATION_BACKEND MATCHES "xcb")
5582 target_link_libraries (openxr-gfxwrapper PRIVATE ${X11_X11_LIB} ${XCB_KEYSYMS_LIBRARIES} ${XCB_RANDR_LIBRARIES} )
5683 endif ()
5784elseif (PRESENTATION_BACKEND MATCHES "wayland" )
85+ if (NOT BUILD_WITH_WAYLAND_HEADERS)
86+ message (
87+ FATAL_ERROR
88+ "wayland backend selected, but BUILD_WITH_WAYLAND_HEADERS either disabled or unavailable due to missing dependencies."
89+ )
90+ endif ()
5891
5992 pkg_search_module (WAYLAND_EGL REQUIRED wayland-egl )
6093 pkg_search_module (WAYLAND_SCANNER REQUIRED wayland-scanner )
0 commit comments