aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLeander Beernaert <leander.beernaert@qt.io>2019-09-03 13:25:05 +0200
committerLeander Beernaert <leander.beernaert@qt.io>2019-09-19 08:06:24 +0000
commitec57196980e6a32fce3c56ec3c9f8183c7bcaad1 (patch)
treee416385c724ca5ca07ae57e5c8c77ec58e79f0a1 /examples
parent92025df4a52a2cf82e9a538968a8969cac08554c (diff)
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 <simon.hausmann@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/.prev_CMakeLists.txt4
-rw-r--r--examples/qml/tutorials/extending-qml/CMakeLists.txt5
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/.prev_CMakeLists.txt43
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt44
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/import/CMakeLists.txt42
-rw-r--r--examples/quick/.prev_CMakeLists.txt2
-rw-r--r--examples/quick/CMakeLists.txt2
-rw-r--r--examples/quick/customitems/CMakeLists.txt5
-rw-r--r--examples/quick/customitems/painteditem/CMakeLists.txt55
-rw-r--r--examples/quick/particles/CMakeLists.txt4
10 files changed, 193 insertions, 13 deletions
diff --git a/examples/.prev_CMakeLists.txt b/examples/.prev_CMakeLists.txt
index 2209576c8c..c2ccea65c1 100644
--- a/examples/.prev_CMakeLists.txt
+++ b/examples/.prev_CMakeLists.txt
@@ -1,5 +1,7 @@
# Generated from examples.pro.
+qt_examples_build_begin()
+
add_subdirectory(qml)
if(TARGET Qt::QuickTest)
add_subdirectory(qmltest)
@@ -7,3 +9,5 @@ endif()
if(TARGET Qt::Quick)
add_subdirectory(quick)
endif()
+
+qt_examples_build_end()
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}"
+)
diff --git a/examples/quick/.prev_CMakeLists.txt b/examples/quick/.prev_CMakeLists.txt
index 9ca9009184..5299e95ae2 100644
--- a/examples/quick/.prev_CMakeLists.txt
+++ b/examples/quick/.prev_CMakeLists.txt
@@ -35,6 +35,6 @@ endif()
if(TARGET Qt::Widgets)
add_subdirectory(embeddedinwidgets)
endif()
-if(QT_FEATURE_opengles2 OR (QT_FEATURE_opengl AND TARGET Qt::QuickWidgets) OR (QT_FEATURE_opengles3 AND TARGET Qt::Widgets))
+if(TARGET Qt::Widgets AND (QT_FEATURE_opengl OR QT_FEATURE_opengles2 OR QT_FEATURE_opengles3) AND (QT_FEATURE_opengles2 OR QT_FEATURE_opengles3 OR TARGET Qt::QuickWidgets))
add_subdirectory(quickwidgets)
endif()
diff --git a/examples/quick/CMakeLists.txt b/examples/quick/CMakeLists.txt
index 889b46fa3e..a733e42f1c 100644
--- a/examples/quick/CMakeLists.txt
+++ b/examples/quick/CMakeLists.txt
@@ -38,6 +38,6 @@ endif()
if(TARGET Qt::Widgets)
add_subdirectory(embeddedinwidgets)
endif()
-if(QT_FEATURE_opengles2 OR (QT_FEATURE_opengl AND TARGET Qt::QuickWidgets) OR (QT_FEATURE_opengles3 AND TARGET Qt::Widgets))
+if(TARGET Qt::Widgets AND (QT_FEATURE_opengl OR QT_FEATURE_opengles2 OR QT_FEATURE_opengles3) AND (QT_FEATURE_opengles2 OR QT_FEATURE_opengles3 OR TARGET Qt::QuickWidgets))
add_subdirectory(quickwidgets)
endif()
diff --git a/examples/quick/customitems/CMakeLists.txt b/examples/quick/customitems/CMakeLists.txt
index 86cb951940..4afbfe3f6b 100644
--- a/examples/quick/customitems/CMakeLists.txt
+++ b/examples/quick/customitems/CMakeLists.txt
@@ -1,7 +1,4 @@
# Generated from customitems.pro.
-# special case begin
-# Needs public QML Plugin API
-#add_subdirectory(painteditem)
-# special case end
+add_subdirectory(painteditem)
add_subdirectory(maskedmousearea)
diff --git a/examples/quick/customitems/painteditem/CMakeLists.txt b/examples/quick/customitems/painteditem/CMakeLists.txt
new file mode 100644
index 0000000000..48fb6bc3ea
--- /dev/null
+++ b/examples/quick/customitems/painteditem/CMakeLists.txt
@@ -0,0 +1,55 @@
+# Generated from painteditem.pro.
+
+cmake_minimum_required(VERSION 3.14)
+project(qmltextballoonplugin 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(qmltextballoonplugin
+ OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/TextBalloonPlugin"
+ VERSION 1.0
+ URI "TextBalloonPlugin"
+ INSTALL_LOCATION ${INSTALL_EXAMPLEDIR}
+)
+
+target_sources(qmltextballoonplugin PRIVATE
+ TextBalloonPlugin/plugin.h
+ textballoon.cpp textballoon.h
+)
+target_link_libraries(qmltextballoonplugin PUBLIC
+ Qt::Core
+ Qt::Gui
+ Qt::Qml
+ Qt::Quick
+)
+
+# Resources:
+set(painteditem_resource_files
+ "textballoon.h"
+ "textballoons.qml"
+)
+
+QT6_ADD_RESOURCES(qmltextballoonplugin "painteditem"
+ PREFIX
+ "/painteditem"
+ FILES
+ ${painteditem_resource_files}
+)
+
+
+install(TARGETS qmltextballoonplugin
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/quick/particles/CMakeLists.txt b/examples/quick/particles/CMakeLists.txt
index 77ae5fad28..9bc4e894a5 100644
--- a/examples/quick/particles/CMakeLists.txt
+++ b/examples/quick/particles/CMakeLists.txt
@@ -4,7 +4,5 @@ add_subdirectory(affectors)
add_subdirectory(customparticle)
add_subdirectory(emitters)
add_subdirectory(imageparticle)
-# Needs public QML Plugin API
-# add_subdirectory(itemparticle)
-# special case begin
+add_subdirectory(itemparticle)
add_subdirectory(system)