aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quickcontrols/wearable
diff options
context:
space:
mode:
authorOlivier De Cannière <olivier.decanniere@qt.io>2023-07-04 14:51:34 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-07-07 11:07:12 +0000
commit5ae6ed476a0e0ac3ba805c289bf918f71377727b (patch)
tree24e34be45a05b81280fd5be988f2878780bb7963 /examples/quickcontrols/wearable
parentad529b77f26e4ae3e76384c02d58c6f0548111d8 (diff)
Fix wearable example on macOS and Windows
- Use add_qml_module_to_macos_app_bundle and copy other things from examples like attachedstyleproperties and painteditem in order to get it to work on macOS. - Move qt_standard_project_setup() before qt_add_qml_module() (which is called by the three add_subdirectory calls). This is required to avoid issues with subdirectories on Windows. Change-Id: Ie0d859c743d0b8b798238346cc2c738ece362c99 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit fb64096a25f8e847b26c17a5888321e2fbbc4fbb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples/quickcontrols/wearable')
-rw-r--r--examples/quickcontrols/wearable/CMakeLists.txt24
-rw-r--r--examples/quickcontrols/wearable/wearable.cpp3
2 files changed, 22 insertions, 5 deletions
diff --git a/examples/quickcontrols/wearable/CMakeLists.txt b/examples/quickcontrols/wearable/CMakeLists.txt
index 7b337ee61d..833b1b409f 100644
--- a/examples/quickcontrols/wearable/CMakeLists.txt
+++ b/examples/quickcontrols/wearable/CMakeLists.txt
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
-project(wearableexample LANGUAGES CXX)
+project(wearableexample VERSION 1 LANGUAGES CXX)
set(CMAKE_AUTOMOC ON)
@@ -12,14 +12,14 @@ endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols/wearable")
-add_subdirectory(Wearable)
-add_subdirectory(WearableSettings)
-add_subdirectory(WearableStyle)
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick QuickControls2)
qt_standard_project_setup()
+add_subdirectory(Wearable)
+add_subdirectory(WearableSettings)
+add_subdirectory(WearableStyle)
+
qt_add_executable(wearableexample WIN32 MACOSX_BUNDLE
wearable.cpp
)
@@ -38,8 +38,22 @@ if(UNIX AND NOT APPLE AND CMAKE_CROSSCOMPILING)
target_link_libraries(wearableexample PRIVATE Qt6::QuickTemplates2)
endif()
+set_target_properties(wearableexample PROPERTIES
+ MACOSX_BUNDLE TRUE
+ MACOSX_BUNDLE_GUI_IDENTIFIER "io.qt.examples.wearable"
+ MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
+ MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
+)
+
install(TARGETS wearableexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
+
+include(../../quick/shared/QtBundleQmlModuleForMacOS.cmake)
+
+set(app_target "wearableexample")
+add_qml_module_to_macos_app_bundle("${app_target}" "wearableplugin" "Wearable")
+add_qml_module_to_macos_app_bundle("${app_target}" "wearablesettingsplugin" "WearableSettings")
+add_qml_module_to_macos_app_bundle("${app_target}" "wearablestyleplugin" "WearableStyle")
diff --git a/examples/quickcontrols/wearable/wearable.cpp b/examples/quickcontrols/wearable/wearable.cpp
index eea815eff8..bec613d55f 100644
--- a/examples/quickcontrols/wearable/wearable.cpp
+++ b/examples/quickcontrols/wearable/wearable.cpp
@@ -26,6 +26,9 @@ int main(int argc, char *argv[])
//! [icons]
QQmlApplicationEngine engine;
+#ifdef Q_OS_MACOS
+ engine.addImportPath(app.applicationDirPath() + "/../PlugIns");
+#endif
engine.loadFromModule("Wearable", "Main");
return app.exec();