Commit Graph

1629 Commits

Author SHA1 Message Date
Yuhang Zhao
6652bf2353 Bump WINVER, _WIN32_WINNT and _WIN32_IE to _WIN32_WINNT_WIN10 (0x0A00)
And bump NTDDI_VERSION to 0x0A00000B (NTDDI_WIN10_CO) at the same time,
to unblock the developers from accessing the latest Windows APIs.

Pick-to: 6.2
Change-Id: Ifbc28c8f8b073866871685c020301f5f20dc9591
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-10 20:31:05 +08:00
Joerg Bornemann
7be143f438 CMake: Fix default install prefix of top-level non-developer builds
A top-level non-developer build is supposed to default to a prefix like
"/usr/local/Qt-6.3.0".  That wasn't the case.

In QtSetup.cmake we check CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT,
set CMAKE_INSTALL_PREFIX and did the same thing later in
QtBuildInternalsExtra.cmake, with a different value.  Make sure we run
the latter code only in per-repo builds.

Pick-to: 6.2
Fixes: QTBUG-98087
Change-Id: I4a1291dfd126aa11c21d69809f2cf7b075c98d2e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-08 23:12:33 +01:00
Joerg Bornemann
4f360e3b76 Assume qhelpgenerator in libexec instead of bin
Task-number: QTBUG-88791
Change-Id: I0f6dc14401e715a98322abc21da3f88e34118e27
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2021-11-08 19:27:32 +01:00
Joerg Bornemann
71e490f0ba Provide a qtpaths wrapper script when cross-building Qt
The qtpaths tool is supposed to replace "qmake -query", and it must be
available for cross-builds as a wrapper script like qmake.

Re-use the existing facility for creating the qmake wrapper script for
creating the qtpaths wrapper script.

Pick-to: 6.2
Fixes: QTBUG-97821
Change-Id: I460bae61a531994422e1c0fba09c79e4aa65713f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-08 13:41:03 +01:00
Joerg Bornemann
c5409964b0 configure: Allow specifying arbitrary variable assignments
It's now possible to call configure with arbitrary variable assignments
"FOO=BAR" that get passed as "-DFOO=BAR" to CMake.  There is no error
anymore for unknown variables.  CMake already warns about those:
"Manually-specified variables were not used by the project: FOO".

[ChangeLog][configure] Users can directly assign CMake variables with
configure, for example "configure CMAKE_CXX_COMPILE=clang++-11".

Fixes: QTBUG-88210
Change-Id: Ib15e63a895df717919dd2b6623fa4d284209776f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-05 16:54:55 +01:00
Thiago Macieira
bcbc36b8bf CMake/qconfig.cpp: use raw strings so we support any input
Change-Id: I2bbf422288924c198645fffd16aa04379315e69e
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-11-04 10:20:09 -07:00
Lorn Potter
2148e1f0e6 wasm: increase default initial memory
Some apps may need more initial memory when linking, emscripten will
fail with:
wasm-ld: error: initial memory too small

This increases the default initial memory form 16MB to 20MB.

Larger apps might still get this error, in which case
QT_WASM_INITIAL_MEMORY can be set.

Pick-to: 6.2
Fixes: QTBUG-97457
Change-Id: Icdc56c41fb3a3852a9a83f7a3dc15820e83e1148
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-11-04 17:26:49 +10:00
Morten Johan Sørvig
6d039a5e76 wasm: enable event dispatcher asyncify support
Misc. fixes, including:

Fix a couple of typos in the JavaScript code. Also, macros-
within-macros don’t work, (without resorting to preprocessor
token pasting), so remove the debug output for now.

Limit the exec() “simulateInfiniteLoop” workaround to
top-level application exec() only. This way, asyncify
can be used for nested QEventLoop::exec() calls. (Emscripten
supports one level of suspend only, so we don’t want
to use that for the top-level exec(), but instead use it
for dialogs and such).

Use the new QEventLoop::ProcessEventsFlag::ApplicationExec
enum value to detect the exec() call type.

Change-Id: Ic702bfc31faf2e9f84ac5d3ccf43d067c5c61bf0
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-11-04 09:23:11 +02:00
Alexey Edelev
63acb0d9fe Move qt_finalize_framework_headers_copy to the scope finalizer
The qt_finalize_framework_headers_copy function uses the module
QT_COPIED_FRAMEWORK_HEADERS property to generate the dependency list
for the ${target}_framework_headers target. In a common case elements
can be added to the QT_COPIED_FRAMEWORK_HEADERS property after the
qt_internal_add_module command call, that's why we need to make sure
that qt_finalize_framework_headers_copy is called after collecting all
headers assigned to the module.

Pick-to: 6.2
Change-Id: I2878fa6b8d4b11677c3f48345bf6e239221074c2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-03 21:02:44 +01:00
Topi Reinio
51becc4c66 CMake: QtDocsHelpers: Rename generate_qdocs_args variable
To be consistent with prepare_qdoc_args.

Pick-to: 6.2
Change-Id: Ibd40d6c26f6f6fa49ea78b6476f396153b7c4ee5
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-11-03 16:47:18 +02:00
Kai Köhne
df2aa08187 CMake: Improve comment about how to disable warnings
Change-Id: I4367f2b585b7fdfaba2a815be885157a1db990cd
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-02 19:16:10 +01:00
Alexandru Croitor
f04dbdfc97 CMake: Don't create targets if dependencies are not found
If one of the dependencies in QtFooModuleDependencies.cmake is not
found, QtFoo_FOUND will be set to False by find_dependency.

In that case, we should not create imported targets that belong to
that package.
It would be misleading for projects that do target existence checks
instead of package_FOUND checks as well as generally being
incorrect. The created imported targets might be referencing other
targets that would not exist.

Pick-to: 6.2
Fixes: QTBUG-97896
Change-Id: I09198aa3f19be047b27c29329b6e62c30fa09dc0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Craig Scott <craig.scott@qt.io>
2021-11-02 11:51:26 +01:00
Joerg Bornemann
6ab16d52d2 configure: Remove unused facility to define variable assignments
The function qt_commandline_assignment and everything related to it is
removed from configure.  It was only used in qtbase, and all usage has
been removed.

More general variable assignments will be added in a subsequent commit.

Task-number: QTBUG-88210
Change-Id: I7cfa782e89914f2b0dc0277c46e425c8a825557e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-01 22:32:01 +01:00
Tor Arne Vestbø
06513ce175 Remove CFBundleGetInfoString from CMake Info.plist templates
It's been deprecated since Mac OS X 10.5.

qmake templates fixed in 0768a28fbf.

Task-number: QTBUG-74872
Pick-to: 6.2
Change-Id: If7d988f27f07b6fa095b2ea51a87c306361d63d1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-01 18:58:00 +00:00
Thiago Macieira
a887b7750c qconfig.cpp: use qOffsetStringArray
It's been there for ages, we may as well use it and remove unnecessary
complexity from CMake.

Pick-to: 6.2
Change-Id: I2bbf422288924c198645fffd16a9742567a7e4af
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-10-29 20:26:13 -07:00
Alexandru Croitor
c78a652bd2 CMake: Warn when using unsuitable CMake due to issue finding host perl
CMake's Modules/Platform/Android-Initialize.cmake was setting
CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH to OFF and host perl was not
picked up in PATH on Windows when building for Android.

Pick-to: 6.2
Change-Id: Ic98d8b38425231ef6aaf173fdfe958b573cc0c40
Reviewed-by: Craig Scott <craig.scott@qt.io>
2021-10-29 15:34:12 +02:00
Alexandru Croitor
b04a0f0c04 CMake: Allow enabling/disabling QT_HOST_PATH checks via variable
One can now pass -DQT_REQUIRE_HOST_PATH_CHECK=OFF or
-DQT_REQUIRE_HOST_PATH_CHECK=ON to force disable or enable
the QT_HOST_PATH and QT_HOST_CMAKE_DIR_PATH validity checks.

One potential use case is if a project wants to manually find
QtFooTools packages by manipulating CMAKE_FIND_ROOT_PATH and such,
in which case they might not want to pass a QT_HOST_PATH.

Another potential use case is cross-building Qt with
-DQT_BUILD_TOOLS_WHEN_CROSSCOMPILING=ON and allowing the same
generated toolchain file to be used on the device image.

By default the generated toolchain file would require a host path
because it expects that it's still being used for cross-compiling.
But once the toolchain file is deployed to the device there's no need
to use the host tools anymore.

Another use case is building a desktop Qt using the host tools of
another desktop Qt. The new desktop Qt can use its newly built tools
just fine and wouldn't need the original desktop Qt tools.

QT_REQUIRE_HOST_PATH_CHECK needs to be added the list of vars to pass
through to try_compile calls.

Change-Id: I4b922b5d854828e6b9210dd8c07b4b1b8630aad1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Craig Scott <craig.scott@qt.io>
2021-10-29 15:34:12 +02:00
Alexandru Croitor
f917df2752 CMake: Fix _QT_TOOLCHAIN_VARS_INITIALIZED check in toolchain file
The environment variable check to set extra env vars
was using invalid syntax. The condition always resolved to TRUE
which means the env vars were constantly re-assigned inside each
try_compile project.

To check for undefined-ness, one can use if(NOT DEFINED ENV{...})
To check for false-ness, one can use if(NOT "$ENV{...}")
To check for string emptiness, one can use
  if(NOT "$ENV{...}" STREQUAL "")

In this particular case checking for false-ness is good enough.
The extra re-assigning had no visible effect, so this is just cleanup.

As a drive-by, clarify one comment.

Amends ca59c20939

Pick-to: 6.2
Change-Id: I8fd400101efa9e610a81268c33cac8c0cb33cba3
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Craig Scott <craig.scott@qt.io>
2021-10-29 15:34:12 +02:00
Alexandru Croitor
402b8b9cee CMake: Use Qt6HostInfo dir for Tools CMAKE_PREFIX_PATH assignment
Instead of hard-coding a lib/cmake suffix to CMAKE_PREFIX_PATH
use the parent directory of the Qt6HostInfo package which is always
searched for when QT_HOST_PATH is set.

Amends d2359b2d4e

Pick-to: 6.2
Change-Id: I7f3c8fe17bc82f733580d68d928146434a57d849
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-10-29 15:34:12 +02:00
Alexandru Croitor
102c1cff72 CMake: Clean up and improve QT_HOST_PATH_CMAKE_DIR computation
Previously when one wanted to use a cross-compiled Qt with a host Qt
installed in a non-default location, they'd have to provide both
QT_HOST_PATH and QT_HOST_PATH_CMAKE_DIR.

This change will now try to first check if ${QT_HOST_PATH}/lib/cmake
is a valid path on disk and use that. This is nicer to the user
because they don't need to specify 2 paths anymore.

Furthermore the path computation and sanity checks are now done after
any extra toolchain cmake files are loaded, to give an opportunity
to the files to set the paths first.

Finally, both variables need to be added to
__qt_toolchain_used_variables so they are passed along to try_compile
calls if the variables are specified manually.
Otherwise when the toolchain file is loaded by a try_compile project,
it will error out saying no host path found (as long as the initial
paths embedded in the toolchain are invalid).

Amends 93fc3afe71 and
ec90f9013b

Pick-to: 6.2
Change-Id: I433239b36b084f2d0a7a0dd043fdf87d77c138f3
Reviewed-by: Craig Scott <craig.scott@qt.io>
2021-10-29 15:34:12 +02:00
Alexandru Croitor
c82bca9efe CMake: Fix forcing usage of host tools when doing a desktop build
One can now set QT_FORCE_FIND_TOOLS to ON together with passing a
QT_HOST_PATH to ensure that a new desktop build uses
already existing tools from a different Qt host (desktop) installation.

Depends on a0e56294c1
to work, which is not in 6.2, but this change is still included in
6.2 because it cleans up the conditions a bit to make them more clear.

