aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt')
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt52
1 files changed, 25 insertions, 27 deletions
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}"