Commit Graph

27 Commits

Author SHA1 Message Date
Ulf Hermann 9ea281b3b5 Tests: Fix various CMake warnings
Add NO_GENERATE_EXTRA_QMLDIRS where applicable, make output directories
and module URIs match, and avoid setting QTP0004 to OLD since that just
generates a different warning. Also, explicitly include some .js files
in the qmldir, even if that means re-evaluation on each import.

Pick-to: 6.8
Change-Id: Ia03445ed7df85aa4d2032ba51675bab7501ad55b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-09-10 15:51:06 +02:00
Ari Parkkila cef6aa994d tests: Skip tst_qmlbasicapp when builtin data
Task-number: QTBUG-118680
Change-Id: Ie9a148b6a569e0f8022b141fd4beefb389db7df1
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2024-08-19 09:50:51 +03:00
Lucie Gérard 9c5fc88388 Correct license for test files
According to QUIP-18 [1], all test files should be
LicenseRef-Qt-Commercial OR GPL-3.0-only

[1]: https://contribute.qt-project.org/quips/18

Pick-to: 6.7
Task-number: QTBUG-121787
Change-Id: I26d72e8de04d4c7c57b3b7838af5d033265de5ba
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2024-02-27 10:32:21 +01:00
Alexandru Croitor 5818f97e70 CMake: Make qml tests standalone projects
Add the boilerplate standalone test prelude to each test, so that they
can be opened with an IDE without the qt-cmake-standalone-test script,
but directly with qt-cmake or cmake.

Boilerplate was added using the follow script:
https://git.qt.io/alcroito/cmake_refactor

Manual adjustments were made where the code was inserted in the wrong
location.

Task-number: QTBUG-93020
Change-Id: Ia68c9d263e7454f0c4a26c29b10f1c535d08e2f6
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
2023-07-05 12:34:11 +02:00
Ulf Hermann 2d44365f69 CMake: Allow omitting the version of QML modules
Also, drop all the VERSION 1.0 lines from the examples and tests. 1.0 is
actually a bad default version since it's before all the Qt versions.

[ChangeLog][QML] You can now omit the VERSION argument to
qt_add_qml_module(). This will automatically generate the highest
possible version.

Pick-to: 6.5
Task-number: QTBUG-99146
Change-Id: Ic10ec69b87c224e0e94e1785f65653815d4c778c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-01-27 19:16:39 +01:00
Lucie Gérard 1b9808737a Change the license of all CMakeLists.txt and *.cmake files to BSD
Task-number: QTBUG-105718
Change-Id: Id89ed14990804a5024183e75382cc539d4293da1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-09-07 17:01:30 +02:00
Fabian Kosmale 9bcd137da0 Avoid target name conflict
The qmlqtimeexampleplugin exists as a target name both in examples and
in a test; rename the one from the test.

Change-Id: I21b68f7d6228ceaee49ba28e55516b5b10ffce3a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-07-27 00:31:42 +02:00
Lucie Gérard 5a7b716474 Add license headers to cmake files
CMakeLists.txt and .cmake files of significant size
(more than 2 lines according to our check in tst_license.pl)
now have the copyright and license header.

Existing copyright statements remain intact

Task-number: QTBUG-88621
Change-Id: I72c89a98c42bbc9234d8495e9e503bec81d11037
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-08 10:41:06 +02:00
Ulf Hermann 6aad465f08 Introduce a sane resource path to qt_add_qml_module
Since "/qt" is reserved, we can use "/qt/qml" as the default path for
user QML modules.

[ChangeLog][QtQml] The AUTO_RESOURCE_PREFIX option was added to
qt_add_qml_module(). It places your QML modules in the otherwise
reserved resource directory /qt/qml. This directory is also added to the
default QML import path. By using it you don't have to specify custom
import paths anymore. Specifying neither AUTO_RESOURCE_PREFIX nor an
explicit RESOURCE_PREFIX will generate a warning now because such QML
modules are likely invisible in the resource file system.

