Commit Graph

94 Commits

Author SHA1 Message Date
Friedemann Kleint
97bfacf1e2 tests: Remove remains of qmake conversion from CMakeLists.txt files
Pick-to: 6.5
Change-Id: I8d106554bb86ac1ec9bb7a4083de4c376bcbab1d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-02-17 21:56:49 +01:00
Alexey Edelev
19ddc0b225 Add forwarding of CMake variables to ABI-specific external projects
The 'QT_ANDROID_MULTI_ABI_FORWARD_VARS' variable allows to forward
variable values to ABI-specific external projects. The variable accepts
names of variables that needs to be forwarded.

Pick-to: 6.4
Task-number: QTBUG-107893
Change-Id: Iaa4fa7e98ad0df956d90f91e157edb561183c795
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-12-08 23:24:22 +01:00
Amir Masoud Abdol
d77ce33082 Move Some of the Private CMake Helper Scripts from bin/ to libexec/
After this change, private CMake scripts are mostly live in
`libexec/`, except the `qt-cmake` which will stay in `bin/`.
This doesn't affect the Windows configuration.

- `qt-cmake` stays in `bin/`
- `qt-configure-module` moves into `libexec/`
- `qt-cmake-private` moves into `libexec/`
- `qt-cmake-private-install.cmake` moves into `libexec/`
- `qt-cmake-standalone-test` moves into `libexec/`
- `qt-internal-configure-test` moves into `libexec/`

In cases where `QT_GENERATE_WRAPPER_SCRIPTS_FOR_ALL_HOSTS` is set to
ON, e.g., ANDROID, WASM, both Batch and Bash files will be generated
and placed in `bin/` and `libexec/` accordingly; in both cases,
qt-cmake and qt-cmake.bat will be in `bin/` anyway.

[ChangeLog][CMake] The private Qt CMake scripts, i.e.,
qt-configure-module, qt-cmake-private, qt-cmake-private-install.cmake,
qt-cmake-standalone-test and qt-internal-configure-test were moved
into $prefix/libexec on Unix platforms.

Fixes: QTBUG-107621
Change-Id: Ic4f4ec85f64d2ede0e208bca928959e30be906a6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-12-05 18:02:59 +00:00
Alexandru Croitor
9b2c82cc84 CMake: Add auto test for qt_add_resources dependency rebuilding
Make sure that touching any file that is part of a qrc resource
actually rebuilds the resource and the target that depends on the
resource.

Pick-to: 6.4
Task-number: QTBUG-107687
Task-number: QTBUG-108113
Change-Id: I1153dc13fee44ffe59d2685a8cb33303538b026c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-12-02 20:53:01 +01:00
Johannes Kauffmann
a9fa999f79 tests: fix configuring with -no-feature-gui
Pick-to: 6.2 6.4
Change-Id: I99765d38c9c37f1fe17b15f7736e4c78c7ffac20
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-10-29 01:04:09 +02:00
Amir Masoud Abdol
2625e5f050 Make the PREFIX Parameter of the qt_add_resources Optional
The `rcc_PREFIX` will be set to `/` if it is not passed to the
function and it is not defined in `QT_RESOURCE_PREFIX`.

I also removed an unnecessary check of the `rcc_PREFIX`.

[ChangeLog][QtCore][CMake] The `PREFIX` parameter of the
`qt_add_resources` is now optional. If not passed, and
`QT_RESOURCE_PREFIX` is not defined, `/` will be used as the path
prefix.

Fixes: QTBUG-104938
Change-Id: I6524ab5dc54f035272e4c2e3154eb67591efb650
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-10-25 16:39:25 +02:00
Joerg Bornemann
5430fb2243 CMake: Set RPATH of deployed plugins on Linux
When deploying into some directory structure where CMAKE_INSTALL_LIBDIR
is different from Qt's lib dir, we need to set the RPATH of installed
plugins such that Qt libraries are found.

We do this using CMake's undocumented file(RPATH_SET) command and pray
that this command is safe to use across current and future CMake
versions.  For CMake versions < 3.21, we use patchelf, which must be
installed on the host system.

The adjustment of rpaths can be turned on explicitly by setting
QT_DEPLOY_FORCE_ADJUST_RPATHS to ON.

The usage of patchelf can be forced by setting QT_DEPLOY_USE_PATCHELF to
ON regardless of the CMake version.

