summaryrefslogtreecommitdiffstats
path: root/src/compositor/Qt6WaylandCompositorMacros.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'src/compositor/Qt6WaylandCompositorMacros.cmake')
-rw-r--r--src/compositor/Qt6WaylandCompositorMacros.cmake49
1 files changed, 39 insertions, 10 deletions
diff --git a/src/compositor/Qt6WaylandCompositorMacros.cmake b/src/compositor/Qt6WaylandCompositorMacros.cmake
index 4e25916d4..05d16af6c 100644
--- a/src/compositor/Qt6WaylandCompositorMacros.cmake
+++ b/src/compositor/Qt6WaylandCompositorMacros.cmake
@@ -1,5 +1,12 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
function(qt6_generate_wayland_protocol_server_sources target)
- qt_parse_all_arguments(arg "qt6_generate_wayland_protocol_server_sources" "" "" "FILES" ${ARGN})
+ cmake_parse_arguments(arg "" "__QT_INTERNAL_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()
+
get_target_property(target_binary_dir ${target} BINARY_DIR)
if(NOT TARGET Wayland::Scanner)
@@ -10,6 +17,11 @@ function(qt6_generate_wayland_protocol_server_sources target)
message(FATAL_ERROR "qtwaylandscanner executable not found. Most likely there is an issue with your Qt installation.")
endif()
+ string(TOUPPER "${target}" module_define_infix)
+ string(REPLACE "-" "_" module_define_infix "${module_define_infix}")
+ string(REPLACE "." "_" module_define_infix "${module_define_infix}")
+ set(build_macro "QT_BUILD_${module_define_infix}_LIB")
+
foreach(protocol_file IN LISTS arg_FILES)
get_filename_component(protocol_name "${protocol_file}" NAME_WLE)
@@ -21,29 +33,46 @@ function(qt6_generate_wayland_protocol_server_sources target)
add_custom_command(
OUTPUT "${waylandscanner_header_output}"
#TODO: Maybe put the files in ${CMAKE_CURRENT_BINARY_DIR/wayland_generated instead?
- COMMAND Wayland::Scanner --strict --include-core-only server-header < "${protocol_file}" > "${waylandscanner_header_output}"
+ COMMAND Wayland::Scanner --include-core-only server-header < "${protocol_file}" > "${waylandscanner_header_output}"
+ DEPENDS ${protocol_file} Wayland::Scanner
)
add_custom_command(
OUTPUT "${waylandscanner_code_output}"
- COMMAND Wayland::Scanner --strict --include-core-only public-code < "${protocol_file}" > "${waylandscanner_code_output}"
+ COMMAND Wayland::Scanner --include-core-only public-code < "${protocol_file}" > "${waylandscanner_code_output}"
+ DEPENDS ${protocol_file} Wayland::Scanner
)
- # TODO: make this less hacky
set(wayland_include_dir "")
- #get_target_property(qt_module "${target}" QT_MODULE)
- get_target_property(is_for_module "${target}" INTERFACE_MODULE_HAS_HEADERS)
- if (is_for_module)
- set(wayland_include_dir "QtWaylandCompositor/private")
+ if(arg___QT_INTERNAL_WAYLAND_INCLUDE_DIR)
+ set(wayland_include_dir "${arg___QT_INTERNAL_WAYLAND_INCLUDE_DIR}")
+ else()
+ get_target_property(qt_module ${target} _qt_module_interface_name)
+ get_target_property(is_for_module "${target}" _qt_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(
OUTPUT "${qtwaylandscanner_header_output}"
- COMMAND Qt6::qtwaylandscanner server-header "${protocol_file}" "${wayland_include_dir}" > "${qtwaylandscanner_header_output}"
+ COMMAND Qt6::qtwaylandscanner server-header
+ "${protocol_file}"
+ --build-macro=${build_macro}
+ --header-path='${wayland_include_dir}'
+ > "${qtwaylandscanner_header_output}"
+ DEPENDS ${protocol_file} Qt6::qtwaylandscanner
)
add_custom_command(
OUTPUT "${qtwaylandscanner_code_output}"
- COMMAND Qt6::qtwaylandscanner server-code "${protocol_file}" "${wayland_include_dir}" > "${qtwaylandscanner_code_output}"
+ COMMAND Qt6::qtwaylandscanner server-code
+ "${protocol_file}"
+ --build-macro=${build_macro}
+ --header-path='${wayland_include_dir}'
+ > "${qtwaylandscanner_code_output}"
+ DEPENDS ${protocol_file} Qt6::qtwaylandscanner
)
target_sources(${target} PRIVATE