Fixes: QTBUG-95145
Fixes: QTBUG-103452
Change-Id: Ie27dec5cbf34ea06258d55c659d202cdd61e54b2
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-06-23 09:35:57 +02:00
Lucie Gérard 0dc4fd240a Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.

Pick-to: 6.4
Task-number: QTBUG-67283
Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-06-11 08:05:15 +02:00
Assam Boudjelthia 9bdfea7f1f Android: various test fixes
2nd round of test failures fixes for Android. Mostly resource bundling
related issues still.

Pick-to: 6.2 6.3
Task-number: QTBUG-97056
Change-Id: I2fac0710a7b5528fcef4480babd0cbf749e488b3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-03-02 15:21:09 +02:00
Ulf Hermann bf38043b61 CMake: Include upper case .js and .mjs files in qmldir
You can use them as singletons.

Pick-to: 6.2 6.3
Fixes: QTBUG-100326
Change-Id: I8e07600657bd43ba8376279ffe39cfa5d3213c38
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-01 15:21:27 +01:00
Fabian Kosmale 96b1fef1ec Explicitly include qpropery.h in tests
We do not want to rely on the implicit import via qobject.h

Pick-to: 6.2
Change-Id: Ia6e5a601aa65b55c1edb886c667446f85736fc72
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-11-05 14:58:51 +01:00
Ulf Hermann 14a3b34906 Fix generation of names in qmldir files
Dots in QML module names are useless because you cannot instantiate a
component with a dot in its name. We might as well strip all the
extensions when adding components to a qmldir file. This takes care of
.ui.qml as well.

Furthermore, JavaScript files must not be listed because they cannot be
instantiated as QML components.

Change-Id: I9782420ea79fef1d5eedef97cf7a748b96ddbe2b
Pick-to: 6.2 6.2.0
Fixes: QTBUG-96301
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Tapani Mattila <tapani.mattila@qt.io>
2021-09-08 22:19:44 +02:00
Craig Scott f4d5e27080 Add NO_RESOURCE_TARGET_PATH option for executable backing targets
For tooling to work when a QML module is associated with an
executable rather than a library, it still needs the standard QML
directory structure in the build directory. But the source tree
is often not structured that way for the .qml files that are part
of the executable's QML module. The NO_RESOURCE_TARGET_PATH option
allows the project to essentially keep the structure from the
source tree in the resources, but use the standard QML structure
in the build directory for tooling.

Task-number: QTBUG-95598
Pick-to: 6.2
Change-Id: I53145ced0e57d7ea4795bb5260dd464f6458f444
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-08-18 11:31:54 +10:00
Alexandru Croitor 643e093a6d CMake: Use renamed qt6_add_plugin PLUGIN_TYPE option
Task-number: QTBUG-95170
Pick-to: 6.2
Change-Id: I6126387bcfc8c93211d782edd9fc127fba88f66f
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-08-10 16:00:08 +02:00
Alexandru Croitor 1b206f9bdf CMake: Replace add_library with qt6_add_library where appropriate
Augments 1bd408d6f7eac7908c77a0129e0173c280fce55b in qtbase

Pick-to: 6.2
Fixes: QTBUG-95171
Change-Id: I57a88ee5b211085193b8827e9d9e35392e92185a
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-06 17:25:12 +02:00
Craig Scott 73c76005e6 Add NO_PLUGIN option to qt6_add_qml_module()
The new option allows the caller to state more clearly that they do not
want a plugin at all. Previously, the NO_CREATE_PLUGIN_TARGET option
had to be given to prevent the command from trying to create a plugin
target, but that option is meant for when the project will create the
plugin target later.

Now that the caller has a way to explicitly say they don't want a
plugin, require PLUGIN_TARGET to be given if NO_CREATE_PLUGIN_TARGET
is present. This forces the project to provide the name of the plugin
target that they will be responsible for creating.