Change-Id: I62ced496b4c12bf6d46735d2af7ff35130148acb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-10-15 13:00:04 +02:00
Joerg Bornemann
5ca714318c Don't set QT_PLUGIN_PATH in the deployment test's run environment
Otherwise we don't properly test whether the deployed executable can run
without adjusting the environment.

We temporarily adjust the test_widgets_app_deployment test and set
CMAKE_INSTALL_LIBDIR to make the test pass.  It would now fail on Linux
distros where CMAKE_INSTALL_LIBDIR defaults to "lib64" but Qt is built
with lib dir "lib".  The next commit removes this hack.

Change-Id: I63c79ef1ee23ffaeed881337fde6e9d889ecc0fe
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-10-15 12:59:59 +02:00
Alexey Edelev
b89d63515b Replace the syncqt.pl script with syncqt tool
syncqt.pl adds an extra dependency on perl when building Qt. Modern C++
provides the convenient cross-platform way to access a filesystem and
to use regular expressions, so we may replace the perl script with C++
application. The syncqt executable is built at configure time and
installed as QtCore tool. It's running at configure time to deliver the
required header files for IDE to build a consistent code model and at
the build time to keep tracking changes in header files and generate
the missing aliases without reconfiguring. 'syncqt' only parses header
files from a CMake build tree, so the resulting Qt installation only
contains interfacing headers that belong to the platform that Qt is
built for. 'sync.profile' files are not used as the 'source of truth'
for sync qt procedure anymore, all the necessary information is taken
from either CMake files at configure time or from the module header
files while parsing them.

syncqt.pl is still in place since it's required as fallback solution
for a smooth transition to the new syncqt implementation for all qt
repositories.

This patchset only enables the C++ based syncqt for 'qtbase'
repository.

From the performance perspective C++ version works faster then perl
script, also the configure time is reduced significally on subsequent
reconfigurations - up x2 times faster when re-configuring repository,
but it also takes time to compile the tool itself the first time.
Numbers for qtbase:
           syncqt.pl  syncqt.cpp
 initial:  0m16,035s  0m20,413s
 reconfig: 0m6,819s   0m3,725s

The syncing procedure can be run separately for each module using
<ModuleName>_sync_headers targets. The 'sync_headers' target can be
used to sync all the modules at once.

Task-number: QTBUG-87480
Task-number: QTBUG-103196
Change-Id: I8c938bcaf88a8713b39bbfd66d9e7ef12b2c3523
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-27 13:12:11 +02:00
Joerg Bornemann
c9c04291f5 CMake: Add Linux support to qt_deploy_runtime_dependencies
Before this change, qt_deploy_runtime_dependencies supported Windows and
macOS only.  We add a generic deployment method implemented in
cmake-language with file(GET_RUNTIME_DEPENDENCIES).  This deployment
method is now enabled for shared builds on Linux.

The file(GRD) command requires that the EXECUTABLE argument points to
the executable in the build directory.

Only libraries in Qt's installation directory are considered for
deployment.  This includes Qt's own libraries and also things like
libicu*.so we're shipping with the installer.

Unlike macdeployqt and windeployqt, the generic
qt_deploy_runtime_dependencies does not yet support deploying
translations.  We will catch up on this in a later commit.

Change-Id: Iea23abcdba774d4c1885c8d2c243eb3e48fb7fae
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-15 12:55:23 +02:00
Lucie Gérard
32df595275 Change the license of all CMakeLists.txt and *.cmake files to BSD
Task-number: QTBUG-105718
Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-23 23:58:42 +02:00
Alexandru Croitor
9e3e167223 CMake: Add simple widgets qmake iOS build test
Build a simple widgets qmake project when targeting iOS in the CI.
This ensure we don't introduce basic regressions in the .pri / .prl
file generation.

Make sure to target the ios simulator, so we don't require any
code signing or provisioning profiles.

Pick-to: 6.4
Fixes: QTBUG-96058
Change-Id: I1a5564e838a5ce3cac89a37a5a4ddee74d3400f3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-17 21:21:57 +02:00
Joerg Bornemann
9ce5709fb1 CMake: Support big resources in qt_add_resources
[ChangeLog][CMake] The target-based variant of qt6_add_resource gained
the option BIG_RESOURCES. This can be used instead of
qt6_add_big_resources, which is not target-based.

