From 90e5639701ba8b79d576bedda1146fec86edf104 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Wed, 16 Jun 2021 03:44:22 +0200 Subject: [PATCH] cmake: be more flexible when creating Wayland client and server extension headers This was hardcoded to QtWaylandClient/QtWaylandServer for cmake, while $$MODULE_INCNAME was used in the old qmake world. (this is an update to the previous commit, fixing the client side of things, plus adding an override for both) The header location will now default to the current Qt modules private include dir (as it was in qmake times), but we now also have the ability to override this default via WAYLAND_INCLUDE_DIR to deal with special cases like the WlShellExtension (which is an own Qt private module itself) Pick-to: 6.2 Change-Id: I4e96578a9a00598c236fcd22a460aeca4984baeb Reviewed-by: Dominik Holland Reviewed-by: Alexandru Croitor --- .../shellintegration/wl-shell/CMakeLists.txt | 2 ++ .../Qt6WaylandClientMacros.cmake | 16 +++++++++++----- .../Qt6WaylandCompositorMacros.cmake | 19 +++++++++++-------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/CMakeLists.txt b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/CMakeLists.txt index 0a0a83d1bd0..d7c052fa438 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/CMakeLists.txt +++ b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/CMakeLists.txt @@ -17,6 +17,8 @@ qt_internal_add_module(WlShellIntegrationPrivate ) qt6_generate_wayland_protocol_client_sources(WlShellIntegrationPrivate + # this is just a helper module and still part of the QtWaylandClient build + WAYLAND_INCLUDE_DIR QtWaylandClient/private FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../../3rdparty/protocol/wayland.xml ) diff --git a/src/tools/qtwaylandscanner/Qt6WaylandClientMacros.cmake b/src/tools/qtwaylandscanner/Qt6WaylandClientMacros.cmake index 5eab19d896f..6bda08e70fc 100644 --- a/src/tools/qtwaylandscanner/Qt6WaylandClientMacros.cmake +++ b/src/tools/qtwaylandscanner/Qt6WaylandClientMacros.cmake @@ -1,5 +1,5 @@ function(qt6_generate_wayland_protocol_client_sources target) - cmake_parse_arguments(arg "" "" "FILES" ${ARGN}) + cmake_parse_arguments(arg "" "WAYLAND_INCLUDE_DIR" "FILES" ${ARGN}) if(DEFINED arg_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unknown arguments were passed to qt6_generate_wayland_protocol_client_sources: (${arg_UNPARSED_ARGUMENTS}).") endif() @@ -34,11 +34,17 @@ function(qt6_generate_wayland_protocol_client_sources target) COMMAND Wayland::Scanner --strict --include-core-only public-code < "${protocol_file}" > "${waylandscanner_code_output}" ) - # TODO: Make this less hacky set(wayland_include_dir "") - get_target_property(is_for_module "${target}" INTERFACE_MODULE_HAS_HEADERS) - if (is_for_module) - set(wayland_include_dir "QtWaylandClient/private") + if(arg_WAYLAND_INCLUDE_DIR) + set(wayland_include_dir "${arg_WAYLAND_INCLUDE_DIR}") + else() + get_target_property(qt_module ${target} _qt_module_interface_name) + get_target_property(is_for_module "${target}" INTERFACE_MODULE_HAS_HEADERS) + if (qt_module) + set(wayland_include_dir "Qt${qt_module}/private") + elseif (is_for_module) + set(wayland_include_dir "QtWaylandClient/private") + endif() endif() add_custom_command( diff --git a/src/tools/qtwaylandscanner/Qt6WaylandCompositorMacros.cmake b/src/tools/qtwaylandscanner/Qt6WaylandCompositorMacros.cmake index b8771b95487..3fb08b3a743 100644 --- a/src/tools/qtwaylandscanner/Qt6WaylandCompositorMacros.cmake +++ b/src/tools/qtwaylandscanner/Qt6WaylandCompositorMacros.cmake @@ -1,5 +1,5 @@ function(qt6_generate_wayland_protocol_server_sources target) - cmake_parse_arguments(arg "" "" "FILES" ${ARGN}) + cmake_parse_arguments(arg "" "WAYLAND_INCLUDE_DIR" "FILES" ${ARGN}) if(DEFINED arg_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unknown arguments were passed to qt6_generate_wayland_protocol_server_sources: (${arg_UNPARSED_ARGUMENTS}).") endif() @@ -32,14 +32,17 @@ function(qt6_generate_wayland_protocol_server_sources target) COMMAND Wayland::Scanner --strict --include-core-only public-code < "${protocol_file}" > "${waylandscanner_code_output}" ) - # TODO: make this less hacky set(wayland_include_dir "") - get_target_property(qt_module ${target} _qt_module_interface_name) - get_target_property(is_for_module "${target}" INTERFACE_MODULE_HAS_HEADERS) - if (qt_module) - set(wayland_include_dir "Qt${qt_module}/private") - elseif (is_for_module) - set(wayland_include_dir "QtWaylandCompositor/private") + if(arg_WAYLAND_INCLUDE_DIR) + set(wayland_include_dir "${arg_WAYLAND_INCLUDE_DIR}") + else() + get_target_property(qt_module ${target} _qt_module_interface_name) + get_target_property(is_for_module "${target}" INTERFACE_MODULE_HAS_HEADERS) + if (qt_module) + set(wayland_include_dir "Qt${qt_module}/private") + elseif (is_for_module) + set(wayland_include_dir "QtWaylandCompositor/private") + endif() endif() add_custom_command(