Amends 42d3b21c92
and 5a779a4ad3

Pick-to: 6.2
Fixes: QTBUG-95099
Task-number: QTBUG-97658
Change-Id: If6258fb1091c6c1e457f22ae5f468b811bd20d57
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-10-29 15:34:12 +02:00
Alexandru Croitor
9ed274a48d CMake: Enforce lookup of host Tools packages in qt_internal_add_tool
When cross-building, qt_internal_add_tool would accidentally find device
QtFooTools CMake packages as a result of calling find_package. It should
have found host Tools packages instead.

The reason was due to a combination of setting
CMAKE_FIND_ROOT_PATH_MODE_PACKAGE to BOTH, find_package preferring
the lookup of packages in CMAKE_FIND_ROOT_PATH before CMAKE_PREFIX_PATH
and there being a Tools package in the device sysroot.

Because qt_internal_add_tool didn't adjust CMAKE_FIND_ROOT_PATH to
contain the host path, the device package was picked up.

Change the implementation not to set CMAKE_FIND_ROOT_PATH_MODE_PACKAGE
and instead modify both CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH
to prefer the host packages instead.

This aligns to the behavior that was introduced in
ec90f9013b
which is used in QtModuleDependencies when looking for Tools packages.

Pick-to: 6.2
Fixes: QTBUG-97599
Change-Id: I8e38284774ae97981ccfd5071465609f3de80f01
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-10-29 15:34:12 +02:00
Alexandru Croitor
5ffc744b79 CMake: Allow disabling package version check
When building Qt repos, all find_package(Qt6) calls request a
PROJECT_VERSION version which is set in .cmake.conf via
QT_REPO_MODULE_VERSION.

This means trying to configure qtsvg from a 6.3 branch using a
6.2 qtbase won't work, because qtsvg will call find_package(Qt6 6.3)
and no such Qt6 package version exists.

There are certain scenarios where it might be useful to try to do
that though.
One of them is doing Qt development while locally mixing branches.
Another is building a 6.4 QtWebEngine against a 6.2 Qt.

Allow to opt out of the version check by configuring each Qt repo
with -DQT_NO_PACKAGE_VERSION_CHECK=TRUE. This setting is not
recorded and will have to be set again when configuring another
repo.

The version check will also be disabled by default when configuring
with the -developer-build feature. This will be recorded and embedded
into each ConfigVersion file.

If the version check is disabled, a warning will be shown mentioning
the incompatible version of a package that was found but that package
will still be accepted.
The warning will show both when building Qt or using Qt in a user
project.
The warnings can be disabled by passing
-DQT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING=TRUE

Furthermore when building a Qt repo, another warning will show when an
incompatible package version is detected, to suggest to the Qt builder
whether they want to use the incompatible version by disabling the
version check.

Note that there are no compatibility promises when using mixed
non-matching versions. Things might not work. These options are only
provided for convenience and their users know what they are doing.

Pick-to: 6.2
Fixes: QTBUG-96458
Change-Id: I1a42e0b2a00b73513d776d89a76102ffd9136422
Reviewed-by: Craig Scott <craig.scott@qt.io>
2021-10-27 16:41:26 +02:00
Pasi Petäjäjärvi
c91b5dae9a QNX: Generate empty string for WORKING_DIRECTORY test wrapper
Tests for QNX are run in qemu over ssh and setting WORKING_DIRECTORY
will cause created test wrapper to try change specified directory
which will fail (expects local directory) when test is invoked over
ssh.

Task-number: QTBUG-87628
Pick-to: 6.2
Change-Id: If991002398811cc9cb9cbac54da5d2cb0d8c3589
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-27 13:30:01 +03:00
Ilya Fedin
6bf41058a6 Add a QNetworkInformation backend based on GNetworkMonitor
GNetworkMonitor can get information from 3 sources:
* org.freedesktop.portal.NetworkMonitor
* NetworkManager
* netlink

Change-Id: Icfafe6af42148f26360449f1262093ffc6b0613a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-10-24 18:22:46 +04:00
Alexandru Croitor
606124c5cc CMake: Fix -rpath-link dependencies take two
The previous implementation would pick up static Qt deps of a
shared Qt library as packages to find, but packages are not
created for these static libraries in a shared Qt build.

For example Qt::BundledSpirv_Cross is a static helper lib
that is linked directly into ShaderTools shared lib and no CMake
package is created for it, so we shouldn't look for it.

Separate the code path to filter out private dependencies
of a shared library target that don't have packages.

Amends 87215c70c0

Pick-to: 6.2
Fixes: QTBUG-97673
Task-number: QTBUG-86533
Change-Id: I43490b4d20c150256ccfa8b511a6e0e6b0f4b313
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-10-22 22:57:46 +02:00
Alexandru Croitor
8d1db12bba Revert "CMake: Fix rpath-link dependencies when cross-compiling"
This reverts commit 87215c70c0.

Reason for revert: Breaks configuration of standalone tests in
leaf modules

Pick-to: 6.2
Fixes: QTBUG-97673
Task-number: QTBUG-86533
Change-Id: Idd5014b57a8d10070108f5b235c822863dbac088
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-10-21 16:21:51 +00:00
Alexandru Croitor
87215c70c0 CMake: Fix rpath-link dependencies when cross-compiling
Private Qt module dependencies of a Qt module are recorded
in the IMPORTED_LINK_DEPENDENT_LIBRARIES property of a Qt module.
This property is used to compute the runtime dependency dir path
to be passed to the linker via the -rpath-link option.

If the referenced target does not exist in the scope where it's
used, no -rpath-link will be generated (or at least that specific
dir path won't be passed).
The linking operation will either fail saying the library is not found,
or a different version of the library might be silently picked up in
the sysroot or other implicit lib dir.

Make sure that QtFooModuleDependencies.cmake calls find_package() for
all Qt module private dependencies (or other Qt provided 3rd party
libs in the Qt6:: namespace) so that the targets are in scope and
IMPORTED_LINK_DEPENDENT_LIBRARIES does its job.

qmake also records the INTERFACE_LINK_LIBRARIES of a private Qt module
as the runtime dependencies of the module.
It's not clear why it does that. A private Qt module is an
INTERFACE_LIBRARY so it shouldn't add any new runtime dependencies.

Nevertheless, the find_package part of that has been recently addressed
in 2b6500cd15 for a different reason.

This change is basically the CMake equivalent of
326b91ea78

Pick-to: 6.2
Fixes: QTBUG-86533
Change-Id: Iaf514a14acaded4e8752149cca0c159a271be188
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-10-20 11:24:03 +02:00
Giuseppe D'Angelo
b6cbd9c43a QList: deprecate iterator<->pointer implicit conversions (2/3)
The constructor from a raw pointer should be
1) constexpr,
2) explicit, and
3) *private*.

We can do 1) without too much trouble.

2) is a (easy to fix) SIC in case of implicit conversions accidentally
relied upon from somewhere.

3) cannot be "easily" fixed by user code (they have to refactor), and
also, it's a BIC on Windows which encodes class members' access in
symbols. Someone may have been exporting some QList subclass, in turn
exporting the iterator classes, and therefore that someone now has the
constructors' symbols with a given access.

So, don't do 2+3 _just yet_ for user code, but set a deadline: Qt 6.5 is
the last that will support this. On Qt 6.6, we switch. All of this on
non-Windows, againt to avoid an ABI break. One can opt-in at any time
via a suitable define.

