summaryrefslogtreecommitdiffstats
path: root/src/client/Qt6WaylandClientMacros.cmake
diff options
context:
space:
mode:
authorDavid Redondo <qt@david-redondo.de>2024-03-01 10:36:58 +0100
committerDavid Redondo <qt@david-redondo.de>2024-04-15 14:50:16 +0200
commit93e8b36ff5172115404de0a1eeb8174e6618f47e (patch)
tree45718124efaf46d8062b33f559c171c88279b4a6 /src/client/Qt6WaylandClientMacros.cmake
parentf6c4b2f0691ea0240566c068cf36ed95003153e1 (diff)
client: Add CMake options to control visibility of generated symbols
Using public-code by default is problematic if multiple libraries contain wayland interface definitions generated with public-code which exports the symbols of the interface definitions from the library. If not all libraries are build against the same protocol version and the symbol is resolved to a version generated from an older version of the protocol, then libwayland will detect a protocol error if a request or event from the newer version is used. This introduces two new options PRIVATE_CODE and PUBLIC_CODE to qt6_generate_wayland_protocol_client_sources which correspond to the wayland-scanner options. For backwards compatibility PUBLIC_CODE is the default. Change-Id: Ia30ec4b83419962b768207d7353c495e11b0268e Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/client/Qt6WaylandClientMacros.cmake')
-rw-r--r--src/client/Qt6WaylandClientMacros.cmake18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/client/Qt6WaylandClientMacros.cmake b/src/client/Qt6WaylandClientMacros.cmake
index 485322e6a..b4266c558 100644
--- a/src/client/Qt6WaylandClientMacros.cmake
+++ b/src/client/Qt6WaylandClientMacros.cmake
@@ -1,8 +1,14 @@
+
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
function(qt6_generate_wayland_protocol_client_sources target)
- cmake_parse_arguments(arg "NO_INCLUDE_CORE_ONLY" "__QT_INTERNAL_WAYLAND_INCLUDE_DIR" "FILES" ${ARGN})
+ cmake_parse_arguments(arg
+ "NO_INCLUDE_CORE_ONLY;PRIVATE_CODE;PUBLIC_CODE"
+ "__QT_INTERNAL_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,6 +40,14 @@ function(qt6_generate_wayland_protocol_client_sources target)
if (NOT arg_NO_INCLUDE_CORE_ONLY)
set(waylandscanner_extra_args "--include-core-only")
endif()
+
+
+ if (arg_PRIVATE_CODE)
+ set(wayland_scanner_code_option "private-code")
+ else()
+ set(wayland_scanner_code_option "public-code")
+ endif()
+
add_custom_command(
OUTPUT "${waylandscanner_header_output}"
#TODO: Maybe put the files in ${CMAKE_CURRENT_BINARY_DIR/wayland_generated instead?
@@ -43,7 +57,7 @@ function(qt6_generate_wayland_protocol_client_sources target)
add_custom_command(
OUTPUT "${waylandscanner_code_output}"
- COMMAND Wayland::Scanner ${waylandscanner_extra_args} public-code < "${protocol_file}" > "${waylandscanner_code_output}"
+ COMMAND Wayland::Scanner ${waylandscanner_extra_args} ${wayland_scanner_code_option} < "${protocol_file}" > "${waylandscanner_code_output}"
DEPENDS ${protocol_file} Wayland::Scanner
)