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 <dominik.holland@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Robert Griebl 2021-06-16 03:44:22 +02:00
parent 7958ad1029
commit 90e5639701
3 changed files with 24 additions and 13 deletions

View File

@ -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
)

View File

@ -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(

View File

@ -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(