Given we have this define, use it to guard the other way around as well:
conversions from an iterator to a raw pointer should never be explicit
(there's std::to_address for this).

[ChangeLog][QtCore][QList] Converting a QList's iterator from and to a
raw pointer is deprecated, and will get removed in Qt 6.6. User code can
prepare for the change by defining QT_STRICT_QLIST_ITERATORS.

Change-Id: I0f34bfa3ac055c02af5a3ca159180304660dfc11
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-10-16 13:48:27 +02:00
Alexandru Croitor
aad4158959 CMake: Postpone target existence check for qml plugin targets
Each included qml Qt6FooPluginTargets.cmake file checks whether
all the dependency targets that are referenced in the file already
exist by the time the file is included.

If one of the referenced targets is missing, the file sets
${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE with a message mentioning
which targets are missing and also sets
${CMAKE_FIND_PACKAGE_NAME}_FOUND to FALSE.

All our qml package Config.cmake and Targets.cmake files are
include()d by Qt6QmlPlugins.cmake using a file(GLOB) which means the
order in which the files are loaded is implementation-defined.

Furthermore we didn't check the above set variables after each
inclusion, which means the values are overridden and the last plugin
to be loaded determines whether the Qml package is found or not.
If the last included file sets no error, it effectively silences any
previously set error.

Ever since we added dependencies between the qml plugin targets
themselves, we hit the above situation and depending on the platform,
no error was shown because the last file overrode any errors.

But we finally got a specific platform (wasm) which unearthed the
problem (QTBUG-97478). This can happen for any static Qt build though.

To fix this properly, we will most likely have to rewrite the whole
inclusion mechanism to use find_package() so that dependencies
can be resolved recursively as needed. This is a non-trivial change
that will have to be addressed in both qtbase and qtdeclarative.

In the mean time, a stop-gap solution that this change implements is
to include all the files while ignoring any error messages.
Then include the files one more time and check for error message after
each included file.

All qml plugin targets should have been brought into scope with the
first round of inclusions, thus circumventing "missing referenced
target" errors, while still catching any other possible errors.

Amends
6fd1216801f078f65be2cbc748cc459cb6912a4f
9fc302e6d146878103b3d105dce49c7695fcf93a
c368175a9e0a0c120b5bb8a0a02859bfc0cf42ba
in qtdeclarative.

Pick-to: 6.2 6.2.1
Fixes: QTBUG-97478
Task-number: QTBUG-95609
Task-number: QTBUG-97099
Change-Id: I157fa93fc979d726cd221d969b995b3642aeec77
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-10-15 18:25:29 +02:00
Alexey Edelev
2b6500cd15 Add PRIVATE_MODULE_INTERFACE to the module dependency set
PRIVATE_MODULE_INTERFACE libraries are linked as interface libraries to
the module's Private target and exported as the dependencies of package
targets. We need to register these modules as public package dependencies
to call find_package when resolving module dependencies in user
projects.

Pick-to: 6.2
Fixes: QTBUG-96558
Change-Id: I4eef550aab306eaf357539ef7a0f76d69873f856
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-15 15:53:23 +02:00
Alexey Edelev
f19f729511 Improve double call protection of qt_internal_generate_tool_command_wrapper
file(GENERATE) might fail if an unrelated configuration error happens,
and yet QT_TOOL_COMMAND_WRAPPER_PATH would already be set. Set the
cache variable only if generating was successful and replace the
QT_TOOL_COMMAND_WRAPPER_PATH valiable check with GLOBAL property to
protect the function from double call.

For CMake versions higher than or equal to 3.18 replace 'file(GENERATE'
call with 'file(CONFIGURE' to generate the wrapper at configure time
with the use of a plain semicolon character.

Pick-to: 6.2
Fixes: QTBUG-96870
Change-Id: Icf9c40f571d9c069043604f67ffcf2762966f6d0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-10-15 15:53:23 +02:00
Alexey Edelev
61441074ef Set QT_ANDROID_ABIS when builing qtbase for Android
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>
2021-10-14 19:57:10 +02:00
Thiago Macieira
dcb281af7d CMake: Make LTO build work
We don't need to check FEATURE_ltcg, just add -fno-lto unconditionally.
That makes QtCore compile with -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON.

Change-Id: Icb2516126f674e7b8bb3fffd16ada2c71d7334aa
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-13 18:29:35 -07:00
Thiago Macieira
cb0ea39895 CMake: remove support for building Qt with the old Intel compiler
This hasn't worked for some time. It's not in our CI and I don't think
it was working at all. When I tried to build it, I ran into several
problems with C++17 and an Internal Compiler Error I did not have any
interest in working around.

After discussing with the Intel compiler team, it was decided that
fixing those issues in the old compiler is not going to happen. Instead,
their recommendation is to adopt the new LLVM-based compiler, which
the last commit added support for.

This commit does not remove qmake support for the old ICC. It's possible
someone is using qmake with a non-Qt6 project and ICC.

Change-Id: Icb2516126f674e7b8bb3fffd16ad6350ddbd49e5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-13 12:49:49 -07:00
Thiago Macieira
63d80c7c4b CMake: add support for Intel's LLVM-based compiler
This includes a few cleanups to our .cmake files where it was easier to
combine existing sections of Clang / AppleClang that no longer needed to
be distinct.

icpx could be replaced with a shell script:
 exec `basename $0`/clang++ --intel "$@"

tst_qnumeric is not passing
FAIL!  : tst_QNumeric::classifyF() Compared values are not the same
   Actual   (qFpClassify(tiny / two)): 2
   Expected (FP_SUBNORMAL)           : 3
   Loc: [/home/tjmaciei/src/qt/qt6-icx/qtbase/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp(344)]
FAIL!  : tst_QNumeric::classifyD() Compared values are not the same
   Actual   (qFpClassify(tiny / two)): 2
   Expected (FP_SUBNORMAL)           : 3
   Loc: [/home/tjmaciei/src/qt/qt6-icx/qtbase/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp(344)]
FAIL!  : tst_QNumeric::floatDistance(denormal) Compared values are not the same
   Actual   (qFloatDistance(from, stop)): 0
   Expected (expectedDistance)          : 4194304
   Loc: [/home/tjmaciei/src/qt/qt6-icx/qtbase/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp(408)]
FAIL!  : tst_QNumeric::doubleDistance(denormal) Compared values are not the same
   Actual   (qFloatDistance(from, stop)): 0
   Expected (expectedDistance)          : 2251799813685248
   Loc: [/home/tjmaciei/src/qt/qt6-icx/qtbase/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp(408)]
P

Change-Id: Icb2516126f674e7b8bb3fffd16ad59431e8c3379
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-13 12:49:49 -07:00
Morten Johan Sørvig
a34a10c11f Support MoltenVK from homebrew
MoltenVK installed from homebrew has the following
directory structure:

  molten-vk/1.1.5/libexec/include/vulkan/vulkan.h
  molten-vk/1.1.5/include/MoltenVK/mvk_vulkan.h

Task-number: QTBUG-80576
Pick-to: 6.2
Change-Id: If6f5aeb55908f60fff49417ee1ddf4c2db980c5a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-13 09:37:36 +00:00
David Skoland
58d64b770a Rename variable for exported functions
Emscripten complains that this variable is deprecated and should be
replaced with the one given in this patch.

Change-Id: Iafee06fcb1f292de25570545d74d7327679461b0
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-10-13 05:03:02 +02:00
Giuseppe D'Angelo
49cf0b9459 Re-enable QT_NO_NARROWING_CONVERSIONS_IN_CONNECT for Qt
This define used to be set for the entirety of the Qt build but
was lost during the qmake->CMake transition. Re-enable it.

Change-Id: Idc4cb6ada485158559485b60f62f76439550b255
Pick-to: 6.2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-10-13 04:09:21 +02:00
Joerg Bornemann
8b09c9d690 CMake: Fix config tests not finding module-provided CMake packages
This amends commit 165e01d5d5.

Above commit broke the code that adds "${PROJECT_SOURCE_DIR}/cmake" to
CMAKE_MODULE_PATH.  The semicolon that separates entries of
CMAKE_MODULE_PATH must be escaped.  Otherwise, the semicolon separates
elements of the flags list.

Additionally, fix the QT_AVOID_CUSTOM_PLATFORM_MODULES code path which
lacked the addition of "${PROJECT_SOURCE_DIR}/cmake".

Pick-to: 6.2
Change-Id: I72f78cf066cabe6b0002dce1aa0294aa0dc9cbf0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-13 00:50:03 +02:00
Joerg Bornemann
0098e0ca86 Fix build with CMake 3.16
Do not read the target property LINK_LIBRARIES from interface libraries
as this leads to errors with CMake 3.16.

This amends commit 326b91ea78.

Pick-to: 6.2
Change-Id: I44251c7633d5ecd977cd05746ac311dd1285d1e3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-13 00:50:03 +02:00
Joerg Bornemann
326b91ea78 Fix missing QT.<module>.run_depends entries in module .pri files
The .pri files for public Qt modules were missing run_depends entries.
Those entries are used by qmake when linking plugins of a static Qt
build.  In shared builds, run_depends entries are used to decide whether
to add the -rpath-link argument to the linker.  In that matter,
run_depends entries serve a similar purpose as CMake's
IMPORTED_LINK_DEPENDENT_LIBRARIES.

In Qt5, run_depends entries consist of the qmake values QT_PRIVATE and
QT_FOR_PRIVATE.

QT_PRIVATE contains the Qt modules that are privately linked to the
public module, and QT_FOR_PRIVATE are the dependencies of the private
module.  That loosely translates to LINK_LIBRARIES of the public module
and INTERFACE_LINK_LIBRARIES of the private module.

Private modules whose public counterparts are already public
dependencies don't have to be added to run_depends.

Pick-to: 6.2
Fixes: QTBUG-84310
Change-Id: If7025c98ea462a2d5a143202df3d98d88e4fee08
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-12 01:07:21 +02:00
Joerg Bornemann
f19668ce65 Don't use libs in /usr/local for configure tests by default on macOS
Since commit f3c7d22dd0 we do not use
libraries from /usr/local and other non-system locations on macOS.  But
our configure tests still did.  This led to discrepancies between
find_package calls in configure tests and the Qt project itself.

Mentioned commit removed /usr/local and friends from
CMAKE_SYSTEM_PREFIX_PATH.  But we can't pass this variable to the
configure tests, because CMake sets it up and overwrites our value.

Pass CMAKE_SYSTEM_PREFIX_PATH and CMAKE_SYSTEM_FRAMEWORK_PATH as
QT_CONFIGURE_TEST_CMAKE_SYSTEM_{PREFIX|FRAMEWORK}_PATH variables to
tests.

Tests with separate project files that call find_package() must add code
like this after the project() command:

if(DEFINED QT_CONFIGURE_TEST_CMAKE_SYSTEM_PREFIX_PATH)
    set(CMAKE_SYSTEM_PREFIX_PATH
        "${QT_CONFIGURE_TEST_CMAKE_SYSTEM_PREFIX_PATH}")
endif()
if(DEFINED QT_CONFIGURE_TEST_CMAKE_SYSTEM_FRAMEWORK_PATH)
    set(CMAKE_SYSTEM_FRAMEWORK_PATH
        "${QT_CONFIGURE_TEST_CMAKE_SYSTEM_FRAMEWORK_PATH}")
endif()

Adjust pro2cmake accordingly.

Task-number: QTBUG-97076
Change-Id: Iac1622768d1200e6ea63be569eef12b7eada6c76
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-08 23:15:31 +02:00
Joerg Bornemann
01bfed1d0a CMake: Generate relative #line directives in qlalr output
When passing an absolute input file name to qlalr, the #line directives
in the output will contain absolute paths.  For reproducible builds,
it's desirable to have relative paths.

Pass the input file as relative path to qlalr to produce relative #line
directives.

Fixes: QTBUG-96267
Change-Id: I4ef1e4d5be7cbaf25a54a34ab7c2dbec06411a1d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-08 14:16:52 +02:00
Joerg Bornemann
165e01d5d5 CMake: Ensure that UNIX is set for INTEGRITY
Certain platform-related variables, in this case UNIX, must be set in a
platform module, because they get cleared after the toolchain file is
loaded.  Such platform modules live in upstream CMake, but there is none
yet for INTEGRITY.  This manifests in an undefined UNIX variable and
"System is unknown to CMake" warnings for the project and every
configure test.

Add the CMake module "Platform/Integrity" in the cmake/platforms
directory.  Add this directory to CMAKE_MODULE_PATH to let CMake load
Platform/Integrity when the toolchain file set CMAKE_SYSTEM_NAME to
"Integrity".

CMake's module directory takes precedence, when loading platform
modules.  This is special for platform modules and different from the
documented behavior of CMAKE_MODULE_PATH and include().

In case the user wants to provide their own platform modules via
CMAKE_MODULE_PATH, they can instruct Qt to not add its path by setting
QT_AVOID_CUSTOM_PLATFORM_MODULES to ON.

Make sure that configure tests with project files also load the custom
platform module.

Pick-to: 6.2
Fixes: QTBUG-96998
Change-Id: I9855d620d24dc66353cec5e847a2675b464ace26
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-05 19:35:47 +02:00
Lorn Potter
0e100a4d89 wasm: add simd support
Emscripten only supports
SSE1, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, and 128-bit AVX instruction
sets at this time.
https://emscripten.org/docs/porting/simd.html

Browsers might need to enable simd support in the advanced
configurations
about: config or chrome:flags

Enable by configuring Qt with -sse2

Pick-to: 6.2
Fixes: QTBUG-63924
Change-Id: Ifeafae20e199dee0d19689802ad20fd0bd424ca7
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-10-05 11:30:06 +10:00
Alexandru Croitor
99899dd299 Revert "CMake: Warn if cmake_minimum_required has an unsupported low version"
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>
2021-10-04 15:55:10 +02:00
Joerg Bornemann
f6cd55445d Don't export Qt6::ATSPI2_nolink target in Qt6GuiTargets.cmake
We don't have any APSPI2 includes in our public headers and should
therefore not export the target that provides ATSPI2 include paths for
consumers.

Link against PkgConfig::ATSPI2 instead of the _nolink target.
The former will not be exported.

Pick-to: 6.2
Fixes: QTBUG-97023
Change-Id: I4b12e0c2230917feeb963c02565e6db24f757bd3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-01 18:51:07 +02:00
Alexandru Croitor
657525965b CMake: Warn if cmake_minimum_required has an unsupported low version
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>
2021-10-01 14:32:36 +02:00
Topi Reinio
725b52141d CMake: Introduce QT_BUILD_ONLINE_DOCS flag for documentation builds
QDoc modifies its linking behavior depending on whether the -installdir
command line option was set or not; Without -installdir, QDoc will
use 'https://<url>' to link to targets loaded from external
documentation modules, instead of using relative paths.

Drop the -installdir if QT_BUILD_ONLINE_DOCS was set. This behavior matches
the 'build_online_docs' scope that was used for qmake documentation
targets, and is useful for documentation projects that are not part of
Qt but want to link to Qt docs simply by loading the index files of Qt's
modules.

Pick-to: 6.2
Change-Id: Ib1bbf7b9d784e0c276d2bc520240af4a6c8ba903
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-30 15:38:07 +02:00
Joerg Bornemann
acde9784ca CMake: Only write device prefix to target_qt.conf if necessary
The device prefix in target_qt.conf is necessary if and only if the
prefix on the host is different from the prefix on the device - in CMake
terms: if CMAKE_STAGING_PREFIX is different from CMAKE_INSTALL_PREFIX.

This removes the [Devices] section from target_qt.conf from our iOS and
Android packages, because we don't set CMAKE_STAGING_PREFIX for those
platforms.

Pick-to: 6.2
Fixes: QTBUG-96906
Change-Id: I1390e952e544e57d5dd3bc09d688a612db9b4247
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-28 22:18:13 +02:00
Joerg Bornemann
5ef0e3435e Fix separate_debug_info configure test for cross-compilation
The separate_debug_info configure test uses the CMake variable
CMAKE_OBJCOPY.  CMakeFindBinUtils in the test project finds the host's
objcopy despite CMAKE_TOOLCHAIN_FILE being correctly set.

We now add CMAKE_OBJCOPY to the list of variables that are passed to
configure test projects and remove the CMakeFindBinUtils include, which
looks rather internal anyways.

Pick-to: 6.2
Fixes: QTBUG-96798
Change-Id: I164c6bd1771e8789e9dd19b50573b33b8866bd3b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-28 15:59:31 +02:00
Alexandru Croitor
2ed267c820 CMake: Show error in user projects if wasm toolchain file not found
Rather than fail with obscure can't find Qt packages errors when the
Webassembly CMake toolchain file can not be found, error out with a
clear error on how to ensure it is found.

Pick-to: 6.2
Task-number: QTBUG-96843
Change-Id: I0f34cdcde05efb25c93017f3fd365186335ed52c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-27 18:29:44 +02:00
Alexandru Croitor
5d840f0f7a CMake: Get toolchain file path from EMSDK env for Wasm user projects
Try to to chainload the emscripten CMake toolchain file from the
EMSDK env var if it is set, instead of requiring the user to explicitly
specify a path to the file via QT_CHAINLOAD_TOOLCHAIN_FILE.

The order in which the toolchain file is chainloaded becomes is as
follows:

1) The initial toolchain file path that was specified when configuring
   qtbase is set written as the initial value of
   __qt_chainload_toolchain_file in qt.toolchain.cmake
2) If EMSDK env var is set, it overrides the value from 1)
3) If QT_CHAINLOAD_TOOLCHAIN_FILE cache var is supplied it overrides
   the value from 2)

