Skip to content

Commit

Permalink
cmake: Add WSI Build Support Options
Browse files Browse the repository at this point in the history
Fixed CMakelists.txt for vulkaninfo
to generate build files on
Linux with the selected WSI options.

Change-Id: Ied83f0e24dbd08af2ef03066fdfa1443203aa4ad
  • Loading branch information
jeremyk-lunarg committed May 28, 2018
1 parent c3b64a7 commit 97af2fd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
6 changes: 4 additions & 2 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,12 @@ If your build system supports ccache, you can enable that via CMake option `-DUS

### WSI Support Build Options

By default, the Vulkan Tools are built with support for all 4 Vulkan-defined WSI display servers: Xcb, Xlib, Wayland, and Mir.
By default, the Vulkan Tools cube and cubepp are built with support for all 4 Vulkan-defined WSI display servers: Xcb, Xlib, Wayland, and Mir.
It is recommended to build the repository components with support for these display servers to maximize their usability across Linux platforms.
If it is necessary to build these modules without support for one of the display servers, the appropriate CMake option of the form `BUILD_WSI_xxx_SUPPORT` can be set to `OFF`.
See the top-level CMakeLists.txt file for more info.
See the CMakeLists.txt file in `Vulkan-Tools/cube` for more info.

Note vulkaninfo currently only supports Xcb and Xlib WSI display servers. See the CMakeLists.txt file in `Vulkan-Tools/vulkaninfo` for more info.

### Linux Install to System Directories

Expand Down
30 changes: 29 additions & 1 deletion vulkaninfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,35 @@ else()
add_executable(vulkaninfo vulkaninfo.c)
endif()

if(APPLE)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
include(FindPkgConfig)
option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON)
option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" ON)
set(VULKANINFO_WSI_SELECTION "XCB" CACHE STRING "Select WSI target for vulkaninfo (XCB, XLIB)")

if (BUILD_WSI_XCB_SUPPORT)
find_package(XCB REQUIRED)
endif()

if (BUILD_WSI_XLIB_SUPPORT)
find_package(X11 REQUIRED)
endif()

if (VULKANINFO_WSI_SELECTION STREQUAL "XCB")
if (NOT BUILD_WSI_XCB_SUPPORT)
message( FATAL_ERROR "Selected XCB for vulkaninfo build but not building Xcb support" )
endif()
target_include_directories(vulkaninfo PRIVATE ${XCB_INCLUDE_DIRS})
target_link_libraries(vulkaninfo ${XCB_LIBRARIES})
target_compile_definitions(vulkaninfo PRIVATE -DVK_USE_PLATFORM_XCB_KHR)
elseif (VULKANINFO_WSI_SELECTION STREQUAL "XLIB")
if (NOT BUILD_WSI_XLIB_SUPPORT)
message( FATAL_ERROR "Selected XLIB for vulkaninfo build but not building Xlib support" )
endif()
target_include_directories(vulkaninfo PRIVATE ${X11_INCLUDE_DIR})
target_link_libraries(vulkaninfo ${X11_LIBRARIES})
target_compile_definitions(vulkaninfo PRIVATE -DVK_USE_PLATFORM_XLIB_KHR)
endif()
endif()

# Predefine loader root as a cmake cache variable for cmake-gui
Expand Down

0 comments on commit 97af2fd

Please sign in to comment.