Fixes: QTBUG-100268
Change-Id: Ib3fa783cbfbfd10f59c2f952bc88508a91f25e26
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-09 15:21:52 +02:00
Alexandru Croitor
6423a657c7 CMake: Fix mockplugins test not to fail in a non-prefix build
Explicitly running the install step would fail in a non-prefix build.
Do it conditionally on the no_prefix feature.

Pick-to: 6.4
Change-Id: I78cd63f51c499a0df451b08290c6dfc84e52666c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-05 18:10:00 +02:00
Lucie Gérard
fb1b20eab3 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: I3b98cdc55ead806ec81ce09af9271f9b95af97fa
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-03 17:14:55 +02:00
Alexandru Croitor
21bffeec90 CMake: Add deployment auto test
Add a cmake test that builds a simple widgets application, installs
it, in a shared Qt build deploys the runtime dependencies and then
runs it to confirm that the app works.
With a static Qt, the installation of the runtime dependencies is
skipped, but the app should still run.

The test is expected to pass only when targeting Windows and macOS
(both when using shared and static Qt).

Pick-to: 6.3
Task-number: QTBUG-98545
Change-Id: I41b616e1e1fc463d57c64be9273ed4dc755e9187
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-03-16 15:56:17 +01:00
Alexey Edelev
63b8840380 Fix dependency chain that collects the metatype json files
cmake_automoc_parser has the logic preventing the run of moc with the
--collect-json parameter if metatype json files are not changed.
This logic only verify if the file list is changed but not their
content. This change adds a timestamp file that contains the last
metatype json file timestamp that was modified during the last
cmake_automoc_parser run. The logic still prevents of running
'moc --collect-json' when the list of metatype json files is not
changed, but also checks if their content is no changed.

Another approach it to generate the depfile that can be utilized by
CMake in add_custom_command as DEPFILE argument. But this concept only
works from the second build attempt because of an issue related to
dyndep.

Pick-to: 6.2
Fixes: QTBUG-98532
Change-Id: I713f8bfa9ae769cefe0beac0b7fa19750b00a765
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-12-02 16:34:23 +01:00
Alexandru Croitor
0da123d67b CMake: Bump almost all cmake_minimum_required calls to 3.16
Needed for subsequent change that will check and error out if the
version is lower than 3.16. We do that to ensure all policies
introduced by CMake up to version 3.16 have their behavior set to
NEW.

Pick-to: 6.2
Task-number: QTBUG-95018
Change-Id: Ieaf82c10987dd797d86a3fd4a986a67e72de486a
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-09-22 19:36:49 +02:00
Alexandru Croitor
80705298ca CMake: Build a subset of tests when targeting iOS in the CI
Add infrastructure to build cmake auto tests in the CI when targeting
iOS.
Currently the are only CI instructions for qtbase.
More work is needed to make it work for other repos.

With this change, we will build a single Widgets application targeting
the iOS simulator. We can't target the device SDK in the CI because
signing fails due to a missing signing certificate and provisioning
profile.

The Coin instructions will now set a QT_BUILD_ENVIRONMENT=ci env var
whose value will be checked in _qt_internal_test_expect_pass, to
ensure we build for the simulator SDK when using a universal Qt.
Without this, xcodebuild will try to build with the device SDK and
fail to build the project.

Pick-to: 6.2
Task-number: QTBUG-95839
Change-Id: Ib39c9527b107b2004746ccbdc9d9d1d658f88c76
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-26 16:40:15 +02:00
Alexandru Croitor
d654ff4e99 CMake: Disable test_QT_TESTCASE_BUILDDIR cmake build test
CMake 3.21.0 + Ninja now pass absolute source file paths to the
compiler which causes __FILE__ to be absolute and qFindTestData
to ignore any QT_TESTCASE_BUILDDIR value.

This causes the test to fail, because it won't find test data in the
custom specified location.

Disable the test for now.

Amends 70464b355e

Pick-to: 6.2
Task-number: QTBUG-95268
Task-number: QTBUG-95018
Change-Id: If99035e897ac1d5f153d4e19c94e4355f88970af
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-07-22 15:56:37 +02:00
Alexey Edelev
9bd418aeab Implement generating of a module cpp export header
Add an option that automatically generates an export header for a Qt
module. The header contains only Q_DECL_EXPORT/Q_DECL_IMPORT related
content, so it's not a full replacement of 'global' header files.