Whichever value ends up in __qt_chainload_toolchain_file is
checked too see if the file exists.
If it exists it gets included, if it doesn't, a warning is issued.

This checking logic is a bit crude and should be improved and unified
with the Android chainload checking, but the current change already
improves the behavior for users of Qt.

Pick-to: 6.2
Task-number: QTBUG-96843
Change-Id: I5da58a329f659086aaaee765c9399d0369021b22
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-27 18:29:44 +02:00
Alexandru Croitor
c7d9e05a2b CMake: Split and clean up WebAssembly auto-detection code
Split qt_auto_detect_wasm into multiple helper functions and place
them in a new QtPublicWasmToolchainHelpers.cmake file.

We want to use them to try and detect the CMake toolchain
file location from within the generated qt.toolchain.cmake
file whem configuring a user project.

Pick-to: 6.2
Task-number: QTBUG-96843
Change-Id: Id8c2350e6dbe3c994b435681353bdaee114249a7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-27 18:29:44 +02:00
Joerg Bornemann
a0e56294c1 Skip unnecessary commands when cross-building tools
Introduce a new macro qt_internal_return_unless_building_tools which
simply calls return() if tools are not built.  This macro is supposed to
be called after qt_internal_add_tool().

Using this macro avoids having to special-case code for when
qt_internal_add_tool() creates imported targets in cross-builds.

Adjust pro2cmake accordingly.

Task-number: QTBUG-85084
Change-Id: I9e1c455c29535dd8c318efa890ebd739c42effc1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-27 16:34:23 +02: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
Joerg Bornemann
fb9cc52920 Rework how installation is prevented in non-prefix builds
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>
2021-09-22 18:32:47 +02:00
Alexey Edelev
68ad67b6fa Use only supported values when setting internal QT_FEATURE_ values
When setting QT_FEATURE_ values we need to convert the user-provided
FEATURE_ values to the one that is supported by QT_FEATURE_.

Pick-to: 6.2
Fixes: QTBUG-96300
Change-Id: Idd19fbf7f23f351a6c1cfdcedccfaaf6b0aa6e44
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-21 16:05:22 +02:00
Alexey Edelev
2483931e25 Add missing framework paths to header check targets
CMake doesn't add framework include paths for the includes if
add_custom_command is used. When all Qt modules are installed to a
single directory, frameworks could be found under
QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX, but for Conan builds
each module is installed to the separate directory. These directories
need to be listed in the QT_ADDITIONAL_PACKAGES_PREFIX_PATH variables
family. This takes into account directories that are listed in the
QT_ADDITIONAL_PACKAGES_PREFIX_PATH variables and considers they
can contain frameworks.

Pick-to: 6.2
Fixes: QTBUG-96511
Change-Id: I664381df4859a2e85c399cd94dc2f3996e452c03
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-20 17:54:12 +02:00
Allan Sandfeld Jensen
129dae5dbd Pass CMAKE compiler flags to arch detection
This fixes the detection of always available architecture based on
user set CMAKE flags.

Change-Id: I541ac9569766a0fe05f4395c06f2ee3bcd77b035
Fixes: QTBUG-91090
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-20 13:19:02 +02:00
Craig Scott
46438c91f7 Fix main() not being visible on Android
A recent change refactored the call to qt_internal_add_executable(),
but that had the unintended side-effect of changing the symbol
visibility from public to hidden. That meant that main() became hidden,
so while apps still built successfully, they could not be run. Restore
the original symbol visibility to fix this regression.

Amends d47278fd09

Pick-to: 6.2
Change-Id: I27d84ab2b0dd013d5c38dcfe55e88f307c4bc5dd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-20 21:19:02 +10:00
Craig Scott
b57f7f07cf Remove unused EXE_FLAGS option from qt_internal_add_executable()
The EXE_FLAGS option wasn't being used anywhere in any Qt repo
and it had no documentation as to its intended use. Remove it.

Pick-to: 6.2
Change-Id: I2f67ec57c1da7dc6eab81d5351361e770d19d7d5
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-18 01:54:08 +10:00
Craig Scott
c780708bd3 Remove TODOs related to checking CMake 3.21 features post-release
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>
2021-09-18 01:54:08 +10:00
Alexey Edelev
2f1d6e4c3f Do not generate cpp exports for pure STATIC modules
Static libraries don't need to export their symbols, and corner cases
when sources are also used in shared libraries, should be handled
manually.

Task-number: QTBUG-90492
Change-Id: I5cb0a3f7e280b042b678bdbe4475f2bbf9f6b9ba
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-17 13:57:17 +02:00
Alexey Edelev
f16c8fdf18 Add explicit install rules for the autogenerated cpp exports
If qt_internal_generate_cpp_global_exports is called outside the
qt_internall_add_module function scope, install rule that is
generated by qt_internall_add_module won't include generated
cpp export header files. This adds the explicit file-based install
rule for the generated cpp exports.
Since qt_internal_generate_cpp_global_exports now encapsulates all
install rules related to the generated cpp exports, no need to expose
the generated filenames outside the function.

It's expected that module public headers now could be added outside
the qt_internal_add_module function. Tune generating of the module
timestamp by replacing the DEPENDS value with generator expression.

Task-number: QTBUG-90492
Change-Id: I0f086abc8187c5d51117c3a75c47b58580f6913f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-17 13:57:17 +02:00
Craig Scott
d47278fd09 Ensure _qt_is_android_executable is set for internal executables too
The _qt_is_android_executable property is normally set by the
_qt_internal_create_executable() command. But various other internal
commands don't route through that and go through
qt_internal_add_executable() instead. The former is used only by the
public API, the latter only by the internal API. Refactor both so that
the internal one calls the public one. This ensures all targets receive
the same base settings, including the _qt_is_android_executable
property.

Fixes: QTBUG-96085
Pick-to: 6.2
Change-Id: I157356872c9d942d7be5f1abbbcbac97961b1f40
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-17 13:57:27 +10:00
Alexandru Croitor
d470497d9a CMake: Make standalone tests TestsConfig file repo-target-set specific
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>
2021-09-16 20:59:35 +02:00
Alexey Edelev
040258b260 Add missing private cpp exports template to install set
Add missing modulecppexports_p.h.in template to install set.

Amends e1fe816d46

Task-number: QTBUG-90492
Change-Id: I25db6f98637bd33a1c56f6b098ac76c4292de581
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-16 11:17:41 +02:00
Alexey Edelev
a7458b2503 Expose cpp export related arguments for qt_internal_add_module users
Functions that use qt_internal_add_module under the hood might need to
generate cpp exports, e.g. qt_internal_add_qml_module. Append cpp
exports related arguments to the qt_internal_add_module arguments set.

Task-number: QTBUG-90492
Change-Id: I4fd539bd1d8be4d3e57ed5b1b88dd2dbc2f5ca24
Reviewed-by: Craig Scott <craig.scott@qt.io>
2021-09-16 11:15:53 +02:00
Mårten Nordheim
a265333133 qdevice.pri: Use cmake separators for the path
Because otherwise we may end up with trailing backslashes

Pick-to: 6.2 6.2.0 6.1
Change-Id: I7ad24ec34c35f0a7b32241751bbcd2b26a8a23ea
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-10 21:12:58 +02:00
Alexey Edelev
7e794d71c0 Avoid implicit linking of plugin init library if finalizers were called
Propagating of plugin init libraries should take into account
plugin finalizers to avoid duplicating of object files in a linker
line.

Pick-to: 6.2
Fixes: QTBUG-96062
Change-Id: I48feac94b08a7eb08d84134e9e9ae6e7214f5bdd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-08 19:51:58 +02:00
Alexandru Croitor
6d20630b06 CMake: Remove unnecessary IF DEFINED HOST_PERL check
The variable might be defined to HOST_PERL-NOTFOUND which will return
early instead of issuing an error.

Change-Id: Id49dfd0fec8f477dad9e816e6128e36059e68702
Pick-to: 6.2
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-08 14:20:05 +02:00
Alexandru Croitor
c8dbb177f0 CMake: Allow opting out of building examples as ExternalProjects
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>
2021-09-06 19:44:26 +02:00
Alexandru Croitor
d7c6d69a8c CMake: Fix 'Cannot find source file' error with older CMakes
Configuring a static plugin init library with CMake versions earlier
than 3.18.0 fails at generation phase with

CMake Error at Qt6CoreMacros.cmake:2071
(add_library):
  Cannot find source file:
    example/plugins/basictools/pnp_basictools_init.cpp
Call Stack (most recent call first):
    qtbase/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:1998
  (_qt_internal_add_library)
    qtbase/lib/cmake/Qt6/QtPublicPluginHelpers.cmake:243
  (qt6_add_library)
    qtbase/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:1967
  (__qt_internal_add_static_plugin_init_object_library)
    qtbase/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:1989
  (qt6_add_plugin)
    qtbase/plugins/basictools/CMakeLists.txt:1 (qt_add_plugin)

Marking the generated file as GENERATED explicitly solves the issue.

Similar to e2c6f2ba7e

Fixes: QTBUG-96197
Pick-to: 6.2
Change-Id: If730a1fcbe6910d6041eb6eba03d6e45a025c424
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-06 10:35:36 +02:00
Joerg Bornemann
60f36007a3 CMake: Don't cache QT_SYNCQT across builds
There is no need for this variable to be stored in CMake's cache.  We
don't perform expensive operations to set up QT_SYNCQT, and we even
unset the cache variable to ensure it gets recomputed on
reconfiguration.

We still store QT_SYNCQT in a global property, because the function
qt_ensure_sync_qt is called in different directory scopes, and we want
to avoid re-calculations for every subdir.

It's now possible for the user to set QT_SYNCQT (see QTBUG-88088 for
motivation).  Also, in a non-prefix build, changes to syncqt.pl in the
source dir are reflected upon re-configuration in the build
tree (because qt_copy_or_install is called on every configure).

