From beaae4533a634f667bdf8c50285fb6dd3aabeca9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Jun 2022 09:11:30 +1000 Subject: 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. --- intern/ghost/CMakeLists.txt | 34 ++++++++++++++++------------- intern/ghost/intern/GHOST_SystemWayland.cpp | 13 ++++++----- intern/ghost/intern/GHOST_SystemWayland.h | 4 +++- intern/ghost/intern/GHOST_WindowWayland.h | 1 - 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index 5b06b5d98e6..945b3261562 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -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) diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp index 5ca85933cc7..33afb5f3155 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cpp +++ b/intern/ghost/intern/GHOST_SystemWayland.cpp @@ -26,15 +26,18 @@ #include #include -#include "GHOST_WaylandCursorSettings.h" -#include -#include -#include #include -#include + +#include "GHOST_WaylandCursorSettings.h" #include +/* Generated by `wayland-scanner`. */ +#include +#include +#include +#include + #include #include #include diff --git a/intern/ghost/intern/GHOST_SystemWayland.h b/intern/ghost/intern/GHOST_SystemWayland.h index 1599e644c68..4b953dccac6 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.h +++ b/intern/ghost/intern/GHOST_SystemWayland.h @@ -12,7 +12,9 @@ #include "GHOST_WindowWayland.h" #include -#include + +/* Generated by `wayland-scanner`. */ +#include #include #include diff --git a/intern/ghost/intern/GHOST_WindowWayland.h b/intern/ghost/intern/GHOST_WindowWayland.h index d1eadd8fcd4..89354c54c0f 100644 --- a/intern/ghost/intern/GHOST_WindowWayland.h +++ b/intern/ghost/intern/GHOST_WindowWayland.h @@ -10,7 +10,6 @@ #include "GHOST_Window.h" -#include #include class GHOST_SystemWayland; -- cgit v1.2.3