@@ -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 ()
@@ -41,6 +62,12 @@ if(PRESENTATION_BACKEND MATCHES "xlib")
4162 endif ()
4263 endif ()
4364elseif (PRESENTATION_BACKEND MATCHES "xcb" )
65+ if (NOT BUILD_WITH_XCB_HEADERS)
66+ message (
67+ FATAL_ERROR
68+ "xcb backend selected, but BUILD_WITH_XCB_HEADERS either disabled or unavailable due to missing dependencies."
69+ )
70+ endif ()
4471 pkg_search_module(XCB_RANDR REQUIRED xcb-randr)
4572 pkg_search_module(XCB_KEYSYMS REQUIRED xcb-keysyms)
4673 pkg_search_module(XCB_GLX REQUIRED xcb-glx)
@@ -56,6 +83,12 @@ elseif(PRESENTATION_BACKEND MATCHES "xcb")
5683 target_link_libraries (openxr-gfxwrapper PRIVATE ${X11_X11_LIB} ${XCB_KEYSYMS_LIBRARIES} ${XCB_RANDR_LIBRARIES} )
5784 endif ()
5885elseif (PRESENTATION_BACKEND MATCHES "wayland" )
86+ if (NOT BUILD_WITH_WAYLAND_HEADERS)
87+ message (
88+ FATAL_ERROR
89+ "wayland backend selected, but BUILD_WITH_WAYLAND_HEADERS either disabled or unavailable due to missing dependencies."
90+ )
91+ endif ()
5992
6093 pkg_search_module(WAYLAND_EGL REQUIRED wayland-egl)
6194 pkg_search_module(WAYLAND_SCANNER REQUIRED wayland-scanner)
0 commit comments