Skip to content

Commit 03a736d

Browse files
Make Xrandr not implicitly required when x11 is used
The previous logic made xrandr a required header whenever x11 was available which doesn't honestly convey build requirements to users. This commit add BUILD_WSI_XLIB_XRANDR_SUPPORT as a build option that defaults to ON (for platforms which support x11) so the xrandr requirement can be configured by users directly.
1 parent b831551 commit 03a736d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ elseif(APPLE)
111111
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|BSD|DragonFly|GNU")
112112
option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON)
113113
option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" ON)
114+
option(BUILD_WSI_XLIB_XRANDR_SUPPORT "Build X11 Xrandr WSI support" ON)
114115
option(BUILD_WSI_WAYLAND_SUPPORT "Build Wayland WSI support" ON)
115116
option(BUILD_WSI_DIRECTFB_SUPPORT "Build DirectFB WSI support" OFF)
116117

@@ -125,8 +126,14 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|BSD|DragonFly|GNU")
125126
if(BUILD_WSI_XLIB_SUPPORT)
126127
pkg_check_modules(X11 REQUIRED QUIET IMPORTED_TARGET x11)
127128
pkg_get_variable(XLIB_INCLUDE_DIRS x11 includedir)
128-
target_compile_definitions(platform_wsi INTERFACE VK_USE_PLATFORM_XLIB_KHR VK_USE_PLATFORM_XLIB_XRANDR_EXT)
129+
target_compile_definitions(platform_wsi INTERFACE VK_USE_PLATFORM_XLIB_KHR)
129130
target_include_directories(platform_wsi INTERFACE ${XLIB_INCLUDE_DIRS})
131+
if(BUILD_WSI_XLIB_XRANDR_SUPPORT)
132+
pkg_check_modules(XRANDR REQUIRED QUIET IMPORTED_TARGET xrandr)
133+
pkg_get_variable(XLIB_XRANDR_INCLUDE_DIRS xrandr includedir)
134+
target_compile_definitions(platform_wsi INTERFACE VK_USE_PLATFORM_XLIB_XRANDR_EXT)
135+
target_include_directories(platform_wsi INTERFACE ${XLIB_XRANDR_INCLUDE_DIRS})
136+
endif()
130137
endif()
131138
if(BUILD_WSI_WAYLAND_SUPPORT)
132139
target_compile_definitions(platform_wsi INTERFACE VK_USE_PLATFORM_WAYLAND_KHR)

0 commit comments

Comments
 (0)