Pick-to: 6.2
Fixes: QTBUG-88088
Task-number: QTBUG-75290
Change-Id: I6137b060d200d3dafd4a64d5a6c1bd2549723d78
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-03 21:35:06 +02:00
Lorn Potter
375c7c47ff wasm: fail when configuring for wasm and EMSDK is not found
Pick-to: 6.2
Change-Id: Ic7fb933d8c2b42c3ba84a3b5a6c89a808d971bd1
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-01 08:02:08 +10:00
Juha Vuolle
17d7a8dc2e Update Android default SDK from 29 to 30
By the time of Qt 6.2 release all new apps targeting Play store must
target API level 30 (Android 11) or above (starting in 08/2021 for
new apps and 11/2021 for existing apps' updates).

Pick-to: 6.2 5.15
Task-number: QTBUG-94451
Change-Id: Id7fa2fd62899a7259e365c917292c6c3ac0d2b0d
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-08-27 18:31:17 +00:00
Joerg Bornemann
f9e9d21a11 CMake: Error out if ccache is requested but not found
Before, we would just issue a warning which is likely to get overlooked
in CMake's output.  Also, the configure summary would report "Using
ccache ... yes" but CMAKE_<LANG>_COMPILER_LAUNCHER stays unset, which is
inconsistent.

Make QT_USE_CCACHE=ON and missing ccache a hard error.

Task-number: QTBUG-88308
Change-Id: Iddc7f3a91428fd96ad0defbb1ca72bd46a90aa98
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-27 16:29:49 +02:00
Joerg Bornemann
d94652f792 Call MinGW's ld with -Bstatic when requesting static runtime linkage
The -static argument we used before is supported by ld, but not lld.
The latter requires --static or -Bstatic.  Use -Bstatic, which is
supported by both.

Pick-to: 6.2
Fixes: QTBUG-89549
Change-Id: I3c3069661bf4cd20e3298aff4714163b7419d3ef
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-27 15:45:25 +02:00
Alexey Edelev
e1fe816d46 Implement generating of private cpp exports
Add the generating of private cpp exports for Qt modules.

Add the GENERATE_PRIVATE_CPP_EXPORTS option to qt_internal_add_module
that is the manual switch for private exports generator. Existing
modules in qtbase doesn't follow any strict convention of using
private cpp export. So there is no clue how to detect if generating of
the private exports is required or not for the module.

Use autogenerated private cpp exports in QtNetwork module.

CPP_EXPORT_HEADER_NAME argument of the qt_internal_add_module function
is replaced by the CPP_EXPORT_HEADER_BASE_NAME and has a different
meaning. The provided name is used as a base name for the private and
non-private headers that contains cpp exports. Header files suffixes
are constant: .h and _p.h for the non-private and private header files
accordingly.

Pick-to: 6.2
Task-number: QTBUG-90492
Change-Id: Icf11304e00379fb8521a865965c19b974e01e62f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-27 11:01:47 +02:00
Alexey Edelev
928ffbd1e2 Use correct module include name across the project
Module may have specific module include name that should be taken into
account when specifying module include directories in different places.
The INTERFACE_MODULE_INCLUDE_NAME module property name is aligned to
the common naming rules and the property is used to preform include
paths instead of the direct use of the module name.

Add additional paths generated by qt_internal_module_info to keep them
consistent across all cmake files.

Pick-to: 6.2
Change-Id: I4c94017abc322c48616f47e65e371bd863bb087d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-27 11:01:38 +02:00
Alexandru Croitor
0dbf73e3de CMake: Warn when PRIVATE_MODULE_INTERFACE is provided with no target
Warn if the PRIVATE_MODULE_INTERFACE option is provided a value, but
there is no ${target}Private target to set the interface dependencies
on.

Pick-to: 6.2
Task-number: QTBUG-95921
Change-Id: I7d4df9cb3aa9b7746d836b82019ecdd9c8f50fdc
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-26 16:40:15 +02:00
Alexandru Croitor
d806ce6fc5 CMake: Properly export MODULE_PLUGIN_TYPES
Don't export the MODULE_PLUGIN_TYPES property only when a module has
an associated configure.cmake file with features. Instead, always
export it if a module defines a plugin type.

This fixes qttools DesignerTargets.cmake file to contain the plugin
types it defines, given that the Designer lib does not declare any
features via a configure.cmake file.

Pick-to: 6.2
Task-number: QTBUG-95668
Change-Id: Ic036c31768e03b51d3bce9c2afe48e04f69f435b
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-26 11:36:27 +00:00
Alexey Edelev
abb19da572 Add missing PRIVATE_MODULE_INTERFACEs to INTERNAL_MODULEs
To detect the internal module ouside the qt_internal_add_module
function need to mark it with the property.
This adds _qt_is_internal_module property to the Qt internal modules.
Since PRIVATE_MODULE_INTERFACE only was applicable to pure Private
modules, INTERNAL_MODULEs is missing those dependencies if they were
specified. Add extra condition to qt_internal_extend_target to link
PRIVATE_MODULE_INTERFACE libraries to internal modules as well.

Pick-to: 6.2 6.1
Change-Id: I9c32fa5bad3aff365f5d7663349e5365d5f1d72d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-24 20:58:39 +02:00
Alexandru Croitor
3c1125d9fe CMake: Create plugin initializers for static user plugins
Previously we only created object library static plugin initializers
for Qt plugins only, not user-project plugins.

The reason was that if a user tried to install the plugin target via
an export set, CMake would error out saying that the _init library is
not part of the same export set.

Introduce an OUTPUT_TARGETS option that would allow projects to get
the name of the generated _init target, so they can install it if
needed.
This was already done for qt6_add_qml_module, so we just introduce the
same option for qt6_add_plugin.

Now user static plugins will have an _init target created, which will
be propagated to consumers whenever the consumers link against the
plugin itself.

We also need an internal option to disable this propagation, because
it's handled a bit differently for Qt plugins which can be linked
either via finalizers or via usage requirements.

Amends 91c65dd80c

As a result of the implementation change, cleanup example projects
to ensure that they build successfully (the important part is
specifying the CLASS_NAME).

Only plugandpaint works properly with both shared and static Qt
builds.

echoplugin works with a shared Qt build, but not a static one due to
some assumptions in the C++ code about shared plugins.

styleplugin doesn't seem to work properly neither with shared Qt
builds nor static Qt builds, at least on macOS. But it builds fine.
For some reason even if the plugin is found, the style is not applied.

Amends 4caac1feea

Pick-to: 6.2
Task-number: QTBUG-80863
Task-number: QTBUG-92933
Change-Id: I6f631cda9566229b7a63992b23d7d7fa50303eeb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-24 16:10:31 +02:00
Joerg Bornemann
278368b523 CMake: Fix excessive size of precompiled header files
Do not add catch-all header files like QtCore, QtGui, etc. to
precompiled headers for targets that already define their own set of
precompiled header files.

This reduces the size of the precompiled headers and brings the pch file
sizes down into the region of the qmake build.

Pick-to: 6.2
Task-number: QTBUG-89122
Change-Id: I8e4d17aa6829c7d7b1aa01a01a61b6677e22c460
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-24 14:50:12 +02:00
Joerg Bornemann
1ac947e3af Add missing -help argument to qt-configure-module
Now it's possible to display a configure help screen per module with
  qt-configure-module <module-source-dir> -help

Pick-to: 6.2
Fixes: QTBUG-95943
Change-Id: I7d26006246af4b38b5a2ec6deca3f45c5313afec
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-20 19:44:43 +02:00
Joerg Bornemann
57ad532e75 Fix our usage of CMake script mode in Windows configure
This is a preparation for adding the -help argument to
qt-configure-module.bat.

Consider the call
  qt-configure-module.bat path/to/qt-module -help
Internally, we called
  cmake ... -P .../QtWriteArgsFile.cmake path/to/qt-module -help
which was supposed to separate the arguments and write them into
config.opt.

However, passing arbitrary arguments after "-P script.cmake" only worked
by accident and is not supported.  As soon as arguments are passed that
are valid CMake arguments, like -help or -G, the CMake call would fail.

Now, we let configure.bat and qt-configure-module.bat write the
arguments as is into config.opt.in and let QtWriteArgsFile.cmake read
this file, separate the arguments and write config.opt.

Pick-to: 6.2
Task-number: QTBUG-95943
Change-Id: I80f298a2aaf55b0f79fed86320a055eb2d2b6faa
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-20 19:44:43 +02:00
Joerg Bornemann
6e48d654d7 Don't force lld for Android when clang is used
This reverts commit 64c111e10f.

The claim of the commit message, that we cannot use the gold linker,
does not seem to be true (anymore?).  This is underlined by the fact
that CMake *forces* the gold linker for Android, whenever LTCG is
enabled (see Modules/Compiler/Clang.cmake as of CMake 3.21.1).

Change-Id: I90edac8555be4abdd44cd367228aeffb0d66b895
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-20 17:19:20 +02:00
Joerg Bornemann
80de516565 Fix Android -ltcg build
We're passing -Oz for release builds, but that's not a flag the linker
understands when -ltcg is enabled.  The build fails with:
    ld.gold: fatal error: Optimization level must be between 0 and 3

Fix this by using -O2, which -Oz is based on, and -O3 for the "full
optimization" that is used for core and gui.

Pick-to: 6.2
Fixes: QTBUG-89472
Change-Id: Ie1a86888baefce5ca97026e7d635f10d2819f9f4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-20 09:48:27 +02:00
Alexandru Croitor
6544312869 CMake: Pass Qt6_FIND_VERSION in Qt6Config when looking for components
Pass Qt6_FIND_VERSION to components when the
find_package(Qt6 ${ver} COMPONENTS Foo) signature is used.

Create a ConfigVersion file for BuildInternals, so that BuildInternals
passes the version check.

Fix qt_configure_file to look in the _qt_6_config_cmake_dir folder for
the template file rather than Qt6_DIR, because Qt6_DIR might be
accidentally unset after a failed find_package(Qt6) call and the error
is not helpful then.

We already pass versions everywhere else when looking for
dependencies, like in ModuleDependencies.cmake.in,
PluginDependencies.cmake.in, ModuleToolsDependencies.cmake.in.

Pick-to: 6.2
Fixes: QTBUG-91737
Change-Id: Ief1da0c6f239c935385e7ce662951e85ccfdf130
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-19 16:42:56 +02:00
Alexandru Croitor
6b6d42f6b8 CMake: Fix QT_ADDITIONAL_PACKAGES_PREFIX_PATH for cross-builds
The QT_ADDITIONAL_PACKAGES_PREFIX_PATH variable was introduced to
allow specifying extra locations to find Qt packages.

The reason it was introduced instead of just using CMAKE_PREFIX_PATH
is because the Qt6 component find_package call uses NO_DEFAULT_PATH
which means CMAKE_PREFIX_PATH is ignored.
We use NO_DEFAULT_PATH to ensure we don't accidentally pick up
system / distro Qt packages.

The paths from QT_ADDITIONAL_PACKAGES_PREFIX_PATH are added to the
find_package PATHS option in the Qt6 package, each
ModuleDependencies.cmake file and some other places.

Unfortunately that's not enough to make it work for cross-builds.

Imagine the following scenario.

  host qtbase, qtdeclarative installed in /host_qt
  target qtbase installed in /target_qtbase
  target qtdeclarative installed in /target_qtdeclarative

We want to cross-build qtlottie.

We configure qtlottie as follows
 /target_qtbase/bin/qt-configure-module /qtlottie_src -- -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=/target_qtdeclarative

We expect the target QtQuick package to be found, but it won't be.

The reason is that QT_ADDITIONAL_PACKAGES_PREFIX_PATH is added to the
PATHs option, but we don't adjust CMAKE_FIND_ROOT_PATH.

Without adding the new paths in CMAKE_FIND_ROOT_PATH, CMake will
re-root the passed PATHs under the existing CMAKE_FIND_ROOT_PATH,
which is QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX, which evaluates to
/target_qtbase. There is no QtQuick package there.

To fix this, prepend the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH
to CMAKE_FIND_ROOT_PATH.

The location where we currently do CMAKE_FIND_ROOT_PATH manipulations
is in the qt.toolchain.cmake file, so to be consistent, we prepend the
new prefixes there as well.

We need to adjust both CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH,
due the path re-rooting bug in CMake.
See https://gitlab.kitware.com/cmake/cmake/-/issues/21937 as well as
the existing comment in qt.toolchain.cmake marked with
REROOT_PATH_ISSUE_MARKER.

We also need to do a few more things to make the setup work

Because Qt6Config uses NO_DEFAULT_PATH, the CMAKE_PREFIX_PATH
adjustments we do in the toolchain file are not enough, so we still need
to add the same prefixes to the Qt6Config find_package PATHS option.

One would ask why do we need to adjust CMAKE_PREFIX_PATH at all then.
It's for find_package(Qt6Foo) calls to work which don't go through
the Qt6Config umbrella package.

To make the CMake re-rooting behavior happy, we need to ensure the
provided paths are absolute.
So we iterate over the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH,
to make them absolute. We do the same for the environment variable.

We need to append lib/cmake to the prefixes which are added to
CMAKE_PREFIX_PATH, otherwise the CMake re-rooting bug is hit.

We need to specify the Qt6 package location (${_qt_cmake_dir}) to the
PATHS option in the various Dependencies.cmake.in files, to ensure
that dependency resolution can jump around between the Qt6 dir and
the additional prefixes. Previously the dependency lookup code assumed
that all dependencies would be within the same prefix.

The same is needed for qt and qml plugin dependency lookup.

Amends 7bb91398f2
Amends 60c87c6801
Amends 5bbd700124

Pick-to: 6.2
Fixes: QTBUG-95854
Change-Id: I35ae82330fec427d0d38fc9a0542ffafff52556a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-19 16:42:56 +02:00
Alexandru Croitor
d65ccd3999 CMake: Don't backup cmake prefix when there are no tool dependencies
This is just a minor optimization.

Pick-to: 6.2
Change-Id: Icf0fc615895e1def63c57a72694c89f7ae7ee5cf
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-19 16:42:56 +02:00
Alexey Edelev
2059d294eb Remove unnecessary version of module from _MODULE_DEPENDENCIES
_<module>_MODULE_DEPENDENCIES variable in the
<module>Dependnecies.cmake should only contain the list of targets that
module depends on, but not versions. Version of the first module
appears in the list because of the regression introduced in
425ff34aa1

Amends 425ff34aa1

Pick-to: 6.2
Change-Id: Iaa42120af6bac742bdf0f8d389bd8e5bdef9c1d1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-19 13:35:40 +02:00
Alexandru Croitor
e7455644a2 CMake: Don't install metatypes files for user projects
Installing extracted metatypes json files for user projects was an
oversight. We shouldn't install anything on behalf of user projects,
but rather give them enough information so they can do it the
themselves.

Make all the install options of qt6_extract_metatypes internal,
change the behavior not to install the files by default, unless
__QT_INTERNAL_INSTALL is passed, which is used for the Qt build only.

__QT_INTERNAL_NO_INSTALL is now a no-op and should be removed from
projects.

This is behavior change for existing public API, but it's better to
fix this now before 6.2.0 release.

Introduce a new OUTPUT_FILES option to allow assigning the extracted
metatype file paths into a variable that the project provides.
The project can then install the files where they need them.

[ChangeLog][CMake] qt6_extract_metatypes does not install metatypes
files anymore. Instead the OUTPUT_FILES option can be provided to get
the list of extracted files for further processing.

Pick-to: 6.2
Task-number: QTBUG-95845
Change-Id: If5dd0255a5fea2b598e15118c29ec2ab2ba4324e
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-08-19 13:35:40 +02:00
Alexandru Croitor
a52b24ac39 CMake: Include quiet packages in feature summary
This will show packages that were found (or not) with
find_package(QUIET) in summary just before the configure summary.

It's useful for CI logs to determine whether some Qt packages was not
found when cross-compiling.

Pick-to: 6.2
Change-Id: Ic7d5062cf061f7c60b5c74374f957065dd8029f5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-18 22:15:35 +02:00
Kai Köhne
d2359b2d4e Pick up *Tools components also from host Qt
Let find_package(Qt6 COMPONENTS LinguistTools) for a cross-compiled
Qt fall back to search LinguistTools in the host Qt.

Use the same trick as in QtModuleDependencies.cmake: Prepend both
CMAKE_PREFIX_PATH and CMAKE_FIND_ROOT_PATH with the QT_HOST_PATH
(respective ${QT_HOST_PATH}/lib/cmake).

Furthermore adding ${QT_HOST_PATH}/lib/cmake to PATHS argument
makes sure that find_package will work even with NO_DEFAULT_PATH.

Make sure not to match ShaderTools and Tools packages.
ShaderTools is the cross-compiled package, the host package name is
ShaderToolsTools.
Tools is the cross-compiled module from qttools.

Allow an opt out via a QT_NO_FIND_HOST_TOOLS_PATH_MANIPULATION
variable in case that we accidentally match more packages ending in
Tools that are actually cross-compiled packages.

Pick-to: 6.1 6.2
Fixes: QTBUG-95602
Change-Id: Ib0a787716fa529e36f22356da069e705d9eed5fa
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-18 18:38:16 +02:00
Alexandru Croitor
ae6a8ddf45 CMake: Remove deprecated CFBundleLongVersionString from Info.plist
The CFBundleLongVersionString Info.plist entry has been deprecated and
removed from Apple documentation for a long time now.

Remove it.

Pick-to: 6.2
Task-number: QTBUG-95838
Change-Id: I4e4f74e00d678fd67875976c8884a80cdbb8cec4
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-17 21:30:34 +02:00
Alexandru Croitor
3d2dc88850 configure: Fix iOS option to be passed for both platform and xplatform
Task-number: QTBUG-95838
Pick-to: 6.2
Change-Id: If0617e1d9c47595d4a350a91ab4f7d47546ebf08
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 21:30:34 +02:00
Alexandru Croitor
67dae9e6ee CMake: Save value of QT_UIKIT_SDK in QtBuildInternalsExtra.cmake
The value of QT_UIKIT_SDK is used in configure tests via
qt_config_compile_test -> qt_get_platform_try_compile_vars.

Up till now QT_UIKIT_SDK was only available in qtbase only.

Save the value in BuildInternals to ensure it's used for other repos
as well.

Change-Id: I46f372267782f1c8e7d48c237fe0264ac72d33bb
Pick-to: 6.2
Task-number: QTBUG-95838
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 21:30:34 +02:00
Alexandru Croitor
fe40e08da4 CMake: Fix building iOS projects with a single-arch Qt build
Automatically set the CMAKE_OSX_SYSROOT and CMAKE_OSX_ARCHITECTURES
values with the ones Qt was configured with, when configuring a user
project with the Xcode generator and a single arch / sdk Qt build.

This ensures that calling xcodebuild from the command line chooses the
correct architecture and SDK when building the project.

Allow to opt out of this behavior by passing
QT_NO_SET_OSX_ARCHITECTURES and QT_NO_SET_OSX_SYSROOT.

Amends 55a15a1c1b
Amends a6a3b82ffb

Pick-to: 6.2
Task-number: QTBUG-95838
Change-Id: Ifab16e9eee3100a9b80a2a14b3ea29ba8d9aa6fc
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 21:30:34 +02:00
Joerg Bornemann
153fd84c8a CMake: Suggest "ninja install" for multi-config builds
The configure summary now suggests "ninja install" for Ninja
Multi-Config builds, because "cmake --install ." does not install all
configurations.  See CMake upstream issue #21475.

Pick-to: 6.2
Change-Id: Ie3129a906945db9d09c6772ce66ec7239797b8fc
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-17 19:18:54 +02:00
Joerg Bornemann
eafbda4191 CMake: Fix feature evaluation for feature defines
Passing -DFEATURE_developer_build=TRUE did not add the define
QT_BUILD_INTERNAL to src/corelib/global/qconfig.h like
-DFEATURE_developer_build=ON would.

This happened, because the feature evaluation in
qt_evaluate_feature_definition did a string comparison against "ON".

Normalize both sides of the string comparison, and thus support all
booly values for features.

Pick-to: 6.2
Fixes: QTBUG-95732
Change-Id: Ibf03579c05919b35219438361fc93676b7cca7cc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-17 09:23:40 +02:00
Joerg Bornemann
b43afd5315 CMake: Make precompiled headers work for Android on Windows
When building Qt for Android on Windows, the precompile_headers test
failed if the source directory was passed as absolute path without drive
letter.  See CMake upstream issue #22534.

Work around the CMake issue by ensuring that the path is properly
prefixed with a drive letter.

Pick-to: 6.2
Fixes: QTBUG-95652
Change-Id: I3154b6c0bb2f53533306227074b24fbbf5973b05
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-17 01:36:22 +00:00
Alexandru Croitor
6ef3d070a8 CMake: Replace usage of WIN32 with CMAKE_HOST_WIN32 in qconfig.cpp
The workaround of adding a drive letter to
QT_CONFIGURE_PREFIX_PATH_STR should be done when running on any
Windows host, not only when targeting Windows.

Amends 59c3be7117

Pick-to: 6.1 6.2
Task-number: QTBUG-87580
Change-Id: Ic6ca50aa58a4a54fb483e90fe61a907fe86cb002
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 03:36:22 +02:00
Martin Vejdarski
3c148323c0 CMake: Exclude dSYM INSTALL commands for already excluded tools in debug
Debug tools are excluded from the ALL target for debug_and_release
builds. However, when using the -separate-debug-info option, the same
exclusion wasn't being applied for their dSYM INSTALL commands,
resulting in a CMake install error.

Pass any additional install args like

  EXCLUDE_FROM_ALL COMPONENT "ExcludedExecutables"

to the installation rules of qt_enable_separate_debug_info and
install dSYMs for executables per-config in a multi-config build.

All the non-main config executable install rules are optional because
the non-main config executables are excluded from ALL.

Amends 5b136abd21

Pick-to: 6.2
Fixes: QTBUG-93999
Change-Id: I95c3ce28215c3ee535551e4b7a5fa9731f8f1c28
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 02:55:12 +02:00
Alexandru Croitor
48fa7f53cc CMake: Save QT_BUILD_BENCHMARKS and other info in BuildInternalsExtra
So that those values are used when configuring other repos in a
per-repo build arrangement.

Pick-to: 6.2
Change-Id: I5ff86260116c52afc87d7fcd5cbd047fcb9dde22
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 02:55:12 +02:00
Kai Köhne
d6661c5622 CMake: Warn if qt_internal_plugin(target) does not end with 'Plugin'
The logic for linking plugins in a static build in Qt6*Plugins.cmake
looks up plugins that are named Qt6*PluginConfig.cmake, and the file
name is computed by the target name.

Not naming the target 'Plugin' therefore means it won't be picked up
in static builds.

Pick-to: 6.2
Task-number: QTBUG-95731
Change-Id: Ic83a29d7c91492c302eb413a69577a0c550e1a1b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-12 12:43:49 +02:00
Alexey Edelev
f0bb95cb63 Use _qt_module_has_headers instead of INTERFACE_MODULE_HAS_HEADERS
After introducing the _qt_module_has_headers target property, it's
better to replace the INTERFACE_MODULE_HAS_HEADERS use by
_qt_module_has_headers since properties duplicate each other.

Pick-to: 6.2
Change-Id: I4d62ed71b8ed8263f51d8575628693122580b4a7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-11 21:39:53 +02:00
Alexandru Croitor
06c2400f5d CMake: Warn when using CMake 3.21.0 due to issue in AUTOMOC/AUTOUIC
There can be cases where trying to incrementally rebuild an already
built Qt will cause a ninja dependency cycle error due to incorrect
dependency information created by AUTOMOC and AUTOUIC.

Example error when building qtscxml tests

ninja: error: dependency cycle:
auto/scxmlcoutput/default/tst_scxmlcoutput_default_autogen/timestamp
->
auto/scxmlcoutput/default/ids1.h ->
auto/scxmlcoutput/default/tst_scxmlcoutput_default_autogen ->
auto/scxmlcoutput/default/CMakeFiles/tst_scxmlcoutput_default_autogen
->
auto/scxmlcoutput/default/tst_scxmlcoutput_default_autogen/timestamp

Example error when building Qt Creator

ninja: error: dependency cycle:
src/shared/help/shared_help_autogen/include/ui_filternamedialog.h ->
src/shared/help/shared_help_autogen/timestamp ->
src/shared/help/shared_help_autogen/include/ui_filternamedialog.h

Warn and advise to use a different CMake version instead.

Pick-to: 6.1 6.2
Change-Id: I6f529ba6a526663bc6ed699b1bfe8a9094129887
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-11 21:03:56 +02:00
Li Xinwei
1a8de144b6 Copy Find*.cmake to ${QT_BUILD_DIR}/lib/cmake/Qt6
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>
2021-08-11 01:31:03 +08:00
Alexandru Croitor
dfabb5b677 CMake: Use __qt_internal_propagate_object_library for static plugins
Address TODO and use the new helper
__qt_internal_propagate_object_library function instead of
target_sources when linking static plugin initializers via usage
requirements.

Note that to work correctly this depends on using the
target_link_options object library linking approach, which means a
minimum CMake version of 3.17, which is already the case for static
Qt usage.
With CMake 3.21, it will use target_link_libraries approach instead.

With CMake version 3.16 or lower, currently, this won't work correctly
on Linux if there are dependencies wrapped in genexes because the
__qt_internal_propagate_object_library call will try to use
the still-by-default-enabled 'object_libraries' finalizer mode via
__qt_internal_collect_dependency_object_libraries and that stops
the usage of the target_sources approach to link the object files
directly.

This isn't a big deal though, because we already require CMake 3.20
as the minimum.
It might be a bigger deal if we will need any of this functionality
to work with 3.16 in shared Qt builds where the user project tries
to create and link against custom static plugins. But that's already
likely to be a can of worms even without this specific edge case.

Amends a37957df5c
Amends 91c65dd80c
Uses 3329212815

Pick-to: 6.2
Task-number: QTBUG-92933
Change-Id: I8710e79eee265d820f65c8ccc3d0bd0c0ee6eccd
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-10 16:51:53 +02:00
Alexandru Croitor
5161d8d525 CMake: Remove qt6_enable_object_libraries_finalizer_mode
qt6_enable_object_libraries_finalizer_mode is not needed anymore
now that static Qt builds require CMake 3.21 and thus CMake takes
care of placing object library object files at the beginning of
the link line.

Rename qt6_enable_import_plugins_finalizer_mode to a more generic
qt6_set_finalizer_mode that can enable or disable multiple
different modes.

For now the only available mode is "static_plugins" which handles
the behavior of the old function name.

The mode can be enabled by calling

 qt6_set_finalizer_mode(${target} ENABLE MODES "static_plugins")

Note that the function is re-tagged as being in Technical Preview.

Ideally we would not need it at all. But we need to provide some
workaround for the limitations of linking Qt static plugins in CMake
on Linux-y platforms that use bfd ld or ld.gold.

The workaround does not work well with dependencies wrapped in
generator expressions which is why we can't confidently advertise it
as a proper solution.
Our hope is that this can be fixed in future upstream CMake versions
and the function can be removed.
See 6fcc272ac9 for details.

Adjust the tests due to the renamed and removed functions.

Amends 19e789bace
Amends cdbb390c4a
Amends a25027eecb
Amends 6fcc272ac9
Amends a3c430f390

Pick-to: 6.2
Fixes: QTBUG-95169
Task-number: QTBUG-95601
Task-number: QTBUG-95603
Change-Id: I51b85f776ec29fc04fed1a637eba7d1f60609e69
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-10 16:51:53 +02:00
Alexandru Croitor
72a1e55472 CMake: Fix qt_find_package to work when CMP00126 is set to NEW
When CMP00126 is set to NEW, set(CACHE) doesn't remove regular
variable bindings with the same name as the cache variable.

This introduced an issue in qt_find_package, which called
find_package(CONFIG QUIET) to try and find a package config file, but
did not clean up the non-cache _FOUND variable which is automatically
set to 0 by CMake if no Config file is found.

Make sure to unset both the regular and cache _FOUND variables if either
the package config file was not found, or if none of the provided
targets found even if the Config file was found.

Also move the _DIR cache variable cleaning into the same code block.

Amends 4c31ce68d5
Amends 34b1c1c23c

Fixes: QTBUG-95635
Pick-to: 6.2
Change-Id: I871987217526e0f0a20038a8da52625838e49488
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-10 16:51:53 +02:00
Alexandru Croitor
eb22826057 CMake: Fix build with CMake master / 3.22
CMake master / 3.22 introduced a behavior change in how conditions are
evaluated in the while command. It is now consistent with how if()
evaluates conditions.

This caused an issue in Qt code where a "(" opening parenthesis was
evaluated as part of the condition rather than as a string.

Fix this by wrapping the evaluation of the variable in quotes.

Pick-to: 6.1 6.2
Change-Id: I70c26dc91394f4a14f7a26419df264a069dc7dc5
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Craig Scott <craig.scott@qt.io>
2021-08-10 12:05:31 +00:00
Joerg Bornemann
0e92ec9728 Remove dysfunctional -coverage configure argument
The -coverage argument merely added compiler flags for the Qt build.  It
was never properly ported to the CMake build, and it doesn't seem
feasible to have configure arguments for every possible compiler option.

The same can be achieved by passing the needed compiler option to CMake,
for example: CMAKE_CXX_FLAGS=-fsanitize-coverage=trace-pc-guard

Pick-to: 6.2
Fixes: QTBUG-86227
Change-Id: Ieef9acaedc0a839f9fb35b4403395eea28643864
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-10 12:00:13 +02:00
Alexandru Croitor
b2f00dfb46 CMake: Rename qt6_add_plugin TYPE option to PLUGIN_TYPE
The intention is to remove TYPE as a keyword completely before 6.2.0
release, but in case if that's not possible due to the large amount
of repositories and examples, just print a deprecation warning for
now and handle both TYPE and PLUGIN_TYPE.

Task-number: QTBUG-95170
Pick-to: 6.2
Change-Id: If0c18345483b9254b0fc21120229fcc2a2fbfbf5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-06 21:08:21 +02:00
Alexandru Croitor
7d86cf02c1 CMake: Partially fix QUIETness of find_package(Qt6 COMPONENTS Foo)
When Qt5Config.cmake was ported to Qt6, the assignment of
_Qt6_FIND_PARTS_QUIET was accidentally left out.

Make sure that when find_package(Qt6 QUIET COMPONENTS Foo) is
called, the underlying component find_package(Qt6Foo) call gets
a QUIET option as well.

This will silence short-form warnings like

 -- Could NOT find Qt6Foo (missing: Qt6Foo_DIR)

It currently won't silence any warnings produced by the transitive
find_package calls in QtModuleDependencies.cmake. That will require a
separate change.

Remove usage of _Qt6_FIND_PARTS_REQUIRED which was always empty.
See details of QTBUG-95573 why it's currently not used.

Pick-to: 6.2
Task-number: QTBUG-95573
Change-Id: I3822c068eecbe84c306a1b04f4187278d35ec3d5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-06 17:00:21 +02:00
Alexandru Croitor
825cb50c27 CMake: Improve component / package not found error messages
Provide better error messages when a Qt package / component is not
found.

Mention the location of the expected Config file on the file system,
whether it exists
Also mention the location of the Config file that was specified by the
user when configuring the project or which CMake computed and stored
in QtModule_DIR cache var.

Mention that a package is not found in case if the main target exposed
by that package is not found.

If the target is not found, mention that it might be due to
QT_NO_CREATE_TARGETS being set to TRUE (when it is set to true).
If it is set to true, the assumption is that the target must have been
defined by something else before the find_package call (either an
earlier find_package call without QT_NO_CREATE_TARGETS set to TRUE or
maybe it's the use case of Qt being built together with its examples
or it's a super build).

Unset _Qt_NOTFOUND_MESSAGE to ensure that the Qt6 not found error
message is not spilled into any subsequent find_package(Qt6) calls,
causing a cascade of unwarranted warnings / errors.
Make sure to unset it only if components were specified, so the
message is not shown or unset in any of the recursive
find_package(Qt6) calls which is a dependency for regular Qt module
packages.
This works fine, because find_package(Qt6) calls with components are
only done in project code and not done by the transitive dependency
code (which looks for Qt6Foo packages directly).

Remove some dead code.

Pick-to: 6.2
Task-number: QTBUG-95532
Change-Id: Ie93d18e25e33aa0fe9e9da9a60e3d3e4cd6adb58
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-06 17:00:21 +02:00
Joerg Bornemann
fe9c705e9a CMake: Make qt6_wasm_add_target_helpers an internal function
This function is called by qt_add_executable.  There is no need to
expose it as public function.

Fixes: QTBUG-95172
Change-Id: I85a1d906ecda42458e226db225e47c1d348a72f1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-04 17:01:11 +02:00
Alexandru Croitor
6518bcc167 CMake: Enforce minimum CMake version in user projects
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>
2021-08-04 16:03:08 +02:00
Alexandru Croitor
9aa0d99e66 CMake: Bump min required CMake version for static Qt builds to 3.20
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>
2021-08-04 16:03:08 +02:00
Li Xinwei
a251443949 Avoid to call _qt_internal_set_up_static_runtime_library() twice
Pick-to: 6.2
Change-Id: I28985470b3e0b88befbbd2d62a027670d7d6c822
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-03 04:18:42 +08:00
Tor Arne Vestbø
7c14223b1e testlib: Update a few remaining instances of the deprecated -xunitxml format
The format was renamed in 27db9e458c.

Pick-to: 6.2
Change-Id: I53975c7467d8768dc9dc9ac2d89c42eefa12e22f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-07-29 18:46:39 +02:00
Alexandru Croitor
3c23317552 CMake: Make WrapVulkanHeaders target optional for QtGui consumers
If Vulkan headers are present on the system when qtbase is configured,
QtGui and QtOpenGL should be compiled with Vulkan support.

If a user project uses a Qt built with Vulkan support, but their system
is missing Vulkan headers, the project configuration needs to succeed.

The project will get compilation errors if it uses Vulkan headers, but
that's intended.

This use case was broken when fixing Vulkan to be found when building
Qt for Android.

Fix the regression with a combination of things
1) Mark the WrapVulkanHeaders package as optional (already the case)
2) Use the include directories directly when compiling Gui and OpenGL
3) Propagate WrapVulkanHeaders::WrapVulkanHeaders link requirement to
   consumers only if the target exists. It won't exist if Vulkan
   include dirs are not found

This also requires some changes in pri and prl file generation.

For prl file generation, we don't want to link to the
WrapVulkanHeaders target, so we filter out all dependencies that
use TARGET_NAME_IF_EXISTS for anything that calls
__qt_internal_walk_libs which includes qt_collect_libs.

For pri files, we make sure to generate a uses=vulkan/nolink clause
by inspecting a new _qt_is_nolink_target property on the target.

We also don't add include dirs to the pri file if the new
_qt_skip_include_dir_for_pri property is set.
This is intended for Vulkan, because there is separate qmake logic to
try and find the include dirs when configuring a user project.

As a drive-by, fix nolink handling for WrapOpenSSLHeaders.

Amends bb25536a3d
Amends 7b9904849f

Pick-to: 6.2
Fixes: QTBUG-95391
Change-Id: I21e2f4be5c386f9e40033e4691f4786a91ba0e2d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-29 16:38:50 +02:00
Alexandru Croitor
3b2157ed9e CMake: Fix MoltenVK headers to be found on macOS
This fixes building Qt with Vulkan support on macOS which aside from
the regular Vulkan headers also needs the location of the MoltenVK
headers.

This assumes the usage of the LunarG Vulkan SDK for macOS.

Pick-to: 6.2
Fixes: QTBUG-80576
Change-Id: I030b2fdeaafdd7bf5ebe6fb4c9ea860917e84056
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-29 16:38:49 +02:00
Alexandru Croitor
42970e490a CMake: Bump min required CMake version for shared Qt builds to 3.16
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>
2021-07-28 20:54:14 +02:00
Jaeyoon Jung
c89a9ccbcc CMake: Keep public include header locations for internal module pri
Amends f254d62cb1.