Task-number: QTBUG-90492
Change-Id: I250d1201b11d4096b7e78e61cbf4565945fe6517
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-24 20:40:49 +02:00
Alexandru Croitor
561fc8107f CMake: Allow promoting the Qt libraries to be global targets
User projects can set the QT_PROMOTE_TO_GLOBAL_TARGETS variable to
true so that the various imported targets created by find_package(Qt6)
are promoted to global targets.

This would allow a project to find Qt packages in a subdirectory scope
while using those Qt targets from a different scope.

E.g. it fixes errors like

  CMake Error at CMakeLists.txt:5 (target_link_libraries):
  Error evaluating generator expression:

    $<TARGET_OBJECTS:Qt6::Widgets_resources_1>

  Objects of target "Qt6::Widgets_resources_1" referenced but no such
  target exists.

when trying to use a static Qt from a sibling scope.

Various 3rd party dependency targets (like Atomic or ZLIB) are not
made global due to limitations in CMake, but as long as those targets
are not mentioned directly, it shouldn't cause issues.

The targets are made global in the generated
QtFooAdditionalTargetInfo.cmake file.

To ensure that resource object libraries promoted, the generation
of the file has to be done at the end of the defining scope
where qt_internal_export_additional_targets_file is called,
which is achieved with a deferred finalizer.

Replaced all occurrences of target promotion with a helper function
which allows tracing of all promoted targets by specifying
--log-level=debug to CMake.

Pick-to: 6.2
Fixes: QTBUG-92878
Change-Id: Ic4ec03b0bc383d7e591a58c520c3974fbea746d2
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-16 13:22:17 +02:00
Alexey Edelev
19e789bace Implement propagation of object files to the end-point executable
This proposal collects all the resource objects to the qt-specific
property of the static libraries. This is done to avoid littering
of other static libraries and put resource object files to the
source part of the linker line when linking the end-point
executable.
The way we link object resource libraries is changed back to the
target_link_libraries approach as we may omit using finalizers
with linkers other than ld. Users may enforce finalizers by calling
the qt6_enable_resource_objects_finalizer_mode function if need.

Refactor tests related to the static resources.

Amends ddaa7150d8

Task-number: QTBUG-93002
Change-Id: I74135e291cd82fb54d1b284b4b4a1e002b1fef98
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-27 14:28:17 +02:00
Alexandru Croitor
3a62f9e0c9 CMake: Resurrect test_import_plugins cmake build tests
Now that we run tests for static Qt builds in the CI, it makes sense
to restore the CMake build tests that check that static plugin
importing works correctly.

Resurrect the previously commented out test_import_plugins project and
port the mockplugins qmake projects to CMake.

mockplugins is a CMake project that uses the internal Qt CMake API to
build and install some Qt modules and plugins.

test_import_plugins depends on that test (via a CMake fixture) to
build public projects that use those plugins.

The installation of the mockplugins modules pollutes the Qt install
prefix, but in the CI that only happens on the test VM, which means
the release packages are not affected.

Locally on a developer machine the Qt install path will be polluted,
but it's not that much of a big deal. We could try and address that in
a future change by using the QT_ADDITIONAL_PACKAGES_PREFIX_PATH
functionality added for Conan to allow the installation of Qt packages
into a non-standard prefix.

Task-number: QTBUG-87580
Task-number: QTBUG-92933
Change-Id: I0841064a60a5ffba5118640d3197527a38ba6c30
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-05-11 14:35:30 +02:00
Alexandru Croitor
22a992cb12 CMake: Skip building CMake build tests in a prefix in-tree config
The Qt CMake packages are not installed yet, so the CMake build
projects can't find Qt and fail to configure.

Skip the CMake build tests in a prefix in-tree configuration and issue
a warning for informational purposes.

Change-Id: Ie5cb5b9f6f1d8ec258b70528680e31c711c20f85
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-05-11 14:35:30 +02:00
JiDe Zhang
22e967c304 fix: The QtStartUpFunction function may be called repeatedly
Don't call pre routine function in qAddPreRoutine if
the qt_call_pre_routines is not called

Pick-to: 6.1 6.0
Task-number: QTBUG-90341
Change-Id: I0ee70561dc57b857f8b3b1cf42c9dfe0cf45bd49
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-04-23 18:51:30 +02:00
Juha Vuolle
ed72147149 Fix qtbase cmake autotest
The testcase relied on having optional packages, and that the last
package in that list was found. Otherwise the version numbers of
the found modules were not set.

