aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml/tutorials
diff options
context:
space:
mode:
Diffstat (limited to 'examples/qml/tutorials')
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt2
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt52
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/app.pro4
3 files changed, 28 insertions, 30 deletions
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt
index cf3d218c57..dc0b20dc21 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt
@@ -25,7 +25,7 @@ set_target_properties(chapter6-plugins PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(chapter6-plugins PUBLIC
+target_link_libraries(chapter6-plugins PRIVATE
Qt::Qml
Qt::Quick
)
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt
index 15f6dcc2c2..28efcaace8 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt
@@ -1,25 +1,3 @@
-# Generated from import.pro.
-
-cmake_minimum_required(VERSION 3.16)
-project(chartsplugin LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qml/tutorials/extending-qml/chapter6-plugins/Charts")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Qml)
-find_package(Qt6 COMPONENTS Quick)
-
qt6_add_qml_module(chartsplugin
VERSION 1.0
URI "Charts"
@@ -30,17 +8,37 @@ target_sources(chartsplugin PRIVATE
piechart.cpp piechart.h
pieslice.cpp pieslice.h
)
-set_target_properties(chartsplugin PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(chartsplugin PUBLIC
+
+target_link_libraries(chartsplugin PRIVATE
Qt::Core
Qt::Gui
Qt::Qml
Qt::Quick
)
+if(QT6_IS_SHARED_LIBS_BUILD AND APPLE)
+ get_target_property(is_bundle chapter6-plugins MACOSX_BUNDLE)
+ if(is_bundle)
+ # The application's main.cpp adds an explicit QML import path to look for qml modules under
+ # a PlugIns subdirectory in a macOS bundle.
+ # Copy the qmldir and shared library qml plugin.
+
+ set(charts_dir "$<TARGET_FILE_DIR:chartsplugin>")
+ set(chars_qmldir_file "${charts_dir}/qmldir")
+ set(app_dir "$<TARGET_FILE_DIR:chapter6-plugins>")
+ set(bundle_charts_dir "${app_dir}/../PlugIns/Charts")
+
+ add_custom_command(TARGET chartsplugin POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${bundle_charts_dir}
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ $<TARGET_FILE:chartsplugin> ${bundle_charts_dir}
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ ${chars_qmldir_file} ${bundle_charts_dir}
+ )
+ endif()
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLEDIR}/Charts")
install(TARGETS chartsplugin
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/app.pro b/examples/qml/tutorials/extending-qml/chapter6-plugins/app.pro
index b340981e42..8f53075a7d 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/app.pro
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/app.pro
@@ -3,9 +3,9 @@ QT += qml quick
# Ensure that the application will see the import path for the Charts module:
# * On Windows, do not build into a debug/release subdirectory.
-# * On OS X, add the plugin files into the bundle.
+# * On macOS, add the plugin files into the bundle, only in a shared build though
win32: DESTDIR = ./
-osx {
+macos:!qtConfig(static) {
charts.files = $$OUT_PWD/Charts
charts.path = Contents/PlugIns
QMAKE_BUNDLE_DATA += charts