aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-06-16 14:49:20 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2021-06-16 16:34:51 +0200
commit8bf2209c34f838dc601cff577b0a29a251cef466 (patch)
tree2bfda632400e4cb06c585169f506c07b77adb832
parentfa0a6426f7a63db61358ebcf4d67538d049a1491 (diff)
Port to newer CMake API
- opt out of deprecated internal functions - port deprecated API to newer equivalent - use new QML CMake API Additionally, disable the Qt 6 check: By using REQUIRED in find_package, cmake will abort if no suitable Qt 6 version can be found. The old check would instead get confused if there was a Qt 5 qmake in the path, even when a perfectly suitable Qt 6 were too exist somewhere else. Change-Id: I3f2658836f13f607757a4609a121a00159e6f140 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--CMakeLists.txt17
-rw-r--r--src/CMakeLists.txt54
-rw-r--r--tests/auto/CMakeLists.txt4
3 files changed, 22 insertions, 53 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4e43ec4..62c8797 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,19 +2,7 @@
cmake_minimum_required(VERSION 3.15.0)
-execute_process (
- COMMAND $ENV{CMAKE_PREFIX_PATH}/bin/qmake -query QT_VERSION
- OUTPUT_STRIP_TRAILING_WHITESPACE
- OUTPUT_VARIABLE qt_version
-)
-
-string(SUBSTRING ${qt_version} 0 1 qt_major_version)
-if (${qt_major_version} EQUAL 5)
- message(FATAL_ERROR
- "You're building TreeView using Qt version ${qt_version} (read "
- "from CMAKE_PREFIX_PATH/bin/qmake). When using Qt 5, you need to "
- "build with qmake instead.")
-endif()
+set(QT_NO_INTERNAL_COMPATIBILITY_FUNCTIONS TRUE)
include(.cmake.conf)
project(QtTreeView
@@ -24,7 +12,8 @@ project(QtTreeView
LANGUAGES CXX C
)
-find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core Quick QuickControls2 QuickTest)
+find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core Quick
+ QuickControls2 QuickTest REQUIRED)
find_package(Qt6 ${PROJECT_VERSION} CONFIG OPTIONAL_COMPONENTS Widgets)
if(NOT TARGET Qt::Quick)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1e354ea..30d41c6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,48 +1,28 @@
-# Generated from src.pro.
-
-#####################################################################
-## qquicktreeviewplugin Plugin:
-#####################################################################
+set_source_files_properties(TreeView.qml PROPERTIES
+ QT_QML_SOURCE_VERSION "2.15;6.0"
+)
-qt_add_qml_module(qquicktreeviewplugin
+qt6_add_library(qquicktreeview)
+set_property(TARGET qquicktreeview PROPERTY AUTOMOC ON)
+target_link_libraries(qquicktreeview PUBLIC
+ Qt::Core
+ Qt::Gui
+ Qt::Qml
+ Qt::Quick
+ Qt::QuickPrivate
+)
+qt_add_qml_module(qquicktreeview
URI "QtQuick.TreeView"
VERSION "${CMAKE_PROJECT_VERSION}"
CLASSNAME QQuickTreeViewPlugin
- GENERATE_QMLTYPES
- INSTALL_QMLTYPES
+ QML_FILES TreeView.qml
SOURCES
qquicktreemodeladaptor.cpp qquicktreemodeladaptor_p.h
qquicktreeview.cpp qquicktreeview_p.h
qquicktreeview_p_p.h
- qquicktreeviewplugin.cpp
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::Quick
- Qt::QuickPrivate
)
-#### Keys ignored in scope 1:.:.:src.pro:<TRUE>:
-# OTHER_FILES = "qmldir" "$$QML_FILES" "../README.md" "../Marketplace.md" "../Marketplace.json"
-# QML_FILES = "TreeView.qml"
-# QML_IMPORT_MAJOR_VERSION = "6"
-# QML_IMPORT_NAME = "QtQuick.TreeView"
-# TARGETPATH = "QtQuick/TreeView"
-# TEMPLATE = "lib"
-
-set(qml_files
- "TreeView.qml"
-)
-set_source_files_properties(TreeView.qml PROPERTIES
- QT_QML_SOURCE_VERSION "2.15;6.0"
-)
-
-qt6_target_qml_files(qquicktreeviewplugin
- FILES
- ${qml_files}
-)
-qt_add_docs(qquicktreeviewplugin
- doc/treeview.qdocconf
-)
+qt_internal_add_docs(qquicktreeviewplugin
+ doc/treeview.qdocconf
+ )
diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt
index f2b0cd8..ebcaa74 100644
--- a/tests/auto/CMakeLists.txt
+++ b/tests/auto/CMakeLists.txt
@@ -4,7 +4,7 @@
## tst_treeview Test:
#####################################################################
-qt_add_test(tst_treeview
+qt_internal_add_test(tst_treeview
SOURCES
testmodel.cpp testmodel.h
tst_treeview.cpp
@@ -21,7 +21,7 @@ set(qmake_immediate_resource_files
"data"
)
-qt_add_resource(tst_treeview "qmake_immediate"
+qt_internal_add_resource(tst_treeview "qmake_immediate"
PREFIX
"/"
FILES