Change-Id: I76743fd029d6eed2f4b347280591e6fdaed19053
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-04-19 20:56:25 +03:00
Alexey Edelev
fcb766f588 Add test of the static plugin with resources
The test follows up the discussion about tests related to the static
plugin resources:

https://codereview.qt-project.org/c/qt/qtbase/+/341203/6/tests/auto/other/init_resources_static_plugin/CMakeLists.txt#1

It emulates the static plugin that contains resource files. Since the
test already exposed few issues related to the resource object linking
it makes sense to have it in test set.

Change-Id: I62621c2db1eae6ae5842ba52035774a662d93423
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-04-12 17:19:41 +02:00
Alexey Edelev
70464b355e Specify QT_TESTCASE_BUILDDIR for Qt::Test users implicitly
QT_TESTCASE_BUILDDIR was implicitly defined by Qt::Test target for
library users in Qt5. By default, this definition will point to
CMAKE_CURRENT_BINARY_DIR. This logic works similarly to qmake logic.

From user's perspective it might be useful to not rely on standard
search paths, but specify own. This can be done by setting the
QT_TESTCASE_BUILDDIR property for the user's target. CMake will
substute the value of the QT_TESTCASE_BUILDDIR property into the
QT_TESTCASE_BUILDDIR definition.

The implicit QT_TESTCASE_SOURCEDIR also seems to be useful. According
to the current logic, it points to CMAKE_CURRENT_SOURCE_DIR.

Fixes: QTBUG-92079
Change-Id: I8a9065f08e859c713b3c8cc08142a9ced0677770
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-04-08 13:16:41 +02:00
Alexey Edelev
cbdce59cd2 Add the SIMULATE_IN_SOURCE argument to _qt_internal_test_expect_pass
test_QFINDTESTDATA builds the project in the source tree, this is
necessary because the test requires relative paths to the source file
names. This function could be useful for other tests, so it makes sense
to extend the _qt_internal_test_expect_pass/fail macros to support
build in the source tree.
Note that, the SIMULATE_IN_SOURCE argument doesn't build the test in
the existing source tree, but copies source files to the build tree
first to do not litter the source directory.

Change-Id: I16e790d74be2a0c5ca0593e0f88580dbe09882b9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-04-07 17:56:57 +02:00
Alexandru Croitor
d0c2425d79 CMake: Choose better defaults for qt_add_plugin STATIC/SHARED
There was a recent behavior change where the public CMake API
qt_add_plugin API took into account the value of BUILD_SHARED_LIBS
to decide whether the plugin should be a static or shared library.

Instead, use the following new behavior

 - If no explicit option STATIC / SHARED option is passed, default to
   whatever flavor Qt was built as.
   Aka if Qt was configured with -shared, qt_add_plugin defaults
   to creating shared plugins. If it's a -static Qt, create static
   plugins.
 - If an explicit STATIC / SHARED option is set, override the default
   computed value with the given value.

As a result BUILD_SHARED_LIBS does not affect Qt plugins anymore. This
is more in line with Qt expectations.

Add SHARED as a new valid option to pass to qt_add_plugin (it wasn't
before).

Add tests to check for the above behavior.

Amends aa4a1006cb

Pick-to: 6.1
Fixes: QTBUG-92361
Task-number: QTBUG-88763
Change-Id: Iae806024ddd5cf10cfe58ddbcebd2818084b0bd7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-04-07 10:10:55 +02:00
Alexey Edelev
fec5b8e81c Rework the failure macros in the Qt CTest kit
The _qt_internal_test_expect_fail macro fails when the test fails
during the configuration step. Rename this macro to
_qt_internal_test_expect_build_fail and add
the _qt_internal_test_expect_fail macro that expects inverted test
result.

Change-Id: I4635e99152f7a32f5c48202e84fec59800453d34
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-03-17 13:34:39 +01:00
Alexey Edelev
fd5006eb48 Fix qt_add_big_resources with namespace builds
Add INTERFACE_COMPILE_DEFINITIONS of Qt6::Core to generated rcc object
libraries. This propagates QT_NAMESPACE definition to the object
library.

