Explicitly check that at least CMake 3.21 is used when building Qt or
when using Qt in a project.
This only affects macOS and iOS builds.
We check for 3.21 instead of 3.21.1 as described in the documentation
to avoid an error like:
Policy VERSION range "3.21.1...3.21" specifies a larger minimum than
maximum.
Until the technical limitation is addressed, if someone does end up
using 3.21.1, another existing check for "unsuitable" cmake versions
(as opposed to minimum required) will let them know they should use
something newer.
Amends 1cf3295cef321c9a587af2f2de7740c0cd3ca743.
Pick-to: 6.6
Fixes: QTBUG-114869
Change-Id: I2a479baaa63cfbe23af187cf0796e1c00042692b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Maintain one central place - .cmake.conf - for information
about Qt's copyright.
Pick-to: 6.2 6.5
Change-Id: Ibcbce4313eba9660d459061b0ad00307e267b8f7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
All current modules are free of qAsConst, make sure new ones will be,
too.
Change-Id: Iae3c67bca86eddf62ae664b00ff39a9b513d7290
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@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>
In a toplevel build, we include qtbase's .cmake.conf twice: Once for
qtbase itself, but already earlier to provide some necessary information
for the toplevel build. We now detect the latter, and skip setting
QT_EXTRA_INTERNAL_TARGET_DEFINES in that case, to ensure that it is only
applied to the qtbase itself
Task-number: QTBUG-101640
Pick-to: 6.2 6.3
Change-Id: I14dbf6110c79331fac38cceb76f669ca329ad33a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Forward declare more types in qvariant.h, and do the same for qdebug.h
(which will be removed from qvariant in a separate patch).
As we now only forward declare containers (e.g. QMap, QList, ...), code
which includes <QVariantMap>, <QVariantList>... breaks without further
adjustment: So far, those headers simply included qvariant.h. However,
by introducing new actual headers for those types and adjusting
sync.profile, we can avoid this issue.
To avoid breaking leaf modules and user code, we make the change opt-in:
Unless QT_LEAN_HEADERS is defined to a value of >= 1, we still
include the superfluous headers. We also set this macro in qtbase via
QT_EXTRA_INTERNAL_TARGET_DEFINES.
[ChangeLog][Potentially Source-Incompatible Changes] qvariant.h no
longer includes <QList>, <QMap>, <QHash>, <QVarLengthArray>, <QSet> and
<QObject>. Code that relied on transitive includes might need to
explicitly include those headers now. Notably, including <QVariant> (or
qvariant.h) is no longer sufficient when using QVariant(List|Map|Hash).
Using them now requires including respectively <QVariantList>,
<QVariantMap>, or <QVariantHash>. Alternatively, including <QVariant>
and the <QList>, <QMap> or <QHash> header also works.
[ChangeLog][Potentially Source-Incompatible Changes] qdebug.h no longer
includes <QSet>, <QHash>, <QVarLengthArray> and <QMap>. Code that relied
on transitive includes might need to explicitly include those headers
now.
Task-number: QTBUG-97601
Change-Id: I142e5de709ed0b305716369a3266389ab7fbbb71
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This reverts commit 657525965b.
The change relied on reading the last value of the
CMAKE_MINIMUM_REQUIRED_VERSION variable before one of the Qt packages
is found to use it for the version check.
Even if a user project has a cmake_minimum_required() right at
the beginning of the project with a supported version specified,
the first project() call which loads a CMake toolchain file could
contain another cmake_minimum_required() call with a lower
(unsupported) version and that version would be used for the check,
failing the project configuration.
The Android NDK ships such a toolchain file, which requires version
'3.6'.
Thus, relying on the last value of CMAKE_MINIMUM_REQUIRED_VERSION is
not robust enough.
Pick-to: 6.2
Task-number: QTBUG-95018
Task-number: QTBUG-95832
Change-Id: Iff3cb0a46e6e878569dce9c5fe915a714a034904
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Qt6Config.cmake calls cmake_minimum_required to ensure a recent enough
CMake version is used in projects.
That call does not set policies in the calling subdirectory scope,
because find_package introduces a new policy scope.
If a project using Qt has a 'cmake_minimum_required(VERSION 3.1)'
call and is configured with a recent CMake, many policies will
still be set to OLD.
One such policy is CMP0071 (Run AUTOMOC on GENERATED files). The
policy value is queried at generation time rather than at target
definition time, which means we can't influence the policy value
(e.g. inside the implementation of qt_add_executable for example)
The inability to influence the policy value for targets created by our
own CMake functions is unfortunate and can lead to issues (in the case
of the above policy to compilation / linker issues).
Record the version of the last cmake_minimum_required call before
the Qt packages are found and error out if the version is lower than
the minimum supported one.
A project can reduce the error into a warning by specifying a
-DQT_FORCE_MIN_CMAKE_VERSION_FOR_USING_QT_IN_CMAKE_MIN_REQUIRED=3.xyz
option when configuring the project.
If the option is used and build issues arise, no official support is
given.
All the CMake example projects shipped with Qt specify a minimum
version of 3.16 already (which is the minimum for shared Qt builds),
so it shouldn't be an issue to require that in other user projects as
well.
Implementation wise, we follow the existing pattern to record
what the minimum and computed versions for static and shared Qt
builds are at qtbase configure time.
These are then checked before the Qt6 or QtFoo packages are
find_package'd.
Amends 6518bcc167
Pick-to: 6.2
Task-number: QTBUG-95018
Task-number: QTBUG-95832
Change-Id: I1a1d06d82f566c92192a699045127943604c8353
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Building a static library Qt configuration will now require a
minimum CMake version of 3.21.
Using such a static library Qt configuration in user projects will now
require the same minimum CMake version of 3.21.
Qt builders and packagers can still opt out of the mentioned minimum
required version by configuring Qt with
QT_FORCE_MIN_CMAKE_VERSION_FOR_BUILDING_QT
and
QT_FORCE_MIN_CMAKE_VERSION_FOR_USING_QT.
Such a Qt configuration is /NOT SUPPORTED/.
Increase the upper range of CMake policies set to NEW to 3.21.
Amends 9aa0d99e66
Amends 6518bcc167
[ChangeLog][CMake] Building Qt as static libraries now requires
CMake version 3.21 or later. Building user projects with CMake using
that Qt installation also requires a CMake version of 3.21 or later.
Pick-to: 6.2
Fixes: QTBUG-95018
Change-Id: I717b6e1207df46627443b3e5ed430f3c964e2b48
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This change introduces new behavior to error out when configuring user
projects if the CMake version used is too old for Qt to work with.
The main motivator is the requirement of new CMake features to ensure
object libraries are placed in the proper place on the link line in
static builds.
The minimum CMake version is computed based on whether Qt was
configured as shared or static libraries.
At the moment the required versions for building and using Qt are the
same.
The minimum versions are defined in qtbase/.cmake.conf in the
following variables
QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT_SHARED
QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT_STATIC
QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_SHARED
QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_STATIC
Qt Packagers can disable the version check when configuring Qt
by setting
QT_FORCE_MIN_CMAKE_VERSION_FOR_BUILDING_QT and
QT_FORCE_MIN_CMAKE_VERSION_FOR_USING_QT.
In this case it is the packagers responsibility to ensure such a Qt
works correctly with the specified CMake version.
User projects can also set QT_FORCE_MIN_CMAKE_VERSION_FOR_USING_QT
to disable the version check. Then it's the project's developer
responsibility to ensure such a Qt works correctly.
No official support is provided for these cases.
Implementation notes.
The versions required to build Qt are stored in
QtBuildInternalsExtra.cmake
whereas the versions required to use Qt are stored in a new
QtConfigExtras.cmake.
Also the policy range variables stored in
QtBuildInternalsExtra.cmake are now regular variables instead of cache
variables, to properly allow overrides per-repository.
Some renaming of functions and variables was done for a bit more
clarity and easier grep-ability.
Pick-to: 6.2
Task-number: QTBUG-95018
Change-Id: I4279f2e10b6d3977319237ba21e2f4ed676aa48b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Building a static library Qt configuration will now require a
minimum CMake version of 3.20.
Qt builders and packagers can still opt out of the mentioned minimum
required version by configuring Qt with QT_FORCE_MIN_CMAKE_VERSION.
Such a Qt configuration is /NOT SUPPORTED/.
To facilitate these changes, the minimum version check has been moved
to happen after the BUILD_SHARED_LIBS option is computed by either
QtAutoDetect.cmake or set by a user provided cmake toolchain file.
Introduce a new QT_MIN_SUPPORTED_CMAKE_VERSION_FOR_STATIC_QT variable
in .cmake.conf to mark the minimum version for a static Qt build.
Pick-to: 6.2
Task-number: QTBUG-95018
Change-Id: Idc1875729f26a7c635b6bd26ac0c1be973917c13
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Craig Scott <craig.scott@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>
The status information (alpha1, beta2, rc3, ...) needs to be part of
the Conan package reference.
As Conan supports semantic versioning the best place to put the status
is to append it to the version string:
qtbase/6.2.0-alpha1@qt/everywhere
qtbase/6.2.0-beta2@qt/everywhere
qtbase/6.2.0-rc3@qt/everywhere
qtbase/6.2.0@qt/everywhere
Other Conan packages declaring a dependency can use e.g. syntax:
# notice the asterix character after version
self.requires(f"qtbase/[<=<version>, include_prerelease=True}]@..)
This way the status information is not in the Conan channel part and
downstream consumers of the Conan package does not need to update
the dependency (Conan reference string) every time the version changes.
Put the status information next to Qt version string in .cmake.cache.
Task-number: QTBUG-94385
Pick-to: 6.2
Change-Id: Ib277f99ea1e87253b93f59e463bd6c7dd8b3203e
Reviewed-by: Toni Saario <toni.saario@qt.io>
Ubuntu 20.04 is a supported platform and comes with CMake 3.16. The
current state of the Qt build works fine with this CMake version, mainly
because the default build on Linux is single-config.
For multi-config builds we have higher version requirements as
documented in cmake/README.md.
This lowers the barrier for users using single-config builds who don't
want or cannot upgrade to CMake >= 3.18.
For Ninja Multi-Config builds, which were introduced by CMake 3.17, we
yield a warning that 3.18.3 is the lowest supported version.
Pick-to: 6.0
Change-Id: Ia918b9f2b494508e86301ffc0e138d3ad4dbaf86
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
When a CMake release introduces a new policy that affects most Qt
modules, it may be appropriate to make each module aware of that newer
CMake version and use the NEW policy without raising the minimum CMake
version requirement. To reduce the churn associated with making that
change across all Qt modules individually, this change allows it to be
updated in a central place (qtbase), but in a way that allows a Qt
module to override it in its own .cmake.conf file if required (e.g. to
address the issues identified by policy warnings at a later time). The
policies are modified at the start of the call to
qt_build_repo_begin().
For commands defined by the qtbase module, qtbase needs to be in
control of the policy settings at the point where those commands are
defined. The above mechanism should not affect the policy settings for
these commands, so the various *Config.cmake.in files must not specify
policy ranges in a way that a Qt module's .cmake.conf file could
influence.
Starting with CMake 3.12, policies can be specified as a version range
with the cmake_minimum_required() and cmake_policy() commands. All
policies introduced in CMake versions up to the upper limit of that
range will be set to NEW. The actual version of CMake being used only
has to be at least the lower limit of the specified version range.
This change uses cmake_minimum_required() rather than cmake_policy()
due to the latter not halting further processing upon failure.
See the following:
https://gitlab.kitware.com/cmake/cmake/-/issues/21557
Task-number: QTBUG-88700
Pick-to: 6.0
Change-Id: I0a1f2611dd629f847a18186394f500d7f52753bc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Add a new function that returns the minimum CMake version required to
build Qt. Pass that value to cmake_minimum_required() when building
qtbase and its standalone tests.
The minimum supported CMake version is read from qtbase/.cmake.conf
and its value should be updated when the need arises. It's the main
source of truth for all repos.
Provide a way to lower the minimum CMake version at configure time by
passing a value via QT_FORCE_MIN_CMAKE_VERSION.
This is not an officially supported way of building Qt. If the
specified version is lower than Qt's supported minimum, show a
warning.
Nevertheless the option is useful for testing how Qt builds with a
different minimum CMake version due to different policies being
enabled by default.
Issue warnings for CMake versions that are higher than the minimum
version but are known to cause issues when building Qt.
A counterpart change is needed in qt5 to ensure the minimum CMake
version is set at the proper time for top-level builds.
Ideally we would use the same 'check the CMake minimum version` code
in all our repositories, but that will cause lots of duplication because
we can't really find_package() the code and doing something like
include(../qtbase/foo.cmake) hardcodes assumptions about repo
locations.
So for now we don't bump the minimum version in child repo
cmake_minimum_required calls (qtsvg, qtdeclarative, etc).
Instead we record both the minimum supported version and the computed
minimum version (in case a different version was forced) in
QtBuildInternalsExtra.cmake.
Then we require qtbase's computed min version in
qt_build_repo_begin().
This won't set policies as cmake_minimum_required would, but at least
it propagates what minimum CMake version should be used for child
repos.
We might still have to bump the versions in child repos at some point.
Task-number: QTBUG-88086
Change-Id: Ida1c0d5d3e0fbb15d2aee9b68abab7a1648774b9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
And create one for QtBase at the same time.
Fixes: QTBUG-83835
Change-Id: Icc6b022165a57bd4e22c23bdb0016522b99a5b80
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>