mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-02-09 23:38:04 +00:00
xrt/comp/cmake: Enable build of Wayland backend.
Add pkgconfig based Wayland build including protocol generation.
This commit is contained in:
parent
871f6bfc87
commit
979536dd4b
|
@ -41,11 +41,16 @@ pkg_check_modules(FFMPEG libavcodec)
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
# Compositor backend
|
# Compositor backend
|
||||||
find_package(X11)
|
find_package(X11)
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_check_modules(XCB xcb xcb-randr)
|
pkg_check_modules(XCB xcb xcb-randr)
|
||||||
|
|
||||||
find_package(udev REQUIRED)
|
find_package(udev REQUIRED)
|
||||||
set(BUILD_WITH_LIBUDEV TRUE)
|
set(BUILD_WITH_LIBUDEV TRUE)
|
||||||
set(BUILD_DRIVER_V4L2 TRUE)
|
set(BUILD_DRIVER_V4L2 TRUE)
|
||||||
|
|
||||||
|
pkg_search_module(WAYLAND wayland-client)
|
||||||
|
pkg_search_module(WAYLAND_SCANNER wayland-scanner)
|
||||||
|
pkg_search_module(WAYLAND_PROTOCOLS wayland-protocols)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
cmake_dependent_option(BUILD_WITH_WAYLAND "Enable Wayland support" ON "WAYLAND_FOUND" OFF)
|
cmake_dependent_option(BUILD_WITH_WAYLAND "Enable Wayland support" ON "WAYLAND_FOUND" OFF)
|
||||||
|
|
|
@ -38,6 +38,7 @@ set(GL_SOURCE_FILES
|
||||||
main/comp_window.h
|
main/comp_window.h
|
||||||
main/comp_window_direct_mode.cpp
|
main/comp_window_direct_mode.cpp
|
||||||
main/comp_window_xcb.cpp
|
main/comp_window_xcb.cpp
|
||||||
|
main/comp_window_wayland.c
|
||||||
)
|
)
|
||||||
|
|
||||||
if (${XCB_FOUND})
|
if (${XCB_FOUND})
|
||||||
|
@ -45,17 +46,48 @@ if (${XCB_FOUND})
|
||||||
add_definitions(-DVK_USE_PLATFORM_XLIB_XRANDR_EXT)
|
add_definitions(-DVK_USE_PLATFORM_XLIB_XRANDR_EXT)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# generate wayland protocols
|
||||||
|
if("${WAYLAND_FOUND}" AND
|
||||||
|
"${WAYLAND_SCANNER_FOUND}" AND
|
||||||
|
"${WAYLAND_PROTOCOLS_FOUND}" AND
|
||||||
|
"${BUILD_WITH_WAYLAND}")
|
||||||
|
pkg_get_variable(WL_PROTOS_PKG_DIR wayland-protocols pkgdatadir)
|
||||||
|
pkg_get_variable(WL_SCANNER wayland-scanner wayland_scanner)
|
||||||
|
|
||||||
|
set(WL_PROTOS_DIR "${CMAKE_CURRENT_BINARY_DIR}/wayland-protocols/")
|
||||||
|
file(MAKE_DIRECTORY "${WL_PROTOS_DIR}")
|
||||||
|
|
||||||
|
set(WL_PROTOS_XML "${WL_PROTOS_PKG_DIR}/stable/xdg-shell/xdg-shell.xml")
|
||||||
|
set(WL_PROTOS_C "${WL_PROTOS_DIR}/xdg-shell.c")
|
||||||
|
set(WL_PROTOS_H "${WL_PROTOS_DIR}/xdg-shell-client-protocol.h")
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
COMMAND
|
||||||
|
${WL_SCANNER} private-code "${WL_PROTOS_XML}" "${WL_PROTOS_C}"
|
||||||
|
OUTPUT "${WL_PROTOS_C}" VERBATIM)
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
COMMAND
|
||||||
|
${WL_SCANNER} client-header "${WL_PROTOS_XML}" "${WL_PROTOS_H}"
|
||||||
|
OUTPUT "${WL_PROTOS_H}" VERBATIM)
|
||||||
|
|
||||||
|
set(WL_PROTOS_SRC ${WL_PROTOS_C} ${WL_PROTOS_H})
|
||||||
|
|
||||||
|
add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (${VULKAN_ENABLE_VALIDATION})
|
if (${VULKAN_ENABLE_VALIDATION})
|
||||||
add_definitions(-DXRT_ENABLE_VK_VALIDATION)
|
add_definitions(-DXRT_ENABLE_VK_VALIDATION)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Use OBJECT to not create a archive, since it just gets in the way.
|
# Use OBJECT to not create a archive, since it just gets in the way.
|
||||||
add_library(comp OBJECT ${GL_SOURCE_FILES})
|
add_library(comp OBJECT ${GL_SOURCE_FILES} ${WL_PROTOS_SRC})
|
||||||
set_property(TARGET comp PROPERTY POSITION_INDEPENDENT_CODE ON)
|
set_property(TARGET comp PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||||
target_include_directories(comp
|
target_include_directories(comp
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${XCB_INCLUDE_DIRS}
|
${XCB_INCLUDE_DIRS}
|
||||||
${VULKAN_INCLUDE_DIR}
|
${VULKAN_INCLUDE_DIR}
|
||||||
|
${WL_PROTOS_DIR}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../include
|
${CMAKE_CURRENT_SOURCE_DIR}/../include
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../auxiliary
|
${CMAKE_CURRENT_SOURCE_DIR}/../auxiliary
|
||||||
|
|
|
@ -47,6 +47,7 @@ target_link_libraries(${RUNTIME_TARGET}
|
||||||
${Vulkan_LIBRARIES}
|
${Vulkan_LIBRARIES}
|
||||||
${UDEV_LIBRARIES}
|
${UDEV_LIBRARIES}
|
||||||
${XCB_LIBRARIES}
|
${XCB_LIBRARIES}
|
||||||
|
${WAYLAND_LIBRARIES}
|
||||||
OpenGL::GLX
|
OpenGL::GLX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue