Cleanup: use full names for generated wayland headers, use own directory

Instead of providing our own names for wayland headers, use the filename
component as the basis for the header names. This matches most reference
documentation for Wayland.

Also generate client protocols into a sub-directory `libwayland`,
instead of generating headers into the ghost directory. Making the
include path more specific & makes it easier to differentiate generated
headers from other build files.
This commit is contained in:
Campbell Barton
2022-06-21 09:11:30 +10:00
parent 84315368ef
commit beaae4533a
4 changed files with 30 additions and 22 deletions

View File

@@ -303,59 +303,63 @@ elseif(WITH_GHOST_X11 OR WITH_GHOST_WAYLAND)
message(FATAL_ERROR "path to wayland-protocols not found")
endif()
set(INC_DST ${CMAKE_CURRENT_BINARY_DIR}/libwayland)
# Generate protocols bindings.
macro(generate_protocol_bindings NAME PROT_DEF)
macro(generate_protocol_bindings PROT_DEF)
# File name without directory or extension (use for header name).
get_filename_component(_name ${PROT_DEF} NAME_WLE)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}-client-protocol.h
COMMAND ${WAYLAND_SCANNER} client-header ${PROT_DEF} ${NAME}-client-protocol.h
OUTPUT ${INC_DST}/${_name}-client-protocol.h
COMMAND ${CMAKE_COMMAND} -E make_directory ${INC_DST}
COMMAND ${WAYLAND_SCANNER} client-header ${PROT_DEF} ${INC_DST}/${_name}-client-protocol.h
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}-client-protocol.c
COMMAND ${WAYLAND_SCANNER} private-code ${PROT_DEF} ${NAME}-client-protocol.c
DEPENDS ${NAME}-client-protocol.h
OUTPUT ${INC_DST}/${_name}-client-protocol.c
COMMAND ${CMAKE_COMMAND} -E make_directory ${INC_DST}
COMMAND ${WAYLAND_SCANNER} private-code ${PROT_DEF} ${INC_DST}/${_name}-client-protocol.c
DEPENDS ${INC_DST}/${_name}-client-protocol.h
)
list(APPEND SRC
${CMAKE_CURRENT_BINARY_DIR}/${NAME}-client-protocol.c
${CMAKE_CURRENT_BINARY_DIR}/${NAME}-client-protocol.h
${INC_DST}/${_name}-client-protocol.c
${INC_DST}/${_name}-client-protocol.h
)
unset(_name)
endmacro()
list(APPEND INC_SYS
${CMAKE_CURRENT_BINARY_DIR}
${INC_DST}
)
# `xdg-shell`.
generate_protocol_bindings(
xdg-shell
"${WAYLAND_PROTOCOLS_DIR}/stable/xdg-shell/xdg-shell.xml"
)
# `xdg-decoration`.
generate_protocol_bindings(
xdg-decoration
"${WAYLAND_PROTOCOLS_DIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
)
# `xdg-output`.
generate_protocol_bindings(
xdg-output
"${WAYLAND_PROTOCOLS_DIR}/unstable/xdg-output/xdg-output-unstable-v1.xml"
)
# Pointer-constraints.
generate_protocol_bindings(
pointer-constraints
"${WAYLAND_PROTOCOLS_DIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"
)
# Relative-pointer.
generate_protocol_bindings(
relative-pointer
"${WAYLAND_PROTOCOLS_DIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
)
# Tablet.
generate_protocol_bindings(
tablet
"${WAYLAND_PROTOCOLS_DIR}/unstable/tablet/tablet-unstable-v2.xml"
)
add_definitions(-DWITH_GHOST_WAYLAND)
unset(INC_DST)
endif()
if(WITH_INPUT_NDOF)

View File

@@ -26,15 +26,18 @@
#include <unordered_map>
#include <unordered_set>
#include "GHOST_WaylandCursorSettings.h"
#include <pointer-constraints-client-protocol.h>
#include <relative-pointer-client-protocol.h>
#include <tablet-client-protocol.h>
#include <wayland-cursor.h>
#include <xdg-output-client-protocol.h>
#include "GHOST_WaylandCursorSettings.h"
#include <xkbcommon/xkbcommon.h>
/* Generated by `wayland-scanner`. */
#include <pointer-constraints-unstable-v1-client-protocol.h>
#include <relative-pointer-unstable-v1-client-protocol.h>
#include <tablet-unstable-v2-client-protocol.h>
#include <xdg-output-unstable-v1-client-protocol.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>

View File

@@ -12,7 +12,9 @@
#include "GHOST_WindowWayland.h"
#include <wayland-client.h>
#include <xdg-decoration-client-protocol.h>
/* Generated by `wayland-scanner`. */
#include <xdg-decoration-unstable-v1-client-protocol.h>
#include <xdg-shell-client-protocol.h>
#include <string>

View File

@@ -10,7 +10,6 @@
#include "GHOST_Window.h"
#include <unordered_set>
#include <vector>
class GHOST_SystemWayland;