diff options
author | Robert Griebl <robert.griebl@qt.io> | 2022-06-29 14:19:07 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-06-30 20:52:59 +0000 |
commit | a26f5d83c4a079207f0d3cbe4b78507fc2ddf437 (patch) | |
tree | 2510311d5ce7220b4d7990473e797ba37c1b33cc /examples/applicationmanager/application-features | |
parent | c344046075fa3359dd4c70e92253f2edc5368579 (diff) |
Prevent linking of AppMan modules into user plugins
As the AppMan modules are static libraries, linking any of them
into a QML plugin (that later gets loaded into the system-ui) will
lead to a bunch of problems:
1) due to symbol duplication and duplicate static data, a lot of
singletons may exist twice
2) all static constructors (logging, crash-handling, etc.) are run
a second time, overriding any custom configuration that was applied
after config parsing.
If you are legitimately building a custom appman binary, a custom
launcher or a native app using launcher-lib, you need to flag this
via compile-time defines now:
Either AM_COMPILING_APPMAN or AM_COMPILING_LAUNCHER
AM_COMPILING_LAUNCHER is also used for native apps using launcher-lib.
Change-Id: I0c1a3fb7e0c7121f92d44c764c2c1eeb720e7041
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
(cherry picked from commit a1c90ed4605b08c39d380d2605d26b684d340c64)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples/applicationmanager/application-features')
3 files changed, 15 insertions, 0 deletions
diff --git a/examples/applicationmanager/application-features/doc/src/application-features.qdoc b/examples/applicationmanager/application-features/doc/src/application-features.qdoc index a2ccb99b..ed9afad1 100644 --- a/examples/applicationmanager/application-features/doc/src/application-features.qdoc +++ b/examples/applicationmanager/application-features/doc/src/application-features.qdoc @@ -93,6 +93,14 @@ needs a \c type window property to differentiate between normal windows and popu This application only works in multi-process mode, as application processes cannot be started in single-process mode. +Linking against the private application manager modules is prohibited by default to prevent +potential problems with duplicate symbols coming from QML plugins. However here building against +them is both intended and required, so we need to set the define \c AM_COMPILING_LAUNCHER: + +\quotefromfile applicationmanager/application-features/native/widgets/CMakeLists.txt +\skipuntil /allows us to link against/ +\printuntil /AM_COMPILING_LAUNCHER/ + The C++ code for the native widgets application is as follows: \quotefromfile applicationmanager/application-features/native/widgets/main.cpp diff --git a/examples/applicationmanager/application-features/native/widgets/CMakeLists.txt b/examples/applicationmanager/application-features/native/widgets/CMakeLists.txt index b4c977da..52de895e 100644 --- a/examples/applicationmanager/application-features/native/widgets/CMakeLists.txt +++ b/examples/applicationmanager/application-features/native/widgets/CMakeLists.txt @@ -22,6 +22,10 @@ find_package(Qt6 COMPONENTS AppManLauncherPrivate) qt_add_executable(widgets main.cpp ) + +# This define flags us as a "launcher" and allows us to link against the AppMan's private libraries +target_compile_definitions(widgets PRIVATE AM_COMPILING_LAUNCHER) + set_target_properties(widgets PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE diff --git a/examples/applicationmanager/application-features/native/widgets/widgets.pro b/examples/applicationmanager/application-features/native/widgets/widgets.pro index 9a93277d..784f63cf 100644 --- a/examples/applicationmanager/application-features/native/widgets/widgets.pro +++ b/examples/applicationmanager/application-features/native/widgets/widgets.pro @@ -4,6 +4,9 @@ QT += widgets appman_launcher-private SOURCES = main.cpp +# This define flags us as a "launcher" and allows us to link against the AppMan's private libraries +DEFINES *= AM_COMPILING_LAUNCHER + DESTDIR = $$OUT_PWD/../../apps/widgets target.path = $$[QT_INSTALL_EXAMPLES]/applicationmanager/application-features/apps/widgets |