This somewhat indicates the progress of configuring a specific
repo and the slower period of time when configuring examples
in-tree.
Pick-to: 6.5
Change-Id: I643536c4ebc865933730b7af2a1d0c56bbbf2912
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
AUTOUIC doesn't handle relative paths to .ui files in parent
directories when using Ninja Multi-Config.
The designer tool in qttools has such a ui file. This leads to the
following error when trying to build qttools together with examples as
ExternalProjects and Ninja Multi-Config:
ninja: error: 'src/designer/src/designer/designer_autogen/
include_Debug/ui_preferencesdialog.h', needed by
'src/designer/src/designer/designer_autogen:Debug',
missing and no known rule to make it
Until cmake is fixed, we can work around the issue by not adding
designer as a dependency when building EP examples, because no example
tries to use the app.
We can't exclude all apps from example dependencies because some
modules use qt_internal_add_app for tools as well, which are called
from public CMake API and also examples.
An example of this is qtapplicationmanager.
Given that we can't exclude all apps, introduce a function to
allow skipping single targets when building EP examples.
This will allow excluding designer specifically.
The examples will now depend on a new ${repo}_src_for_examples target
rather than ${repo}_src, which will exclude skipped targets.
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Task-number: QTBUG-110369
Change-Id: I2f900253bbf7bac917f2293ef604ab3ea8f298e1
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Add it globally so that each module using tracepoints don't have to
add it themselves to each modules configure.cmake.
Pick-to: 6.5
Change-Id: Id58cfaff5cd715b2667da2470001d646117f9f28
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
qt-cmake-standalone-test uses add_subdirectory call when evaluating the
project. This leads to an error if users try to use path to
CMakeLists.txt as an argument, instead of directory when configuring
standalone tests with qt-cmake-standalone-test. It makes sense to check
if the user-specified path points to CMakeLists.txt and cut the
filename part when calling add_subdirectory.
Pick-to: 6.5 6.4 6.2
Change-Id: I6b9ac0ca8323eaf11f219eb1e6bed3057120a231
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
As far as I can tell nothing uses TYPE anymore.
[ChangeLog][QtCore][CMake] The deprecated TYPE option of the
qt_add_plugin() has been removed. You can specify the plugin
type using the PLUGIN_TYPE option instead.
Change-Id: I786fbc772a23ae0037d9a4cf68018e3af5cb061d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Building repo targets may be incomplete as we skip adding
INTERFACE_LIBRARIES as dependencies. This leads to the missing
artifacts belonging to HEADER_MODULES. It seems reasonable and safe to
include INTERFACE_LIBRARIES in the list of dependencies of the repo targets.
Pick-to: 6.4 6.2
Task-number: QTBUG-108815
Change-Id: I83f44018f42dcf2fb1e3299461e17ef53e79c2e5
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
In the case of re-doing, `configure` and `configure.bat` pass an extra
parameter to the `QtProcessConfigureArgs.cmake`. As a result, CMake
removes CMakeCache.txt and CMakeFiles/ before the reconfiguration. If
the user is using CMake 3.24 or newer, this is achieved by passing
the `--fresh` option to CMake call. In older CMake(s), CMakeCache.txt
and CMakeFiles/ found in CMAKE_BINARY_DIR will be removed using a
file(REMOVE_RECURSIVE call.
[ChangeLog] The -redo option now additionally removes existing
CMakeCache.txt file, and CMakeFiles/ directory, and recreates them from
scratch.
Task-number: QTBUG-108287
Change-Id: I11a5c8f9df1247d11eb7097552e6764463583346
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Instead of constantly trying to find packages by calling
qt_find_package on each reconfiguration, record which packages were
found during initial configuration. Then on a second reconfiguration,
skip looking for packages that were not found on the initial
configuration.
This speeds up reconfiguration on certain platforms and repos.
Here are some stats for my macOS qtbase build.
not skip 3.69s user 4.96s system 98% cpu 8.750 total
skip 2.69s user 1.00s system 97% cpu 3.792 total
Top-level build with -submodules=qtquick3d
not skip 15.03s user 10.58s system 97% cpu 26.334 total
skip 13.87s user 5.16s system 96% cpu 19.724 total
Note this is a behavior change from how find_package is used in most
CMake projects, where if a package was previously missing, the
developer can just install the package and reconfigure to pick it up.
With this change, they will first have to remove their CMakeCache.txt
file and configure from scratch, or remove the
QT_INTERNAL_PREVIOUSLY_FOUND_PACKAGES cache variable and reconfigure.
For this reason, we enable this behavior by default only in
-developer-builds.
Builders can also opt in or out by setting the
QT_INTERNAL_SAVE_PREVIOUSLY_FOUND_PACKAGES variable to either ON or
OFF.
Note this behavior does not apply to user projects, or direct
find_package calls (as opposed to qt_find_package).
Fixes: QTBUG-107251
Change-Id: Iee9c5d120eb09e2a94eebb059a2174ef6b241e03
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
If I understood the function correctly, then the example was not quite
right.
Change-Id: I6b6a4845c5ded2a058050dfbecf5db158d32d12a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Each module now identifies its actions during the configuration by a
prefix, e.g., `[QtBase]`. In addition,
- I have slightly modified some of the `message()` commands to get
a more coherent output.
- `syncqt.cpp` prints its output as WARNING if any
Change-Id: I3922d75a668d94f402068f4121751b7fcb6522b4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
As stated in `QtBuildInternalsConfig.cmake`, `cmake_minimum_required`
versions should be synced with `qtbase/.cmake.conf`, but it wasn't at
the moment.
Change-Id: I8100370778707d46abe973b681fd4aba182a7513
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
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>
We forwarded the compiler path to the EP but not the flags that might
have been set via the CXX environment variable.
Make sure to also forward the flags.
Pick-to: 6.2 6.3 6.4
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I0fbf9b595f7885014b1f09d158db52e56a3d5243
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
When building qtsvg examples as external projects on Windows
with Ninja Multi-Config in a prefix build on the CI, the build would
fail with an error message like:
ninja: error:
'C:/Users/qt/work/qt/qtsvg/lib/Qt6SvgWidgets.lib', needed by
'RelWithDebInfo/svgviewer.exe', missing and no known rule to make it
This can be reproduced locally on Windows if one calls
'ninja svgviewer' instead of just 'ninja'. I wasn't able to reproduce
it on macOS, although I have seen some peculiarities in the
dependencies there as well.
External project examples depend on the ${repo_name}_src custom
target to ensure all Qt modules are built, so one would expect that
dependency to be sufficient.
While trying to figure out what's going wrong, I noticed that running
'ninja -t query qtsvg_src:Debug' showed dependencies on Release
libraries, which should not happen. The :Release target looked fine
though.
I'm still not quite sure why the Release libraries are not built
on the first ninja run, despite the example having a proper dependency
on qtsvg:Release.
Running 'ninja svgviewer' a few more times ends up succeeding at one
point, because the SvgWidgets Release library does get built in
parallel with the failing example, and the next rebuild would
succeed.
While trying to fix the :Debug target to have proper dependencies, I
noticed that we add dependencies to the ${repo_name}_src custom target
via the DEPENDS option of add_custom_target(). That is incorrect,
that option should only be used for file level dependencies.
For target dependencies, add_dependencies should be used.
Doing that fixed both the :Debug dependencies as well as the Windows
issue, which is good enough for me.
Amends 08f46bb400
Pick-to: 6.2 6.3 6.4
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I1888681e2e9362d3237acbdacc83222d6a60b48e
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
When using qt-cmake-standalone-test, we didn't tell CMake to use the
same C++ language standard that Qt used when it was configured.
We did tell CMake to do that when configuring tests with
qt-internal-configure-tests via the qt_build_tests macro.
To ensure the proper standard is set, we also need to
find_package(Qt6Core), because the std flag is derived from the
QT_FEATURE_cxxyz flag which is set by Core.
Change-Id: Ia41f2a24983ddab0107a6446743f7b054df8c033
Pick-to: 6.2 6.3 6.4
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
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>
Add an option to limit the number of tests for building and testing
Android multi-ABI configurations in CI. Currently only Core tests
supposed to run.
Change-Id: Ibb8a41d60d108259ef2675ec54bde2482f87c8b2
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
In cross-compilation, the CMAKE_FIND_ROOT_PATH will have path to the
host Qt and examples build will pick up wrong Qt6Config.cmake unless
the build dir path is prepended.
Pick-to: 6.4 6.3 6.2
Fixes: QTBUG-104270
Change-Id: I7fc7499369a2e5446e1c5257155f81c72716fef7
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
When recording which package version to look for in
QtFooModuleDependencies.cmake and other files like it,
instead of using PROJECT_VERSION, use the version of the
package that contains the dependency.
For example if we're hypothetically building the qtdeclarative repo
from the 6.4 branch, against an installed 6.2 qtbase, then
the Qt6QmlModuleDependencies.cmake file will have a
find_package(Qt6Core 6.2) call because qtdeclarative's
find_package(Qt6Core) call found a 6.2 Core when it was configured.
This allows switching the versioning scheme of specific Qt modules
that might not want to follow the general Qt versioning scheme.
The first candidate would be QtWebEngine which might want to
follow the Chromium versioning scheme, something like
Qt 6.94.0 where 94 is the Chromium major version.
Implementation notes.
We now record the package version of a target in a property
called _qt_package_version. We do it for qt modules, plugins,
3rd party libraries, tools and the Platform target.
When we try to look up which version to write into the
QtFooModuleDependencies.cmake file (or the equivalent Plugins and
Tools file), we try to find the version
from a few sources: the property mentioned above, then the
Qt6{target}_VERSION variable, and finally PROJECT_VERSION.
In the latter case, we issue a warning because technically that should
never have to happen, and it's a bug or an unforeseen case if it does.
A few more places also need adjustments:
- package versions to look for when configuring standalone
tests and generating standalone tests Config files
- handling of tools packages
- The main Qt6 package lookup in each Dependencies.cmake files
Note that there are some requirements and consequences in case a
module wants to use a different versioning scheme like 6.94.0.
Requirements.
- The root CMakeLists.txt file needs to call find_package with a
version different from the usual PROJECT_VERSION. Ideally it
should look for a few different Qt versions which are known to be
compatible, for example the last stable and LTS versions, or just
the lowest supported Qt version, e.g. 6.2.6 or whenever this change
would land in the 6.2 branch.
- If the repository has multiple modules, some of which need to
follow the Qt versioning scheme and some not,
project(VERSION x.y.z) calls need to be carefully placed in
subdirectory scopes with appropriate version numbers, so that
qt_internal_add_module / _tool / _plugin pick up the correct
version.
Consequences.
- The .so / .dylib names will contain the new version, e.g. .so.6.94
- Linux ELF symbols will contain the new versions
- syncqt private headers will now exist under a
include/QtFoo/6.94.0/QtFoo/private folder
- pri and prl files will also contain the new version numbers
- pkg-config .pc files contain the new version numbers
- It won't be possible to write
find_package(Qt6 6.94 COMPONENTS WebEngineWidgets) in user code.
One would have to write find_package(Qt6WebEngineWidgets 6.94)
otherwise CMake will try to look for Qt6Config 6.94 which won't
exist.
- Similarly, a
find_package(Qt6 6.4 COMPONENTS Widgets WebEngineWidgets) call
would always find any kind of WebEngine package that is higher than
6.4, which might be 6.94, 6.95, etc.
- In the future, if we fix Qt6Config to pass EXACT to its
subcomponent find_package calls,
a find_package(Qt6 6.5.0 EXACT COMPONENTS Widgets WebEngineWidgets)
would fail to find WebEngineWidgets, because its 6.94.0 version
will not be equal to 6.5.0. Currently we don't pass through EXACT,
so it's not an issue.
Augments 5ffc744b79
Task-number: QTBUG-103500
Change-Id: I8bdb56bfcbc7f7f6484d1e56651ffc993fd30bab
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Turning off pkg-config with the configure flag -no-pkg-config did not
work. There are different defaults for FEATURE_pkg_config on different
platforms (e.g. Linux: ON, Windows: OFF). The existing code that
calculated the initial FEATURE_pkg_config value assumed that the default
is OFF and never turned the feature off.
Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-104123
Change-Id: I33b9687c55c60d4ec9224324951a8838741ee976
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Otherwise they will just use default compiler
Pick-to: 6.3
Change-Id: Id5813b99fbbb6b0d8b0ee658e06312b637a097c1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Allow such a combination
- staging prefix (CMAKE_STAGING_PREFIX / -extprefix) set to the
qtbase build dir
- install prefix (CMAKE_INSTALL_PREFIX / -prefix / on-device prefix) set
to some custom location
even for non-cross builds.
An example would be
configure -prefix /usr \
-extprefix ~/qt/qtbase_build_dir
CMake will put the Qt libraries in the qtbase build dir, ninja install
will not be required, but ultimately in order to run applications,
the Qt libraries are expected to be in /usr.
Support for this scenario was originally added for cross-builds in
062318feb2 , but not desktop builds.
Such a build is useful when you want to have install rpaths different
from where Qt is initially installed to (the staging prefix).
This case doesn't really happen often when targeting desktop
platforms, it's mostly used for cross-compilation (e.g yocto).
Being able to have the same setup with a desktop build is nevertheless
useful for faster iteration on build system issues in such a scenario.
Amends 062318feb2
Pick-to: 6.2 6.3
Change-Id: I42be3628a30025f14eebaf0a79401b54e95cde26
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Originally, QT_INTERNAL_EXAMPLES_INSTALL_PREFIX was added to
control the installation of examples when they are built as
ExternalProjects, and was not considered for the non-EP case because
we hoped to switch entirely to EP-based building.
Due to some unsolved issues regarding using EP builds in CI, add the
ability to control the installation of non-EP examples.
This will be used in the CI to allow removing the hacky
INSTALL_EXAMPLEDIR and INSTALL_EXAMPLESDIR assignments in example
projects.
It is also likely that we will not deprecate the non-EP based
building, because it is useful for IDE integration (EP targets
are not as developer-friendly to work with in an IDE in regards
to rebuilding).
Amends 98c89c8cc1
Pick-to: 6.2 6.3
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I02264aaa1daa2c80bb9ef3d02b1831b4ca5d2b84
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
to QT_INTERNAL_EXAMPLES_INSTALL_PREFIX so it's clear that the
variable only affects the location of where examples
are installed.
And make sure the paths are passed as CMake paths.
Amends 1031fa1547
Pick-to: 6.2 6.3
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: Ib92c55488b736d980da2bd88255de78e183de824
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
By default when building ExternalProjects, even if the main ninja
invocation has -v passed, that won't be passed to the nested ninja
calls.
When building examples in the CI, we want to see the full command line
invocations.
Allow passing -v to the nested EP ninja calls by configuring Qt with
-DQT_INTERNAL_VERBOSE_EXAMPLES=ON, which we will use in our CI.
We don't want to add -v by default because if the main ninja does not
have one, the nested calls will still be verbose.
Pick-to: 6.2 6.3
Change-Id: Ifd4b312c6eaa7354e8870f4fb0a77fadf0f33ab7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Fix binary_for_strip project not being found when the following
conditions were met:
- building a repo other than qtbase
- qtbase sources are not available on the machine
(usually happens in CI where only the current repo sources are
available).
The issue was that QT_CMAKE_DIR would always be defined, regardless of
which repo was being built and the system would incorrectly assume
the location of the project files.
The fix is to always pick up the sources from qtbase's source dir if
they are available (this time done with an appropriate check),
otherwise use the installed files.
Note that the behavior of always using the qtbase sources if available
is not exactly the best, but it is a more general issue that affects
other code too.
In the name of consistency, make it so for the binary_for_strip
project as well, but add TODOs in code to address the situation
in a separate change.
Amends 39f657032b
Pick-to: 6.2 6.3
Fixes: QTBUG-102064
Task-number: QTBUG-88090
Task-number: QTBUG-101653
Change-Id: I0649f945e9ff0ab1f597c51bb5ab389fa665c021
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Using INSTALL_LIBDIR is the only reliable way to get the library install directory.
Amends: d1c56073b4
Pick-to: 6.2 6.3
Change-Id: Ib8c4fb8b4d339c63209393d7fdb3d1c3425b03a4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
MinGW 11.2.0 comes with a strip.exe that strips the ".gnu_debuglink"
section in binaries, a section that is needed for the separate debug
information feature.
binutils version 2.34 mentions the feature for the first time:
https://sourceware.org/binutils/docs-2.34/binutils/strip.html#strip
To ensure the debuglink section is preserved, generate a shell wrapper
that calls the original strip binary with an extra option to keep the
required section.
To determine if the option is supported, we build a real shared library
on which strip will be called with the --keep-section option.
If the option is not supported, a wrapper is not generated and the
stock strip binary is used.
This logic only applies when targeting Linux and MinGW + a shared
library Qt. For other targets, the stock strip binary is used.
Developers can opt out of this logic by passing
-DQT_NO_STRIP_WRAPPER=TRUE when configuring each Qt repo.
Pick-to: 6.2 6.3
Fixes: QTBUG-101653
Change-Id: Idd213d48d087d3c9600c853362aebaba348cde33
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
So we can see the exact moc invocations when debugging issues in the
CI.
For ExternalProject examples, it is conditional on whether Qt is
configured with QT_INTERNAL_VERBOSE_EXAMPLES set to ON, otherwise
calling the main ninja without -v will end up cluttering the output
with AUTOGEN output.
Pick-to: 6.2 6.3
Change-Id: I6468ab0e461b3be283e2428e3515cae4d5986242
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Since e2a0ddbb69 , if Qt is configured
as a non-developer-build, some of the CMake tests that include QtSetup
would have their CMAKE_MESSAGE_LOG_LEVEL set to the reduced NOTICE
value.
Make sure that tests always have a DEBUG level, so that if they fail
in the CI, we have more info on what goes wrong.
For ExternalProject examples, it is conditional on whether Qt is
configured with QT_INTERNAL_VERBOSE_EXAMPLES set to ON, otherwise
calling the main ninja without -v will end up cluttering the
output a non default log level.
Amends e2a0ddbb69
Pick-to: 6.2 6.3
Change-Id: Icd3b6e0fcc6c73e4b53b6c4a6d8354c96077a050
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
We shouldn't set CMAKE_FIND_ROOT_PATH_MODE_PACKAGE to BOTH when
cross-building examples without ExternalProjects.
Instead append the $build_tree_prefix to CMAKE_FIND_ROOT_PATH
and $build_tree_prefix/lib/cmake to QT_EXAMPLES_CMAKE_PREFIX_PATH
to circumvent the usual CMake path-rerooting issue.
This ensures that the build-tree Config files are found by the in-tree
find_package calls when cross-building examples.
Pick-to: 6.2 6.3
Task-number: QTBUG-96232
Change-Id: I4e31f0bf3dbfeb4339823fe09addda3ae83f12c3
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
For examples to successfully find not yet installed Config files in a
prefix cross-build, both CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH
need to be adjusted when toolchain files set
CMAKE_FIND_ROOT_PATH_MODE_PACKAGE to ONLY.
Before this change, we lacked two things.
1) If the chain-loaded toolchain file sets CMAKE_FIND_ROOT_PATH
(instead of appending), then the initial value of CMAKE_FIND_ROOT_PATH
that was passed by ExternalProject's initial cache would be
overridden.
2) The prefixes we passed via QT_EXAMPLES_CMAKE_PREFIX_PATH did not
end in lib/cmake, to work around the path re-rooting problem in CMake.
We can handle both of these points by using
QT_ADDITIONAL_PACKAGES_PREFIX_PATH which was introduced for Conan
usage.
Each value assigned to QT_ADDITIONAL_PACKAGES_PREFIX_PATH
gets prepended to CMAKE_FIND_ROOT_PATH by qt.toolchain.cmake AFTER the
original toolchain file is chain-loaded.
And each value also gets lib/cmake appended and assigned to
both CMAKE_PREFIX_PATH and _qt_additional_packages_prefix_paths (used
by Qt6Config.cmake.in to work with find_package + NO_DEFAULT_PATH).
This is exactly what we need to ensure examples build.
Pick-to: 6.2 6.3
Task-number: QTBUG-96232
Change-Id: I11a52457ff795a6661a3a7b68e823e0615d0ce89
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
qtdeclarative has a call like
qt_internal_add_example(imagine/automotive)
This causes issues when trying to pass that as the name of the
external project. Use the last part after the last slash as the name
of the project.
Pick-to: 6.2 6.3
Change-Id: Ifc074e50e537f07f3636699ed255d2561930d873
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Introduce a new QT_INTERNAL_CUSTOM_INSTALL_DIR variable to
allow specifying an 'examples install dir' outside of the Qt prefix.
It will be used in a follow-up change to ensure we don't package
the example binaries in our CI artifacts (thus saving space).
This will be even more important when the examples will contain code
to deploy Qt libraries alongside each deployed example (which would
significantly increase the package size).
Pick-to: 6.2 6.3
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I06b4a8f9e8c57a712a356bca0f5c351a9362bc30
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Change prefix builds to use ExternalProjects to build examples
by default. This will affect our CI which only does prefix builds.
To make it work, we have to do a few adjustments:
- look for Config files in the build-tree (before Qt is installed)
- build only one examples with only a single config,
even if Qt is a multi-config build
- install examples as part of main make install step, rather than
as part of the make step (which is the default for EPs)
- adjust CXX flags when building with MSVC to ensure we can still
use sccache and separate debug info
- derive the correct install prefix for each example and pass it
to the ExternalProject
As a drive-by, add TODOs to address tidiness of the code and corner
cases that likely don't work (Conan).
Amends d97fd7af2b
Pick-to: 6.2 6.3
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I3060da5dc64e7b06052f9dcb720d4d250f876450
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
We want to get rid of the INSTALL_EXAMPLEDIR and INSTALL_EXAMPLESDIR
code in each example project.
This was an internal workaround to ensure examples are installed into
a relative path somewhere under $qt_prefix/examples and not in
$qt_prefix/bin or similar.
To achieve that we do two things.
First, deduce the install prefix for each example in the
implementation of qt_internal_add_example (our add_subdirectory
wrapper) and assign it to CMAKE_INSTALL_PREFIX before calling
add_subdirectory. We need to make sure to remove the default
value of CMAKE_INSTALL_PREFIX in the generated
cmake_install.cmake file.
Second, we set an internal variable called
QT_INTERNAL_SET_EXAMPLE_INSTALL_DIR_TO_DOT before the add_subdirectory
call, which will be checked whenever find_package(Qt6Core) is called
in an example project. If the variable is set, the
INSTALL_EXAMPLEDIR var is set to "." in the scope of where Qt6Core
is found.
This ensures that the hardcoded INSTALL_EXAMPLEDIR values in our
example projects are changed to ".".
With both changes, our example project install(TARGET DESTINATION)
calls will now install to
"${CMAKE_INSTALL_PREFIX}/examples/${example_relative_dir}/."
Once all repositories are updated to use qt_internal_add_example
instead of add_subdirectory, we can get rid of the
QT_INTERNAL_SET_EXAMPLE_INSTALL_DIR_TO_DOT workaround.
For repositories that still don't use qt_internal_add_example,
the install prefix rewriting will not happen, but the examples will
still be installed to the proper place because they use their own
hardcoded INSTALL_EXAMPLEDIR value.
Amends d97fd7af2b
Pick-to: 6.2 6.3
Task-number: QTBUG-96232
Task-number: QTBUG-98545
Change-Id: I78c118e10c41b519c570c7d87529afd15aeed900
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Instead of nesting the external project build dir under the current
binary dir, place the EP build dir where it would usually be when we
use add_subdirectory.
Shorten the name of the external project to just ${subdir} instead
of using the relative current binary dir path.
Place the EP prefix and stamp dirs under a new ${subdir}-ep folder
next to the example build dir.
Overall this places example executables where you'd usually expect
them to be, as well as shortens a bunch of build paths to circumvent
path limit issues when building on Windows.
Pick-to: 6.2 6.3
Fixes: QTBUG-94608
Task-number: QTBUG-96232
Change-Id: Ifb921c5a6397385e8a914111bf56ee59cda003fd
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
One for building using ExternalProject_Add and one when examples are
built in-tree by calling add_subdirectory directly.
Pick-to: 6.2 6.3
Change-Id: If4c5301163aefed9f15148a70a8f7014bc817ac0
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
In preparation for addition of new baseline tests, establish a new
test category, "baseline". This is similar to the category
"benchmarks" in that it contains tests that use the QTest framework,
but conceptually are not unit tests, in contrast to those under auto/.
Move the existing QPainter baseline test, tst_lancelot, into this new
category, and rename it accordingly.
Baseline tests use the QBaselineTest extension to QTest. Move that
extension too into the tests/baseline directory, allowing the clean
out of the baselineserver directory.
Pick-to: 6.2
Change-Id: I1b527f5867c953b1d22be73798fcf7d1494712ea
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
When building Qt we need to set QT_ANDROID_ABIS value to
CMAKE_ANDROID_ARCH_ABI explictily since the automatical detecting of
android ABI is not executed. This fixes build of the qtbase in-tree
tests.
Fixes: QTBUG-97133
Change-Id: Ica7057bcfcc8f4fe4b5a921ca7449f74cdbca0f1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
In non-prefix builds, we want to prevent users from accidentally running
"cmake --install". We did that by replacing cmake_install.cmake with an
empty file.
The responsible target remove_cmake_install is visible in IDEs, appears
in the build output, and the approach is hacky.
It's cleaner and easier to add bail out code at the top of
cmake_install.cmake. This is now done when calling qt_build_repo_begin.
As a bonus, print an informative message on installation.
Change-Id: I022b36289358ba09cac8b79781f44cd7b93113f7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
These TODOs were left as a marker to be checked once the official
CMake 3.21.0 release was made. The things they refer to were included
in the CMake 3.21.0 release, so the TODOs can be removed.
Fixes: QTBUG-94528
Pick-to: 6.2
Change-Id: I769605de85df657ad056123e787ec9849b77e42f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Conan CI builds can built a qt repository in a repo-target-set
configuration. An example of that is qtscxml.
When building standalone tests, qt_build_tests includes a repo
specific TestsConfig.cmake file to call find_package on the modules
that were built as part of that repo.
That doesn't quite work with a repo-target-set build which is enabled
when the repo is built with a QT_BUILD_SINGLE_REPO_TARGET_SET value.
The TestsConfig.cmake file would be overridden with different contents
on each configuration.
Fix that by including the QT_BUILD_SINGLE_REPO_TARGET_SET value as
part of the TestsConfig.cmake file to be generated and included.
This means that when configuring the standalone tests, the same
QT_BUILD_SINGLE_REPO_TARGET_SET value should be passed, so that the
correct packages are found.
Add some debug statements to allow checking which TestsConfig.cmake
file is loaded when the standalone tests are configured with
--log-level=DEBUG.
Adjusts to 4b09522c23
Amends de3a806def
Amends e7f188b2d2
Pick-to: 6.2
Task-number: QTBUG-96253
Change-Id: I7c22aaad88fe8e6fce23046543363316203f6e8d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
We default to configuring examples as separate ExternalProjects when
using a developer / non-prefix Qt build.
This ensures we test that the examples configure successfully without
the pollution of the main Qt build (e.g. already found packages).
One down-side of this is that a developer's IDE doesn't see these
example targets, unless each project is loaded into the IDE
separately. This is cumbersome to do when refactoring or renaming
code across multiple example projects.
Allow configuring the example projects as part of the main Qt build
by setting QT_BUILD_EXAMPLES_AS_EXTERNAL to FALSE when configuring Qt.
Save the value of the variable in QtBuildInternalsExtra.cmake.in
so it's propagated to leaf repositories as well.
Amends dab8f64b6d
Amends d97fd7af2b
Task-number: QTBUG-90820
Task-number: QTBUG-94608
Task-number: QTBUG-96232
Task-number: QTCREATORBUG-26168
Pick-to: 6.2
Change-Id: Ie1f724f74365b3a788b04c3fffe9eb2d0611dd50
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
In top-level builds, when configuring qtsensors, the directory of
FindWMF.cmake isn't in ${CMAKE_MODULE_PATH}, this makes CMake couldn't
find WMF.
On Windows, QtMultimedia requires WMF. If WMF couldn't be found,
QtMultimedia will also be treated as NOT FOUND.
QtSensors has an optional dependency to QtMultimedia. If QtMultimedia
couldn't be found, CMake will warn.
Copy Find*.cmake to ${QT_BUILD_DIR}/lib/cmake/Qt6, to make sure these
files could be found by CMake.
Fixes: QTBUG-95655
Pick-to: 6.2
Change-Id: I87d14c9a7becd0ec493e00c297b2e01fc0ad0f96
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Building a shared library Qt configuration already required a minimum
CMake version of 3.16, because we depend on CMake's Autogen.json files
which are used for metatype.json file generation.
If a lower version was used, a FATAL_ERROR was issued in
qt6_extract_metatypes.
This change is essentially moving the check to happen earlier in the
qtbase configure process.
User projects will now /also/ officially require a minimum of 3.16
(up from 3.14).
As a consequence, the min/max version policy range that is set in
the public QtFooConfig.cmake files is changed
from 3.14..3.19
to 3.16..3.20
The upper bound is raised because building and using Qt works fine
with all CMake 3.20 policies set to NEW.
[ChangeLog][CMake] Building Qt as shared libraries now requires
CMake version 3.16 or later. Building user projects with CMake using
that Qt installation also requires a CMake version of 3.16 or later.
Pick-to: 6.2
Task-number: QTBUG-95018
Change-Id: I77d2829370f1dfc90b4071bebc8a3ade654e59e6
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
target_link_options are placed by CMake at the beginning of a linker
line. This gives us an opportunity to use the function to propagate
object libraries. This change adds one more check in the root
Config.cmake file. If CMP0099 policy is enabled, CMake enables
propagating of the linking options when linking two static libraries
using the PRIVATE linking visibility, so we can rely on the correct
linking order and expect object libraries to be propagated.
Note that on the platforms where cmake version is higher than 3.16
Qt uses CMP0099 NEW in functions like qt_add_executable. This means
that at the moment of creating an executable target the TARGET_POLICY
genex will also be NEW, so we do not take into the account the user
defined CMP0099.
If the CMP0099 policy is not available for a certain CMake version
we skip the TARGET_POLICY check and simply disable propagation of
the object libraries using target_link_options for both user and Qt
libraries. This is applicable for the CMake versions 3.16 and less.
Linking approaches have the following priorities(from higher to lower)
after this change:
- target_link_libraries - works if link order matters not or CMake
version greater equal 3.21.
- target_link_options - works if CMP0099 is set to NEW by user or
if the CMake version is greater than or equal to 3.17 and an
executable is created using Qt functions.
- object library finalizer - works if CMake version is greater equal
3.19 or qt6_finalize_target is called explicitly.
- target_sources - is used when all the other approaches could not
be used.
Amends a1fd4f51ad
Amends 3329212815
Pick-to: 6.2
Change-Id: I14f88caeb04e357191c840abeab89b03e210b796
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Remove target specific flags from static_link_order.
Move the check to the common config.tests folder.
Amends 5fb99e3860
Pick-to: 6.2
Task-number: QTBUG-93002
Task-number: QTBUG-94528
Change-Id: I1368075ec6bd1e743b2b89fd93143df38a278ec2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>