Fixes: QTBUG-95141
Pick-to: 6.2
Change-Id: I84e036074f3e2785f17a8d33ad87ee0b7e016173
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-03 12:28:56 +10:00
Craig Scott 40f4f8d6ec Fix plugin importing in tst_qmlbasicapp
We get no automatic static plugin importing and linking for QML, so we
have to do it manually ourselves. This includes all of the Qt QML
modules we reference too.

This also uncovered that the tst_qmlbasicapp test requires QtQuick, but
no check was added in ccd3907b12 where
the dependency was introduced. Add that check so that the test is now
only added if QtQuick is enabled.

And because the tst_qmlbasicapp test defines static plugins,
we need CMake 3.21 or later to avoid linker command line
ordering issues. Make adding the test conditional on that too.

Pick-to: 6.2
Change-Id: I0f41352fb2fe9bd6548bf30eb8ed93366cefd263
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-29 20:31:05 +10:00
Fabian Kosmale b292e11239 Fix building tst_basicapp in toplevel builds
Pick-to: 6.2
Change-Id: I9b45d59e5d90e764c78736b19598e9ffc7928d41
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-21 13:20:58 +02:00
Fabian Kosmale ccd3907b12 Add test for Q_IMPORT_QML_PLUGIN
The CMake API needs to be adjusted to make this more convenient, but the
test shows that the basic idea works.

Pick-to: 6.2
Change-Id: I523069f33f8e3a8418224b8872b191d4229548b0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-07-20 10:43:56 +02:00
Craig Scott 4e18e7d377 CMake: Add missing dependencies for tst_qmlbasicapp
The test executable needs to depend on the QML module and its plugin
because there is no direct link at the library level. The dependency
exists at the QML level, so we need to tell CMake or else the plugin
may not get built and that will result in failures due to not being
able to load the QML plugin at run time.

Pick-to: 6.2
Change-Id: Iafd1b8c15e3b2c227c7654d6fe39340e686f72a1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-07-20 16:33:48 +10:00
Ulf Hermann 79d0517a12 CMake: Always add the qmldir to the resource file system
We want to be able to load modules directly from the resource file
system, no matter if we build statically or dynamically. It's limited by
the need to load plugins, of course, but as most plugins are optional an
application can easily go this way and never include any plain QML files
in an application bundle.

Pick-to: 6.2
Change-Id: I94657a43b47e442722a83e1fb306680aa50b1bc3
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2021-07-01 13:25:56 +02:00
Ulf Hermann bae18ecd34 QtQml: Key plugins by URI where possible
This allows us to associate different qmldir files for the same module
with one another. Typically there is one qmldir file in the resource
file system and one in the QML import path. We cannot load plugins for
the latter, but usually we have already loaded any plugins we need. Now
we can detect this.

This requires us to construct a proper URI for implicit imports. The
easiest way to do this is to just use the URI from the qmldir if
available.

Modules with versions encoded in their paths and modules with multiple
plugins cannot be resolved by URI only. These continue to be keyed by
path. However, as we do not generate such modules, we will not
automatically get two instances of those, and we won't have to fall back
from one to the other.

Pick-to: 6.2
Change-Id: Ic79add936d263a8e559fd998fca15a6ae160952e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-06-30 10:08:03 +02:00
Ulf Hermann 88424ba1bf CMake: Add qmldir classname entry only if there is a plugin
A class name without a plugin is pointless.

Pick-to: 6.2
Change-Id: I3cfd95bc7d9dd9e80d7f23fbd6e2c2b2b855763d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-06-24 10:53:18 +02:00
Ulf Hermann c9e901db89 CMake: Copy RESOURCES files to the build directory, too
We need to treat them exactly like QML_FILES.

Pick-to: 6.2
Change-Id: I5582ad933c844c55f9015478672607e6d1218d84
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-06-24 10:53:18 +02:00
Ulf Hermann 5e78dc847d Add basic QML application to test CMake API for QML modules
An application with two modules which allows us to check that all the
files end up in the right places.

Pick-to: 6.2
Change-Id: I58557d453e644e13f2eb646ec3195bba2654f569
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-06-24 10:53:18 +02:00