aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/models/objectlistmodel/CMakeLists.txt
diff options
context:
space:
mode:
authorOliver Eftevaag <oliver.eftevaag@qt.io>2021-11-11 16:36:38 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-11-12 15:41:53 +0000
commit0a86a3bdb4536b8d3b29e42fbca3cf46530cd9cc (patch)
treecbe7ece7ef05eeaf3ea458df3568e9f342117ad5 /examples/quick/models/objectlistmodel/CMakeLists.txt
parent3b0b18a5cd54b2f73c54de8530a49d4137d49e73 (diff)
Model examples: use new cmake api
The models directory contains 3 subdirectories with an example project in each. This patch updates the CMakeLists.txt files to use qt_add_qml_module() instead of the old qt_add_resources(). In order to achieve intercompatibility with both cmake and qmake, I had to do some slight modifications to both the .qrc files and the url path used to set the source to the QQuickView. Task-number: QTBUG-98130 Change-Id: I13d1c01a0eda181823f394bc2a4259ce98abd4f8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit a155b3bc3ee161fbb7ff1760781577700b0aafce) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples/quick/models/objectlistmodel/CMakeLists.txt')
-rw-r--r--examples/quick/models/objectlistmodel/CMakeLists.txt32
1 files changed, 10 insertions, 22 deletions
diff --git a/examples/quick/models/objectlistmodel/CMakeLists.txt b/examples/quick/models/objectlistmodel/CMakeLists.txt
index 60fdeea219..8dbee3ae0b 100644
--- a/examples/quick/models/objectlistmodel/CMakeLists.txt
+++ b/examples/quick/models/objectlistmodel/CMakeLists.txt
@@ -7,7 +7,6 @@ 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")
@@ -15,20 +14,13 @@ endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/models/objectlistmodel")
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Qml)
-find_package(Qt6 COMPONENTS Quick)
+find_package(Qt6 COMPONENTS Core Gui Qml Quick)
-qt_add_executable(objectlistmodel
- dataobject.cpp dataobject.h
+qt_add_executable(objectlistmodelexample WIN32 MACOSX_BUNDLE
+ dataobject.cpp
main.cpp
)
-set_target_properties(objectlistmodel PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(objectlistmodel PUBLIC
+target_link_libraries(objectlistmodelexample PUBLIC
Qt::Core
Qt::Gui
Qt::Qml
@@ -37,18 +29,14 @@ target_link_libraries(objectlistmodel PUBLIC
# Resources:
-set(objectlistmodel_resource_files
- "view.qml"
-)
-
-qt6_add_resources(objectlistmodel "objectlistmodel"
- PREFIX
- "/"
- FILES
- ${objectlistmodel_resource_files}
+qt_add_qml_module(objectlistmodelexample
+ URI objectlistmodel
+ VERSION 1.0
+ QML_FILES
+ "view.qml"
)
-install(TARGETS objectlistmodel
+install(TARGETS objectlistmodelexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"