Fixes: QTBUG-85620
Change-Id: I252d1aaee7b19a49bc321fdd271a5d85a34bf67f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-01-19 14:17:55 +01:00
Andreas Buhr
92c066b1e5 Modify test_QFINDTESTDATA to not leave files in source tree
test_QFINDTESTDATA is a test which is built and run in the source
tree. It tests usage of relative paths of the Ninja generator, which
only occurs when building in the source tree, so this test cannot
be done outside of the source tree.
Developer's expectation is, however, that an out-of-source build
does not change the source tree. Having "git status" showing
differences after running the tests is irritating. This patch removes
the in-source build files after executing the test.

Change-Id: Ia9fd368c9d54b97a415b63254b45e17bc95ecf45
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-09 20:30:05 +01:00
Alexey Edelev
558f5a2d7b CMake: Add support for -binary option for generated resources
Add handling of -binary flag in qt6_add_resources for generated
resource file variant.

If -binary argument is provided in OPTIONS section of
qt6_add_resources function, it will be passed to rcc as argument.
File path to output .rcc could be additionally specified by
DESTINATION argument. Extra target generated_<resource_filename>
will be added to project's 'all' set.

Implement tests for new functionality.

Fixes: QTBUG-87644
Change-Id: Id1313da499d86f82859d1757c3cfae2d84e894d4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-12 22:11:37 +01:00
Alexandru Croitor
fbf11e86ef CMake: Fix cmake tests for no-widgets and no-gui configurations
Task-number: QTBUG-86053
Change-Id: I108977546304f203f6e2b7e983bb909b76626a9f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-11-10 16:53:31 +01:00
Alexandru Croitor
081ec14b25 CMake: Clean up the public API a bit
Add some missing versionless functions.
Rename some functions that are not meant to be public API, and their
usages.

Task-number: QTBUG-86827
Change-Id: Ifb66c04cd7598d83fe80c01a92ab2d269ebaf396
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-01 14:57:12 +02:00
Alexandru Croitor
5e0129f63c CMake: Fix configuration of CMake tests in-build-tree
Qt6 package was not found the tests were configured in-tree as opposed
to standalone tests.
Use the same trick we do for building examples in-tree.
Specify the path to the build tree packages, and don't create targets.

Amends 96e3ee0659

Change-Id: Ia60de416ce0afff5bd40be8c0c6e3c7898fd7ebf
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-07-20 18:12:23 +02:00
Alexandru Croitor
96e3ee0659 CMake: Get tests/auto/cmake tests working
The tests/auto/cmake project can be configured separately as a
standalone project with qt-cmake, or as part of the overall qtbase
standalone tests.

To do that a bunch of things were done
- Ported all Qt5 strings to Qt6
- Replaced in all projects the use of add_definitions and
  include_directories with a target based approach, except for 2 tests
  where we check that the old-style approach works, otherwise the
  tests would file
- Removed some (possibly unneeded) EGL / OpenGL tests
- Fixed some C++ code
- Added setup code to tests/auto/cmake/CMakeLists.txt to figure out
  which modules are available and should be tested
- Fixed Qt6CTestMacros.cmake to be loaded by Qt6Core
- Removed the CMake tests to not be run in qmake builds of Qt because
  they would fail anyway
- Enabled the CMake tests to be part of standalone tests
- Disabled auto-passing of the C and CXX compiler cache vars when
  cross-compiling so that the tests can somewhat pass on boot2qt.
  This is the issue we encountered in
  e2b2cd9397
- Ultimately disabled tests for boot2qt, because the -rpath-link
  flag is not generated by CMake for some reason.
- Added code to setup the environment when running an executable that
  was built as part of the test, so that the proper Qt libraries are
  found. This handles both the standalone tests case and separate
  project case.

The remaining unported tests are test_import_plugins which requires
quite a bit of work to get some modules and plugins built that were
done as part of the qmake .pro files, test_plugins that checks
some Network plugins which I'm not sure about, and
test_add_big_resource which doesn't work with namespaced builds
and there's no good way of detecting those at the moment either.

Change-Id: Ic8809c72817d1db81af6c6014c11df6473ad8c75
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-07-17 09:43:04 +02:00
Eirik Aavitsland
56f40cdca6 Remove the openglextensions module
[ChangeLog][General] The QtOpenglExtensions module has been
discontinued. It provided only convenience functionality for certain
direct OpenGL usage. With the new RHI graphics API abstraction, that
is no longer a primary use case. Applications that still need to
access that API have a number of alternative options, including
QOpenGLExtraFunctions.