Task-number: QTBUG-95303
Pick-to: 6.1 6.2
Change-Id: Ica8d2850fe427b780d62cd9a9528f387a7ea1b79
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-26 20:46:40 +09:00
Li Xinwei
bd594f9457 CMake: Use namespaced variables in Qt6*Dependencies.cmake
Pick-to: 6.2 6.1
Change-Id: I166988020cfd9750a4d58e519742215d0c03ad3e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-24 03:51:53 +08:00
Li Xinwei
2915921ad2 Fix generated pri and prl files
Quote the paths after "-L".

Get MSVC’s implicit link directories from $ENV{LIB}.

Fix some issues cause by Inconsistent case.

Amends 2c49f85380

Fixes: QTBUG-95198
Pick-to: 6.2 6.1
Change-Id: Ie82f10b088e2764396377726340509f24a4ae8e7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-17 02:42:13 +08:00
Alexandru Croitor
fb9cbd3b2a CMake: Clean up and simplify qt6_extract_metatypes implementation
Remove copying of json files in non-prefix builds.
Previously, this was done to mimic the directory layout of prefix
builds in a non-prefix build, but the extra complexity is not worth
it.
Keeping the files in the build directories of each repo in a
non-prefix build should be good enough.

As a result, we don't need to distinguish which file path should be
passed in INTERFACE_SOURCES. Now we have only 2 paths to consider, the
BUILD_INTERFACE one and the INSTALL_PREFIX one, rather than 3
different paths.

