From ec57196980e6a32fce3c56ec3c9f8183c7bcaad1 Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Tue, 3 Sep 2019 13:25:05 +0200 Subject: Add qt6_add_qml_module() public API Add qt6_add_qml_module() as a public API for building QML modules. Since the shared implementation details are small, it was easier to just reimplement the shared code than to unmangle the more complicated version we use to build Qt from QtBuild. This patch includes an example conversion. Changes for pro2cmake will follow in a separate patch in qtbase. Change-Id: I942526cc7d978e2d8309b506e785f9c1509d0bbc Reviewed-by: Simon Hausmann --- .../qml/tutorials/extending-qml/CMakeLists.txt | 5 +-- .../chapter6-plugins/.prev_CMakeLists.txt | 43 +++++++++++++++++++++ .../extending-qml/chapter6-plugins/CMakeLists.txt | 44 ++++++++++++++++++++++ .../chapter6-plugins/import/CMakeLists.txt | 42 +++++++++++++++++++++ 4 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 examples/qml/tutorials/extending-qml/chapter6-plugins/.prev_CMakeLists.txt create mode 100644 examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt create mode 100644 examples/qml/tutorials/extending-qml/chapter6-plugins/import/CMakeLists.txt (limited to 'examples/qml') diff --git a/examples/qml/tutorials/extending-qml/CMakeLists.txt b/examples/qml/tutorials/extending-qml/CMakeLists.txt index 8f8395ac95..8e41f3d77d 100644 --- a/examples/qml/tutorials/extending-qml/CMakeLists.txt +++ b/examples/qml/tutorials/extending-qml/CMakeLists.txt @@ -5,7 +5,4 @@ add_subdirectory(chapter2-methods) add_subdirectory(chapter3-bindings) add_subdirectory(chapter4-customPropertyTypes) add_subdirectory(chapter5-listproperties) -# special case begin -# Needs public QML plugin API -# add_subdirectory(chapter6-plugins) -# special case end +add_subdirectory(chapter6-plugins) diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/.prev_CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter6-plugins/.prev_CMakeLists.txt new file mode 100644 index 0000000000..33f79b03f5 --- /dev/null +++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/.prev_CMakeLists.txt @@ -0,0 +1,43 @@ +# Generated from chapter6-plugins.pro. + +cmake_minimum_required(VERSION 3.14) +project(chapter6-plugins LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +set(INSTALL_EXAMPLEDIR "examples") + +find_package(Qt6 COMPONENTS Qml) +find_package(Qt6 COMPONENTS Quick) + +add_qt_gui_executable(chapter6-plugins + main.cpp +) +target_link_libraries(chapter6-plugins PUBLIC + Qt::Qml + Qt::Quick +) + +# Resources: +set(app_resource_files + "app.qml" +) + +QT6_ADD_RESOURCES(chapter6-plugins "app" + PREFIX + "/" + FILES + ${app_resource_files} +) + + +install(TARGETS chapter6-plugins + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) +add_subdirectory(import) diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt new file mode 100644 index 0000000000..6a2b487009 --- /dev/null +++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt @@ -0,0 +1,44 @@ +# Generated from chapter6-plugins.pro. + +cmake_minimum_required(VERSION 3.14) +project(chapter6-plugins LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +set(INSTALL_EXAMPLEDIR "examples") + +find_package(Qt6 COMPONENTS Qml) +find_package(Qt6 COMPONENTS Quick) + +add_qt_gui_executable(chapter6-plugins + main.cpp +) +target_link_libraries(chapter6-plugins PUBLIC + Qt::Qml + Qt::Quick +) + +# Resources: +set(app_resource_files + "app.qml" +) + +QT6_ADD_RESOURCES(chapter6-plugins "app" + PREFIX + "/" + FILES + ${app_resource_files} +) + + +install(TARGETS chapter6-plugins + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) + +add_subdirectory(import) diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/CMakeLists.txt new file mode 100644 index 0000000000..938340eb87 --- /dev/null +++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/CMakeLists.txt @@ -0,0 +1,42 @@ +# Generated from import.pro. + +cmake_minimum_required(VERSION 3.14) +project(chartsplugin LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +set(INSTALL_EXAMPLEDIR "examples") + +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 + OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../Charts" + VERSION 1.0 + URI "Charts" + INSTALL_LOCATION ${INSTALL_EXAMPLEDIR} +) + +target_sources(chartsplugin PRIVATE + chartsplugin.cpp chartsplugin.h + piechart.cpp piechart.h + pieslice.cpp pieslice.h +) +target_link_libraries(chartsplugin PUBLIC + Qt::Core + Qt::Gui + Qt::Qml + Qt::Quick +) + +install(TARGETS chartsplugin + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) -- cgit v1.2.3