Fixes: QTBUG-84085
Change-Id: I272af61c69ebcec207b576d67d08b59623d485ec
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-06-10 09:35:04 +02:00
Qt Forward Merge Bot
025e88bfe5 Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I003c0d6271c6444748bf30b4331eca3fb2410f44
2020-05-05 19:51:50 +02:00
Kai Koehne
fcceae605a Allow switching of QT_NO_CREATE_VERSIONLESS_TARGETS
Fixes: QTBUG-83774
Change-Id: Ib3f2507a917046426b94a779e205012ce52cbfe9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-05-05 08:33:40 +02:00
Kai Koehne
de67bca44e Remove qt6_use_modules
qt5_use_modules has been deprecated in 2013 (commit d9ea4bb144)
and removed for the first time in 2018, but then brought back - see
discussion in https://lists.qt-project.org/pipermail/development/2018-June/032837.html .

Anyhow, I think we can finally put it to a rest in Qt 6.

Change-Id: I770f7e93406ad68535d1d90e4a3bacfb920e2d5a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-25 08:39:43 +01:00
Kyle Edwards
63d9cd17d0 CMake: Add support for auto-importing plugins in CMake
This commit adds transitive dependencies to the plugins, so that a
sane set of default plugins get auto-imported when linking against a
module. It also provides a new function, qt5_import_plugins(), which
allows you to override the set of plugins that get imported. The decision
of whether or not to import a specific plugin is based on several custom
target properties and a very clever generator expression.

Note that this change only imports plugins on static Qt builds. It
does nothing on shared Qt builds, as the shared libraries already have
their own plugin import mechanism.

[ChangeLog][CMake] Added ability to auto-import non-qml plugins on
CMake builds

Task-number: QTBUG-38913
Task-number: QTBUG-76562
Change-Id: I2d6c8908b521cf6ba1ebbbc33a87cb7ddd9935cf
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-12 18:23:58 +02:00
Liang Qi
7029ecade9 cmake: correct version dependency for qt5_add_big_resources
qt5_add_big_resources is only available if using CMake 3.9 and later.

This amends cdccd0222b.

Task-number: QTBUG-55680
Task-number: QTBUG-75806
Change-Id: Ibba7af6ee7edfb226368937d543b7ec5cc93eb16
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2019-05-20 12:49:37 +02:00
Oswald Buddenhagen
5a03b75c50 Merge dev into 5.12
Change-Id: I63f632b595f66d2fc93e9aa713500e3799e3df2a
2018-08-21 02:32:50 +02:00
Andy Shaw
cdccd0222b Add support for big resources with CMake
Task-number: QTBUG-55680
Change-Id: I09570a4e959ffd0e6d378bc315b13d57baaa82e8
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
2018-08-16 08:56:27 +00:00
Kevin Funk
48eb08d255 tests: Fix top-level CMakeLists.txt
Problem:
 CMake Error in CMakeLists.txt:
  A logical block opening on the line

    .../qtbase/tests/auto/cmake/CMakeLists.txt:149 (if)

  is not closed.

Broken by change 02ed1b36da

Change-Id: I6c04721edbccaa9fcdb53af92d33dfa87eeaebb8
Reviewed-by: Rolf Eike Beer <eb@emlix.com>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2018-08-15 11:08:34 +00:00
Kevin Funk
a834b4d245 CMake: Restore qt5_use_modules() function
It appears that in the 5 years since we deprecated this function, people
have not stopped using it. The removal of qt5_use_modules() caused lots of
troubles in packages still using it when they were compiled against Qt 5.11.0.

Instead, let's revive this function and keep it for the Qt5 life time.

See discussion on qt-development mailing list:
  http://lists.qt-project.org/pipermail/development/2018-June/032837.html

Change-Id: Ic263e3bb6706268cb9ea38a0711665f166a3aa9e
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-06-15 07:29:09 +00:00
Kevin Funk
02ed1b36da Remove CMake code for CMake < 3.1
This removes the following functions from Qt5CoreMacros:
- qt5_use_modules(...)

Task-number: QTBUG-63519
Change-Id: I59769060a3a93686bf319b558c0ede55755fdb70
Reviewed-by: David Faure <david.faure@kdab.com>
2018-03-24 22:31:18 +00:00