Move the code that handles installation closer together.

Rename the internal COPY_OVER_INSTALL option to
___QT_INTERNAL_NO_INSTALL.
We might want to expose it as a public option later, but it depends on
whether we will disable default installation for user projects.

Remove assignment of some properties that are not used anymore.

Amends c431e2d33c

Pick-to: 6.2
Task-number: QTBUG-94942
Change-Id: I3a26d1988987b2ce7c7d01d2311c13b3da3175a8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-07-16 18:19:19 +02:00
Alexandru Croitor
e0a0101290 CMake: Apply bitcode flags to internal plugin object lib initializers
All internal libraries, plugins, object libraries (resources, plugin
initializers) need to be built with bitcode flags when targeting iOS.

Internal here means all libraries added by qt_internal_add_X
functions or associated with internal libraries.

We didn't do that for plugin initializers, which were added not too
long ago.

Extract the logic that links to Qt::PlatformModuleInternal into a
separate function to be used for object libraries.
Use it for resources and plugin initializers. It will also be used
in qtdeclarative for qml plugin initializers.

Pick-to: 6.2
Task-number: QTBUG-95208
Change-Id: I366996078f5e9d1c2d2797f6b81c522ee99529e3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-07-16 09:52:26 +02:00
Alexandru Croitor
3595613a0a CMake: Don't propagate -fapplication-extension to user projects
Both the compiler and linker -fapplication-extension flag should only
be applied when building Qt's libraries (not executables).

It's up to the user project whether their code will be restricted with
application-extension-only APIs.

In qmake that can be achieved by adding to the qmake project
  CONFIG += app_extension_api_only

In CMake it can be achieved by either adding the compiler and link flags
in the project directly (using target_X_options) or by setting the
appropriate setting in the Xcode project when using the Xcode
generator.

Amends e189126f1a

Pick-to: 6.2
Task-number: QTBUG-95199
Change-Id: Ie7a764d460a89c7650391abff0fcc5abfcabef64
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-07-16 09:52:24 +02:00
Alexandru Croitor
616c32be04 CMake: Fix bitcode linker flags not to be added on iOS
We shouldn't force add the bitcode linker flags to user projects.
And we don't link anything when building Qt for iOS itself, we only
archive object files into static libraries.

The final decision whether bitcode should be used is up to the Xcode
project. That is controlled by Xcode's ENABLE_BITCODE option.

Bitcode compile flags are still added when building Qt itself.

Amends a046833176

Pick-to: 6.1 6.2
Task-number: QTBUG-95199
Change-Id: I04c77f659b82269bb8010ea262b2e51f36e9def3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-07-16 09:52:21 +02:00
Alexandru Croitor
ba0d5ab555 CMake: Force Integrity to be a static Qt build
This was the case in Qt 5.15 as well.

The CMake toolchain file that Qt's CI is using is already setting
BUILD_SHARED_LIBS to OFF, but it's better to be explicit like we
are with WebAssembly and iOS.

Pick-to: 6.2
Change-Id: Ief17259c15690a97337e9df451663718601c2a52
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-07-15 17:12:57 +02:00
Allan Sandfeld Jensen
f3e006a698 Report multi-arch targets in the configure summary
Otherwise it will confusingly only list the host arch

Pick-to: 6.2
Change-Id: Ic6d080f1fd9ebfa260ce7c35bd5e5b4ee686f083
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-14 20:59:09 +02:00
Li Xinwei
c9db5eed54 fix wrong argument
amends 5b136abd21

Pick-to: 6.2
Change-Id: I8dee597c4ba41ecd07289b724f5e2b52ba705a9f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-07-14 23:56:01 +08:00
Alexandru Croitor
b5a0f88029 CMake: Fix IMPORTED_IMPLIB to be set for shared libraries on Windows
The correct variable to check is WIN32, not WINDOWS.

Amends 85e25d93b3

Pick-to: 6.2
Change-Id: I4570eb5a124bcaa0bd38135dd7c7f48345c40c9d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-07-14 17:14:24 +02:00
Alexey Edelev
0ae2537ad4 Use module interface name as OUTPUT_NAME
For internal modules we should keep the name of the file in file system
consistent with previous Qt versions.

Pick-to: 6.2
Fixes: QTBUG-95077
Change-Id: I02e4fced0fc3172e60f07bc7d1515e23744db567
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-13 20:15:14 +02:00
Joerg Bornemann
564f07086c Don't repeat conditions of use_*_linker features in QtFeature.cmake
qt_config_linker_supports() repeated the conditions of all use_*_linker
features, because the features are not evaluated yet when this function
is called, and the function needs to know what linker is used to build Qt.

Move the required tests and features before any
qt_config_linker_supports() call and evaluate the use_*_linker features
early.

Change-Id: I306f032356682a0e82e4d7c4234e5bbc820ab143
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-13 15:27:23 +02:00
Alexey Edelev
adfb767bcc Move the logic associated with platform definition directory
Since platform definition directory is used as an interface include
path of the Qt::Platform target, it makes sense to define it for this
target only. Also the definition of cached values that contain
path to platform definition looks redundand.

The definition of QT_PLATFORM_DEFINITION_DIR from command line
doesn't make any sense since build procedure doesn't take it into
account when installing mkspecs and the use if the user-provided
QT_PLATFORM_DEFINITION_DIR value as a Qt::Platform include directory
causes inconsistency in the prefixed builds. INSTALL_MKSPECSDIR
and QT_QMAKE_TARGET_MKSPEC should be used instead.

Change-Id: I3636c57b835cb84511a358a0910cc482c5fbd81e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-13 14:31:16 +02:00
Joerg Bornemann
8ac8d812f7 Warn on any PUBLIC usage requirements specified for Qt plugins
Repositories have been changed to be free of this warning. We're now
changing the default of QT_WARN_PLUGIN_PUBLIC_KEYWORDS to ON.

Set this variable to OFF to disable the warnings.

Pick-to: 6.2
Change-Id: Ie37a4df1032f5b1e9152d970e8a14c574ed70241
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-12 19:49:13 +02:00
Alexandru Croitor
451733bd57 CMake: Fix reconfiguration error when features have EMIT_IF conditions
Previously, if a feature was marked as not to be emitted and there was
no user provided value for that feature, the build system would still
save the user provided value in FEATURE_foo with a value of ON (if the
conditions were met).

After a reconfiguration, the build system would hit the code path that
checks if the user provided a value for the non-emitted feature, and
would then warn about it and reset the feature value to OFF.

This would cause errors when reconfiguring a user project, complaining
that a feature value has changed.

Make sure to not save the user provided value for a non-emitted
feature and to always set its internal feature value to OFF.

Amends c4f5762b20

Pick-to: 6.2
Fixes: QTBUG-94921
Change-Id: I257c7fd795c8a6aeba3348cb72522e4f0b006dc9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-07-09 12:44:35 +02:00
Alexandru Croitor
cde126ef26 CMake: Rename and document the feature evaluation functions
Rename various functions and variables to hopefully make the behavior
of feature evaluation clearer.

The previous names like 'set_value' or 'set_cache_value' or 'cache'
were too generic and unclear. One would have to carefully read the
code to understand what was actually set.

Add some doc comments about what FEATURE_foo and QT_FEATURE_foo
represent.

Amends c4f5762b20

Pick-to: 6.2
Task-number: QTBUG-94921
Change-Id: Ie6a7b83a4d54a83976b2706d4af82b39832d79f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-07-09 12:44:35 +02:00
Alexandru Croitor
51ae235080 CMake: Use correct MSVC runtime library for Qt object libraries
If Qt was configured with -static-runtime which implies MultiThreaded
-MT flag, the plugin initializer object libraries were still compiled
with the default -MD flag.

When an application linked to Qt, that caused linking to fail with
mismatched symbol errors between the application symbols and the
plugin initializer object library symbols.

Make sure to set the MSVC_RUNTIME_LIBRARY property on both plugin
initializer and resource object libraries, depending on the value of
QT_FEATURE_static_runtime.

We did set the property for resources added by
qt_internal_add_resource, but not for the resource created by
the public qt6_add_resources counterpart.

Pick-to: 6.2
Fixes: QTBUG-95043
Change-Id: Ia543cd0241db94a12080be2655ad420fe9ad3f24
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-07-09 12:44:35 +02:00
Alexandru Croitor
7b3d9efc04 CMake: Place internal apps in the correct output directory
In a -debug-and-release build, apps were placed under bin/Release
rather than just bin.

Apply the logic we use for tools for apps as well. Rename and move
the common functions into QtTargetHelpers.cmake.

Pick-to: 6.2
Fixes: QTBUG-95028
Change-Id: I5a9082ea50c9238c8fcf0c6dd099708fbc571bf8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-07-09 09:44:58 +02:00
Alexey Edelev
f33d11796f Hide QT_USE_BUNDLED_ CACHE variables from GUI
Make QT_USE_BUNDLED_ INTERNAL to hide them from GUI like QtCreator's
CMake configurator.

Pick-to: 6.1 6.2
Change-Id: Id9dcee31c69b579bbe38611cabb98e46550b0e89
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-08 23:38:25 +02:00
Alexey Edelev
b2649754f1 Make QT_HAVE_LINK_ORDER_MATTERS INTERNAL to hide from GUI
Hide QT_HAVE_LINK_ORDER_MATTERS from GUI like QtCreator's CMake
configurator.

Pick-to: 6.1 6.2
Change-Id: I9591092f0902ad17ff260a1ca4494239a7acf6fa
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-08 23:38:25 +02:00
Joerg Bornemann
85e25d93b3 CMake: Set IMPORTED_{SONAME|IMPLIB} for shared libs only
In our *AdditionalTargetInfo.cmake we now set above target properties
for shared libs only, not executables.

IMPORTED_IMPLIB is only set for Windows.
IMPORTED_SONAME is only set for non-Windows platforms.

Pick-to: 6.2
Change-Id: If7f01e6bf5183cca0ac90f9afffd57c41b34dccd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-08 16:40:35 +02:00