Commit Graph

1633 Commits

Author SHA1 Message Date
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
Joerg Bornemann
7540b4bd56 Fix build of Debug projects against debug-and-release non-prefix Qt
Building a CMake project with CMAKE_BUILD_CONFIG=Debug was broken for
non-prefix debug-and-release builds of Qt.

In debug-and-release builds we set EXCLUDE_FROM_ALL on tools in the
Debug configuration. In non-prefix builds we export(EXPORT) targets, and
that also contains the non-existent Debug variants of the tools.  In
prefix builds, we install(EXPORT) instead, which only exports what is
built and installed.

Consequently, we now remove the DEBUG-related import information if the
debug variant if the target binary does not exist.

Pick-to: 6.2
Fixes: QTBUG-95027
Change-Id: I37766d5ab1e2795bcb91a348e7e72150e8a00f82
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-08 16:40:35 +02:00
Andreas Buhr
3818046204 fix warning in cborparser with gcc 11.1
Pick-to: 6.2
Change-Id: Ie8270f2b156b194dedd115a97b93f7f800af055e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-07-07 22:07:13 +02:00
Alexey Edelev
9bbca531eb Fix platform definition directory in top-level build
QT_BUILD_DIR should be used instead of CMAKE_BINARY_DIR as a base
directory for platform definition when building a non-prefixed
build since artifacts are copied to qtbase directory for top-level
build.

Amends 478f5fcde6

Pick-to: 6.1 6.2
Task-number: QTBUG-94973
Change-Id: I5cce16fdc7f760b954222ae67a4b85d4beea7f13
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-07 17:07:15 +02:00
Craig Scott
9e05e25acf CMake: Fix typo in function name
Pick-to: 6.2
Change-Id: I72ab657670ca6fa460b3495f85d6edd920ee2c8a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-07 17:40:45 +10:00
Joerg Bornemann
46d2ba1ea4 Restore default installation prefix from Qt 5
Change the default installation prefix to C:/Qt/Qt-${version} on Windows
and /usr/local/Qt-${version} elsewhere.

This is what's expected by users coming from Qt5, and setting the
installation prefix to "/usr/local" manually is easier than setting the
versioned variant "/usr/local/Qt-6.2.0".

[ChangeLog][Build System] The installation prefix now defaults to
/usr/local/Qt-${version} and C:/Qt/Qt-${version} like it did in Qt 5.

Fixes: QTBUG-91632
Pick-to: 6.2
Change-Id: I8ce57b1b18084c705b194c776e038cc807a6ed5e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-06 16:52:58 +02:00
Joerg Bornemann
d9a9eca54d Remove unsupported host-related configure options
The following host-related configure options were unsupported since Qt
6.0 and are now completely removed:
-hostprefix
-external-hostbindir
-host*dir (except -hostdatadir)
-android-ndk-host

Pick-to: 6.2
Change-Id: Ib69d90c40ef546f61bf87b1f443eb9d10f7a5a21
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-06 08:53:52 +02:00
Joerg Bornemann
16e869bd01 Remove outdated information from configure-cmake-mapping.md
Pick-to: 6.2
Change-Id: I5101a3d7d07e4c0e818fb005707d99c6afe8f589
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-06 08:53:44 +02:00
Alexey Edelev
478f5fcde6 Fix the detection of platform definitions directory
Platform definition directory is defined when building qtbase.
Depending on the build type (prefixed/non-prefixed) it should point:
  - To the source directory when building prefixed qtbase.
  - To the installation directory of the prefixed qtbase when building
consumer projects.
  - To the build directory of non-prefixed qtbase when building
non-prefixed qtbase or consumer projects.

TODO: It is desirable to move the logic asssociated with Qt platform
definition to the qt_internal_setup_public_platform_target function.

Pick-to: 6.1 6.2
Fixes: QTBUG-94973
Change-Id: I8530613f9b2029834c66206bbdf02475528a4640
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-05 22:00:01 +02:00
Joerg Bornemann
6fec7eae31 Make Android detection more robust
Our only way to detect whether the user requests an Android build of Qt
was to peek into the CMake toolchain file if it is specified.  If the
toolchain file contains a certain magic string, we decide that we're
building for Android.

This approach is fragile and bound to break should the Android toolchain
file's magic string ever change.

Now, we assume an Android build if any of our ANDROID_* cache variables
is set. In that case, we do not peek into the toolchain file.

Pick-to: 6.2
Fixes: QTBUG-94955
Change-Id: Ie2f0ac0963f90f09805e311111bb6912d4325ada
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-05 17:11:22 +02:00
Joerg Bornemann
5bd7952e96 Fix typo in function name qt_auto_detect_vcpkg
Pick-to: 6.2
Change-Id: Ie0fd74a9e1faf8dc55faac1940d100af72cf8030
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-02 18:22:16 +02:00
Alexey Edelev
e80b010795 Use target_link_options to propagate object libraries
target_link_options are placed by CMake at the beginning of a linker
line. This gives us an opportunity to use the function to propagate
object libraries. This change adds one more check in the root
Config.cmake file. If CMP0099 policy is enabled, CMake enables
propagating of the linking options when linking two static libraries
using the PRIVATE linking visibility, so we can rely on the correct
linking order and expect object libraries to be propagated.

Note that on the platforms where cmake version is higher than 3.16
Qt uses CMP0099 NEW in functions like qt_add_executable. This means
that at the moment of creating an executable target the TARGET_POLICY
genex will also be NEW, so we do not take into the account the user
defined CMP0099.

If the CMP0099 policy is not available for a certain CMake version
we skip the TARGET_POLICY check and simply disable propagation of
the object libraries using target_link_options for both user and Qt
libraries. This is applicable for the CMake versions 3.16 and less.

Linking approaches have the following priorities(from higher to lower)
after this change:
  - target_link_libraries - works if link order matters not or CMake
    version greater equal 3.21.
  - target_link_options - works if CMP0099 is set to NEW by user or
    if the CMake version is greater than or equal to 3.17 and an
    executable is created using Qt functions.
  - object library finalizer - works if CMake version is greater equal
    3.19 or qt6_finalize_target is called explicitly.
  - target_sources - is used when all the other approaches could not
    be used.

Amends a1fd4f51ad
Amends 3329212815

Pick-to: 6.2
Change-Id: I14f88caeb04e357191c840abeab89b03e210b796
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-02 15:17:06 +02:00
Joerg Bornemann
c72b7b8e5e Revert "Make toolchain inspection more robust"
This reverts commit 7c62caa355.

Certain toolchain files cannot be read in CMake script mode with CMake
versions >= 3.20.

For example, the vcpkg toolchain file overrides add_executable, and
that fails with CMake 3.20:
CMake Error at D:/dev_tools/vcpkg/scripts/buildsystems/vcpkg.cmake:662 (function):
 Built-in flow control command "add_executable" cannot be overridden.

Pick-to: 6.2
Fixes: QTBUG-93627
Change-Id: Ib6e6352dff50b9684dcf81401d138e27e16292c3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-02 15:05:32 +02:00
Alexandru Croitor
bb25536a3d CMake: Fix Vulkan to be found when targeting Android
Introduce two new packages WrapVulkanHeaders and WrapVulkan similar to
the OpenSSL wrapper packages.

WrapVulkanHeaders uses FindVulkan and is marked as found if Vulkan
headers are found (that's the only part the Qt build requires).

The WrapVulkan package is currently not used, but is there for
symmetry.

The Vulkan feature is now disabled by default on QNX, because the
QNX toolchain file in the CI does not set
CMAKE_FIND_ROOT_PATH_MODE-like variables and CMake ends up finding
host Vulkan headers causing the build to break.

Pick-to: 6.2
Fixes: QTBUG-92157
Change-Id: I05309821f866456cd42e7f85bf8b76ba099df656
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-01 18:57:50 +02:00
Alexandru Croitor
6d59e1e088 CMake: Be more explicit about found OpenSSL variables
Specifying the variables as required variable will show the found
paths in the configure output.

Pick-to: 6.2
Task-number: QTBUG-94355
Change-Id: I985a3585f37b38e25b6be4fae5d42c82e06517de
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-07-01 18:57:22 +02:00
Alexandru Croitor
82063d9af1 CMake: Pierce through LINK_ONLY deps in finalizer dep traversal
Ensure that the finalizer approach of
__qt_internal_propagate_object_library considers $<LINK_ONLY:>
libraries when traversing the dependencies of a target.

The issue was discovered when using the Quick.Shapes QML module in a
static build. The module has both a backing library and a plugin.
The backing library has some resource objects associated with it.
When the targets are exported, the plugin INTERFACE_LINK_LIBRARIES
has a $<LINK_ONLY:QuickShapes> dependency.

This ensures that the library will be linked, but depending on which
linking approach in __qt_internal_propagate_object_library is used,
the resources might not be linked to the final executable.

The resources are linked correctly when using the
target_link_libraries approach, but not when using the finalizer or
target_sources approach.

This change fixes the finalizer approach, but the target_sources
approach is still broken.

Amends a1fd4f51ad

Pick-to: 6.2
Change-Id: Ifbb91a17d388c3dc4263e17ec0d3bd5627b57cb4
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-29 17:03:28 +02:00
Alexey Edelev
dec84a56f5 Throw FATAL_ERROR if specified platform doesn't exist
If user specifies non-existing platform build fails in some non-obvious
place, since qplatfromdefs.h couldn't be found.

Add an explicit error if the defined platform folder doesn't exists in
Qt sources.

Change-Id: Id847d57a6f9cc4f463e697b474b8a669cd041fb8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-25 13:32:26 +02:00
Alexandru Croitor
e2c6f2ba7e CMake: Fix 'Cannot find source file' error with older CMakes
Configuring a static qtdeclarative with CMake versions older than
3.18.0 fails at generation phase with

CMake Error at cmake/QtExecutableHelpers.cmake:28 (add_executable):
  Cannot find source file:

   some_path/some_target_plugin_imports_Gui.cpp

Marking the generated file as GENERATED explicitly solves the issue.

Pick-to: 6.1 6.2
Change-Id: Ife0eba61a1aab4f988d9fe7e2217d30eb96774a7
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-25 12:33:58 +02:00
Alexandru Croitor
1981682687 CMake: Propagate sanitizer flags to public projects
Ensure that Qt user projects build with sanitizer flags if Qt was
configured with any of the sanitizers enabled.

To compile Qt with sanitizer support enable any of Qt sanitizer
features.

Passing -DECM_ENABLE_SANITIZERS=address to CMake is NOT supported
anymore.

When configuring Qt using CMake directly, pass
    -DFEATURE_sanitizer_address=ON
    -DFEATURE_sanitizer_undefined=ON
instead of
    -DECM_ENABLE_SANITIZERS=address;undefined

When configuring Qt with the configure script pass
    -sanitize address -sanitize undefined
as usual.

QtConfig.cmake now records the sanitizer options that should be
enabled for all consuming projects based on the enabled Qt features.
This applies to internal Qt builds as well as well as tests an
examples.

The recorded sanitizer options are assigned to the ECM_ENABLE_SANITIZERS
variable in the directory scope where find_package(Qt6) is called.
The ECMEnableSanitizers module is included to add the necessary flags to
all targets in that directory scope or its children.

This behavior can be opted out by setting the
QT_NO_ADD_SANITIZER_OPTIONS variable in projects that use Qt and might
be handling sanitizer options differently.

Amends 7e03bc39b8

Pick-to: 6.2
Fixes: QTBUG-87989
Task-number: QTBUG-92083
Change-Id: I2e3371147277bdf8f55a39abaa34478dea4853a6
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-06-25 12:33:58 +02:00
Alexandru Croitor
9a9da3aad2 CMake: Handle fuzzer-no-link sanitizer feature name correctly
Pick-to: 6.2
Task-number: QTBUG-87989
Change-Id: Ife42f1fe001c5fafd10981f23dcd387cacc15276
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-25 12:33:58 +02:00
Alexandru Croitor
8c1a35a991 CMake: Restore Qt-custom sanitizer additions to ECMEnableSanitizers
Restores addition of 'float-divide-by-zero' to undefined sanitizer
flags as well as the custom fuzzer-no-link option.

Pick-to: 6.2
Task-number: QTBUG-87989
Change-Id: Icde1e5d31083ce1b6128ab45b0e9df5ae69736a3
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-25 12:33:58 +02:00
Alexandru Croitor
6b3e512e02 CMake: Update ECM sanitizer module to latest version
To bring support for sanitizers when using MSVC.

Pick-to: 6.2
Task-number: QTBUG-87989
Change-Id: I7a8ebf8fdaa31669df82d232fd9eae4e72407b92
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-25 12:33:58 +02:00
Alexey Edelev
9bd418aeab Implement generating of a module cpp export header
Add an option that automatically generates an export header for a Qt
module. The header contains only Q_DECL_EXPORT/Q_DECL_IMPORT related
content, so it's not a full replacement of 'global' header files.

Task-number: QTBUG-90492
Change-Id: I250d1201b11d4096b7e78e61cbf4565945fe6517
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-24 20:40:49 +02:00
Alexey Edelev
1cb63fcc97 Disable forced full optimization if QT_USE_DEFAULT_CMAKE_OPTIMIZATION_FLAGS=ON
Pick-to: 6.2
Task-number: QTBUG-94753
Change-Id: Ib9dda1a96f3123394e3b3d4f84feac8cedd18b89
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-24 18:10:32 +02:00
Joerg Bornemann
d6e01ae05c Fix QT_HOST_DATA for builds setting INSTALL_MKSPECSDIR
In a Qt build that was configured with INSTALL_MKSPECSDIR set to
something different than INSTALL_DATADIR, the qmake property
QT_HOST_DATA was wrong. Consequently, mkspecs could not be loaded,
rendering qmake dysfunctional.

The reason was that we considered every QT_HOST_xxx property to have the
same value as QT_INSTALL_xxx in a non-cross build.
This is not true for QT_HOST_DATA, because users might want to set
INSTALL_DATADIR to "foo" but INSTALL_MKSPECSDIR to "bar/mkspecs".

Move the unused determination of the host data dir to the QtLibraryInfo
lib and handle QT_HOST_DATA specially.

Fixes: QTBUG-94591
Pick-to: 6.2
Change-Id: I2c44cda8405ff1d14391254fcd1d9b1361cb5855
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-23 22:12:41 +02:00
Kai Köhne
d0676874d6 MSVC: Enable warnings-are-errors for latest Visual Studio 2019
Also remove handling of older versions, because we only support
Visual Studio 2019 currently

Pick-to: 6.2
Change-Id: If66a46d970047fe25582e323df74e0a904ee92da
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-06-23 12:49:19 +02:00
Morten Sørvig
53eb44906c wasm: don’t set exit_runtime
Go with Emscripten’s default of not shutting down on
main() exit; this allows for writing main() in such
a way that avoids the exec() workaround.

Existing main() implementations (which do use the exec()
workaround) do not shut down Qt cleanly anyway, so we
gain little by shutting down the Emscripten runtime.

Applications can set this flag if they do want to shut
down on main() exit:
    LFAGS += -s EXIT_RUNTIME=1

Change-Id: I52e1cc2bc907d1d2146822713e39b7610db3f95b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-06-23 06:57:21 +00:00
Giuseppe D'Angelo
648e9696d3 Disable -Werror=stringop-overflow on GCC >= 10
There's a number of upstream bugs that cause false positives;
do not make them errors.

Change-Id: I4151794d8d37177a47a34aef8d83accf4377d44a
Pick-to: 6.1 6.2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-06-23 00:23:55 +02:00
Morten Sørvig
7ee4468a18 wasm: enable MODULARIZE option and set EXPORT_NAME
Make Emscripten generate a global constructor function
("createQtAppInstance()") instead of a global javascript
module object.

This enables more fine-grained control over module
instantiation; previously the module object would be
created when the runtime javascript was evaluated, and
the number of emscripten module/instances was limited
to one per page.

Set EXPORT_NAME to “createQtAppInstance” which avoids
collisions with other non-Qt Emscripten modules on
the same page. A further improvement would be to include
the app name in EXPORT_NAME, but this is not done at
this time.

Update the code in qtloader.js to call the constructor
function instead of working on a global module object.
The qtloader.js API is functional before the wasm and
Emscripten modules have been instantiated; store properties
and forward to the Emscripten module when it's created.

Change-Id: I12c49a5b9a4a932bbc46fcc5e5ecc453fd0fe7f0
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-06-22 11:11:20 +00:00
Lorn Potter
ae717aa51f wasm: fix build for emscripten 2.0.14
new syntax rules for EXTRA_EXPORTED_RUNTIME_METHODS valid after 2.0.16

Pick-to: 6.2
Change-Id: Iff33e4c6f3176619fb35ec0994a7cc87b5d937c7
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-06-21 23:43:02 +00:00
Alexey Edelev
991b64a7e5 Cleanup temporary code related to internal modules
Remove the temprotary 'Private' targets of the iternal modules.

Pick-to: 6.2
Task-number: QTBUG-87775
Change-Id: I9a2c7c8c2f63602476fd935b11dab7a835864537
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-21 21:25:00 +02:00
Alexandru Croitor
f567f429bd CMake: Update section on required CMake versions
Change-Id: I6c556cd3a2e8bdf87b3c7c6ef62a6af6bdbe7137
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-21 12:48:12 +02:00
Alexey Edelev
ff4244b540 Move dependency lookup functionality to the common macro
Dependency lookup mechanism is the same for modules and plugins. It
makes sense to wrap it using macro.

Pick-to: 6.2
Change-Id: I73727743b0f5f40b2d94624f65ebfcf85e8dcc59
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-19 14:04:37 +02:00
Alexey Edelev
cdbb390c4a Disable finalizers by default for the non-ld linkers
Check if link order matters before use the object library finalizer.

Amends 5fb99e3860

Pick-to: 6.2
Change-Id: Ie996bc175ebea36ccda1bb2fe388ae3b7fcde395
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-19 11:06:04 +02:00
Alexey Edelev
ed92cb30e4 Fix the naming of the config header files for private modules
Perform a file name of the config header before adding a '_private'
suffix.

TODO: It makes sense to revisit the use of the CONFIG_MODULE_NAME
variable since the variable is used for different purposes and
mutate with use.

Amends 8aee7c6b29

Pick-to: 6.2
Fixes: QTBUG-94568
Change-Id: Id5aaf8d423ec8b94afffe4641b54dab94b5453fb
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-18 22:18:25 +00:00
Alexey Edelev
3329212815 Move the linking logic of the object libraries to a common function
The linking logic of object libraries should be reusable outside of the
resource context. This introduces a
__qt_internal_propagate_object_library function that prepares all the
necessary genexes to link and propagate the object library to the
end-point executable.

Rename resource object finalizer API to make the naming more generic
to object libraries of any kind.

Amends 5fb99e3860

Pick-to: 6.2
Task-number: QTBUG-93002
Task-number: QTBUG-94528
Change-Id: I69d0f34c0dadbd67232de91035aaa53af93d1fa1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-18 23:18:26 +02:00
Mårten Nordheim
bccfb92507 CMake: output VCPKG_CHAINLOAD_TOOLCHAIN_FILE with cmake paths
Change-Id: Ibde8890c30b9024aca589e892590d071b547c361
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-18 21:15:05 +02:00
Alexey Edelev
29789ff0ea Use target OUTPUT_NAME as a module identifier in .pri files
QtPriHelpers copies the logic related to the module OUTPUT_NAME to
produce a module identifier. Since the module identifier should be
equal to OUTPUT_NAME it makes sense to reuse the property and
deduplicate logic.

Amends 8aee7c6b29

Pick-to: 6.2
Fixes: QTBUG-94568
Change-Id: I8d9c04273e4cdb1a2e6a3b0db3ddf52e008c0cf7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-18 15:14:02 +02:00
Giuseppe D'Angelo
f29ff5dffb Add GCC 11 and C++20 workarounds
GCC 11.1 has a bug [1] in the preprocessor that leads to
-Wsuggest-override warnings being raised in random places, even under
pragmas that are supposed to suppress it. For some reason, NOT using the
integrated preprocessor fixes it, so add that flag as a workaround.

Also, GCC 11 introduces a family of warnings for C++20's deprecations of
mixed enum arithmetic, which we use all over the place. Avoid a hard
error for those warnings.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100796

Change-Id: I3b2aefa385f191f207e7eb876bc1ed0b18fb342b
Pick-to: 6.1 6.2
Task-number: QTBUG-93360
Task-number: QTBUG-94059
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-06-18 15:14:02 +02:00
Alexandru Croitor
b6c5e06676 CMake: Handle OPTIONAL_COMPONENTS in qt_find_package
The optional components arguments were not handled before which
caused the recorded package information for static builds to be
incorrect, it only recorded the package name without the component.

Remove REQUIRED_COMPONENTS TODO, there is no such find_package option,
it's already handled by the regular COMPONENTS code path.

Amends 07b6d3367d

Pick-to: 6.1 6.2
Fixes: QTBUG-94501
Change-Id: Ib48a7befcb70e20c3f21315897d51d3064b48134
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-17 23:28:18 +02:00
Alexey Edelev
8aee7c6b29 Fix internal module naming in qmake .pri files
Set the correct value to the _qt_config_module_name property at the
internal module creating step instead of appending _private suffix when
generating .pri files.

Amends 425ff34aa1

Pick-to: 6.2
Fixes: QTBUG-94568
Change-Id: I6fa8089358bc638668e313c98c3aee680bf7ec2a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-17 19:32:56 +02:00
Alexandru Croitor
5ec937115b CMake: Export info if an object lib target is a plugin initializer
Needed for qtdeclarative so we can filter out which object library
should go into which export set, because qt_internal_add_qml_module
can create both a backing library export set and a plugin export set.
The plugin initializer object lib should go to the plugin export set.

Pick-to: 6.2
Task-number: QTBUG-92933
Change-Id: I0fce131eff75a0b3090ac0fbb2a12ecfcba5e38d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-17 18:56:12 +02:00
Alexandru Croitor
a37957df5c CMake: Add TODO to apply generalized object library linking approach
Pick-to: 6.2
Change-Id: I1ea368e81d8b055ef353a0f021f188b45588c937
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-17 18:56:12 +02:00
Alexandru Croitor
602d26c38f CMake: Set the plugin class name for qml plugins
This is needed for a change in qtdeclarative to allow building the
Q_IMPORT_PLUGIN-containing object library initializer of a qml plugin.

Show an error if the qml plugin has no class name, it's needed for
plugin initialization so it's mandatory to have a class name.

Show an error if a class name is not found when computing the import
macro for a plugin (both for a regular qt plugin and a qml plugin).

When querying for the class name of a target, query both a Qt6::
prefixed target as well as a non-prefixed one, with the Qt one
taking precedence.
This is to allow querying the class name of user project created qml
plugins.

Currently regular qt user plugins don't use the object library
initializer approach. This will likely be revisited in the future.

Pick-to: 6.2
Task-number: QTBUG-92933
Change-Id: I46417471a7d8b49651e6821f7b28e7a9d44c2557
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-17 18:56:12 +02:00
Alexandru Croitor
103c1bc7ba CMake: Don't generate .pri files for qml plugins
We didn't do it in Qt 5 times and it was accidentally done for Qt 6.

There's no reason to generate them, the .pri files are only meant to
be used for regular plugins so a project can do QTPLUGINS += foo.

That mechanism is not needed for qml plugins which use
qmlimportscanner instead.

Furthermore the pri contents didn't contain a class name, so they
couldn't be used anyway.

Pick-to: 6.2
Change-Id: I6299fda21ece0f693a817ab558b45aa46b97e5ee
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-17 18:56:12 +02:00
Alexey Edelev
13a4de6bf6 Remove target specific flags from the linker capabilities check
Remove target specific flags from static_link_order.
Move the check to the common config.tests folder.

Amends 5fb99e3860

Pick-to: 6.2
Task-number: QTBUG-93002
Task-number: QTBUG-94528
Change-Id: I1368075ec6bd1e743b2b89fd93143df38a278ec2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-16 21:56:09 +02:00
Alexandru Croitor
335123f240 CMake: Don't make example external projects depend on tests
Only depend on the ${project}_src and ${project}_tools targets.

This might exclude some non-obivous target dependencies, but we can
adjust that if needed.

This reduces the build.ninja file of qtbase + qtsvg form 341MB
to 41MB when configuring with tests and examples, as well as reduces
the processing time of calling ninja.

Amends d97fd7af2b

Pick-to: 6.2
Change-Id: I2860d8ae89728f33f6b73fede1335cd6d6290f78
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-06-16 20:01:30 +02:00
Alexey Edelev
5fb99e3860 Check the impact of static link order for user projects
For user projects we run the static link order check once
'find_package(Qt6 ...)' is called.

If linker can resolve circular dependencies between static libraries
and object files we set the _qt_link_order_matters property of the
Qt::Platform target. This indicates the use of finalizers is not
required and we may rely on CMake-base propagation of resource
libraries and resource object files.

If linker could not resolve circular dependencies depending on
the _qt_resource_objects_finalizer_mode value:
  - Finalizer will be called and collected resource objects will be
    linked to the target directly.
  - Finalizer will be omitted and resource objects will be linked
    using the target_sources function implicitly. This only
    propagates resource one level up if consumer links the static
    library PUBLICly, but all symbols will be resolved correctly
    since object files are placed in the beginning of the linker line.

In the CMake version 3.21 we expect that CMake will take care about
the order of the resource object files in a linker line, it's
expected that all object files are located at the beginning of the
linker line.

TODO: Need to confirm that the CMake 3.21 meets the expectations.

Amends 4e901a2f99

Pick-to: 6.2
Task-number: QTBUG-93002
Task-number: QTBUG-94528
Change-Id: Ia68976df8182d3d3007b90c475c1e3928a305339
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-16 16:58:45 +02:00
Alexandru Croitor
7f0f44f014 CMake: Promote all targets to global within a scope when possible
CMake 3.21 introduced a new IMPORTED_TARGETS directory property which
we can use to promote all imported targets within a scope to be
global.

This would cover transitive non-Qt imported targets which the Qt build
system does not know about and is thus a more complete solution
compared to promoting only Qt targets.

Run a finalizer at the end of the directory scope where
find_package(Qt6) is called to promote all imported targets within
that scope to global (when requested).

The old promotion method is disabled when the CMake version is new
enough.

Pick-to: 6.2
Task-number: QTBUG-92878
Task-number: QTBUG-94528
Change-Id: I533a3bd4186eba652f878ddd72c76118c2fd8bae
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-16 13:22:17 +02:00
Alexandru Croitor
561fc8107f CMake: Allow promoting the Qt libraries to be global targets
User projects can set the QT_PROMOTE_TO_GLOBAL_TARGETS variable to
true so that the various imported targets created by find_package(Qt6)
are promoted to global targets.

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

E.g. it fixes errors like

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

    $<TARGET_OBJECTS:Qt6::Widgets_resources_1>

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

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

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

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

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

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

Pick-to: 6.2
Fixes: QTBUG-92878
Change-Id: Ic4ec03b0bc383d7e591a58c520c3974fbea746d2
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-16 13:22:17 +02:00
Allan Sandfeld Jensen
b62fcccb15 Detect win32-msvc target
Automatically set compilers based on old mkspec style target

Pick-to: 6.2
Change-Id: I80404376964a85c6b519657c054d008da47aed91
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-15 16:58:46 +02:00
Allan Sandfeld Jensen
127f658cc9 Fix the win32-clang-msvc target
Detect clang-cl mkspec target

Pick-to: 6.2
Change-Id: If0ca31ae2da3b44a4e2bd116933007139cc02fdc
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-15 16:58:46 +02:00
Alexey Edelev
02855ff6e0 Adjust the EntryPoint target name according to the internal module naming policy
Pick-to: 6.2
Task-number: QTBUG-87775
Change-Id: I1d6097c950f97e102c44e2952edc98caa4deb6c6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-15 12:51:49 +02:00
Alexandru Croitor
dab8f64b6d CMake: Be precise about EXTERNAL_BUILD check when building examples
This change allows temporarily removing the EXTERNAL_BUILD option in
a qt repo examples project to check how the examples behave in a
non-external project build, without forcing the developer to use a
prefix build.

Useful to compare behavior until we've ported over prefix builds to
use EXTERNAL_BUILD.

Amends d97fd7af2b

Change-Id: I29b834bb5f00e1e93966caae6f816faedba76b76
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-15 12:51:49 +02:00
Dominik Holland
f380c87731 CMake: Add public FindPackageHelpers
This makes qt_internal_disable_find_package_global_promotion available,
which is needed when linking against QtMultimedia in a static build

Pick-to: 6.2
Change-Id: I9b8f6d7b74a8693ac471f8a280e893f4da80a44b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-14 20:58:00 +02:00
Robert Griebl
6eea6e30c6 cmake: Allow tools to enable exceptions
Needed for the QtApplicationManager tools.

Pick-to: 6.2
Change-Id: I987b297406b6659d777ce5c00f9fc1b89ccc80ab
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-14 18:32:47 +00:00
Alexey Edelev
523ee5577a Replace flags with spaces when removing them
Removing flags based on REGEX may include spaces, so flags might be
glued. Replace flags with spaces to keep at least one space for
the described case.

Pick-to: 6.2 6.1
Fixes: QTBUG-94400
Change-Id: Ice268da36174ef5cf4398d2aee8fcd4731336316
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-12 00:30:23 +02:00
Alexey Edelev
fd5b92c2ba Fix internal module mappings of the qtdeclarative repo
Add 'Private' suffix to the internal module names in the mappings of
the qmake files for modules of the qtdeclarative repo.

Change-Id: I1592ebad0f0db553322ea766561b1b8c3fd38aea
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-11 15:34:38 +02:00
Alexey Edelev
4e901a2f99 Add the check for linker capabilities to resolve circular dependencies
'ld' only capable to resolve circular dependencies by wrapping the
suspected static libraries and objects using --start/end-group
arguments. We want to detect if linker is 'ld' at configure time to
decide how to link the resource objects if finalizers are not enabled.

The qt_config_compile_test function is extended with an extra argument
since it's required to pass custom cmake flags to the ld-related test.

Pick-to: 6.2
Change-Id: I484fcc99e2886952d8b0232f37e4e6a35d072931
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-10 15:17:55 +02:00
Alexandru Croitor
524b957d1f CMake: Fix global 'apk' target to apply to Qt EXTERNAL_BUILD examples
This means calling 'ninja apk' in a Qt build with examples configured
will build all example apks, regardless of whether the examples are
built as external projects or in-tree.

Fixes: QTBUG-94264
Change-Id: I5c7af0354858898a2e154a6d54fb025e4d81ff80
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-06-08 22:37:50 +02:00
Lorn Potter
1b4fe5d388 wasm: fix threaded builds
set the thread pool size default to 4

Change-Id: I038a81610c82ac4d162c044d0e1f58196cffc7b7
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-06-08 08:10:43 +10:00
Cristian Adam
20b3eb0fd8 CMake: Add support for building with clang-cl
qmake had support for building with clang-cl as the win32-clang-msvc mkspec.

Task-number: QTBUG-89642
Task-number: QTBUG-88081
Change-Id: I0709c289f90fedb121620d1e67ef841602219816
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-04 16:25:17 +02:00
Joerg Bornemann
6d82d0c532 Remove CMake compatibility functions for old API
All repositories define QT_NO_INTERNAL_COMPATIBILITY_FUNCTIONS by now,
and we can remove QtCompatibilityHelpers.cmake altogether.

Change-Id: I4d8104246e96a4514d5651c104607d651d208d95
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-04 14:27:20 +02:00
Niclas Rosenvik
7920c03ff1 Fix support for using system supplied md4c library
Add FindWrapSystemMd4c.cmake so that the old md4c target can be used
as well as the new one and set WrapSystemMd4c_FOUND.
Link to the imported target WrapSystemMd4c::WrapSystemMd4c if the
system library is used.
Add qt_find_package line to find the package in configure.cmake.
Fix the condition for enabling system-textmarkdownreader, it includes
testing for textmarkdownreader because even if the code would compile
correctly without it, it looks strange when the output says
"textmarkdownreader no" and under "using system libmd4c yes" even if
libmd4c is not used.
Use system include when system-markdownreader is enabled.
Add library mapping for libmd4c.

Change-Id: Id5d5b13d6691a8c1cdf627238887977c847c1e67
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-03 20:08:32 +02:00
Alexey Edelev
5cc3105807 Move resource object files to the beginning of linker line in .prl files
Move collected resource objects to the beginning of the linker line to
prevent order-related issues.

Fixes: QTBUG-92250
Change-Id: Ia046f2820feb693bfadc2b60e07fa001638d4d7b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-03 19:37:46 +02:00
Kai Köhne
f00c63093b Fix location of qtattributionsscanner in doc builds
qtattributionsscanner is now found in libexec.

Task-number: QTBUG-88791
Change-Id: Ie704663012be92b0c223d9d57210ec1874abff0b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-03 18:23:40 +02:00
Alexey Edelev
169a248fdf Make framework names consistent with the module names
For Apple's frameworks it's possible to include header files using the
following assumption:
If the framework name is "MyFramework" then
'#include <MyFramework/frameworkheader.h>' will work without specifying
the include path explicitly. This is broken for internal modules since
they use the framework name with the 'Private' suffix.

This uses the module name instead of the target name as a framework
name.

Amends edbe0eb335

Task-number: QTBUG-87775
Change-Id: I0592a28d0768724b6e10ca81aa7cefb0a3699a5e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-03 12:55:02 +02:00
Alexey Edelev
a25027eecb Collect resource objects of plugins and their dependencies in finalizer
Resource objects might be linked to plugins. Since some plugins may
be present in LINK_LIBRARIES as the complex genexes, need to collect
them explicitly and iterate over plugin targets to find resource object
libraries that need to be exposed to end-point target executable.

Amends a1fd4f51ad

Change-Id: Icd85f54f7bf9d1b7e3382caa5d9aa62449b6adb8
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-03 12:55:01 +02:00
Ulf Hermann
ee66bfba39 CMake: Explicitly generate static plugin helpers into binary dir
Before, it would erroneously look for them in the source directory.

Change-Id: I6dcd3ccde3e57dba84639da2cd354c51e8a92459
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-03 08:23:31 +02:00
Li Xinwei
2c49f85380 CMake: Fix generated prl and pri files for MSVC
In MSVC static build, if we build Qt with 3rdparty library (e.g. zstd),
cmake will add"zstd" (without "-l" prefix) to Qt6Core.prl. Then we
use this Qt to build a qmake project, compilation will fail due to
missing zstd.obj. Without "-l" prefix, qmake will treat "zstd" as an
object file instead of a library.

Library names in qt_module.pri and qt_lib_*_private.pri are also
missing "-l" prefix.

This is because on most compilers, CMAKE_LINK_LIBRARY_FLAG equals
"-l". But on MSVC, it is an empty string. So we should pass
"-DLINK_LIBRARY_FLAG=-l" for MSVC.

Also add "-L/path/to/library" if the library path is not in default
linker search directories. This will write un-relocatable paths to prl
files only when using 3rdparty libraries to build Qt statically. Usually
it's not a problem.

In addition, CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES is also empty on
MSVC. So The third argument of "$<FILTER>" is empty, it is an invalid
generator expression. This means no include dir will be written to
qt_module.pri and qt_lib_*_private.pri on MSVC. So only use "$<FILTER>"
when CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES is not empty.

Pick-to: 6.1
Change-Id: Ib66f95dc09cf920363a4b9338fb97747dd2f8ab7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-02 13:32:06 +08:00
Joerg Bornemann
253d97cce6 Fix EXTRA_CMAKE_FILES behavior of qt_internal_add_tool
...and make it consistent with that of qt_internal_add_module.

Make EXTRA_CMAKE_FILES a multi value keyword.
Do not add include statements for every file in EXTRA_CMAKE_FILES.
Add the EXTRA_CMAKE_INCLUDES argument to specify includes.

This enables us to specify EXTRA_CMAKE_FILE that are not included.

Change-Id: I1a3667473b94ee44363b554ab9e6c380e5c11389
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-01 23:52:50 +02:00
Joerg Bornemann
20feedac95 Pass OpenGL_GL_PREFERENCE variable to other Qt repos
When building Linux packages, we pass OpenGL_GL_PREFERENCE=LEGACY when
building qtbase. This is done to link against legacy OpenGL libs.

When building non-qtbase repos, we also need to set this variable to the
same value we have in qtbase.

Pick-to: 6.1
Task-number: QTBUG-89754
Fixes: QTBUG-94040
Change-Id: I567b629d245025d2b1544b91cfc265a9c921725f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-01 20:21:49 +02:00
Alexey Edelev
25888b068c Do not get LINK_LIBRARY of the interface libraries
Avoid getting the LINK_LIBRARY property of the interface libraries
when calling a resource object finalizer.

Amends a1fd4f51ad

Change-Id: I19d625a927c66994902f5c89e6c82183c94af91e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-01 20:21:49 +02:00
Alexandru Croitor
bc80067266 CMake: Create global imported versionless tool targets
Versioned tool targets are always promoted to global targets.
Versionless ones were not promoted to global targets.

This was an oversight which caused issues with conditions like
if(TARGET Qt::Tool) in top-level builds.

Fixes: QTBUG-93839
Change-Id: I5176899b5d0d80bfd0b350bc9c4b3fa5b53c0777
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-06-01 16:29:15 +02:00
Alexandru Croitor
42eb1e4aa6 CMake: Allow printing config summary even if module is not built
In the future it might be useful to print the config summary entries
of a Qt module configure.cmake file even if the associated module
is not built and thus qt_feature_module_begin is not called.

The repo src/CMakeLists.txt could then use a combination of
qt_feature_evaluate_features and a conditional
qt_feature_record_summary_entries to ensure the that summary entries
are still shown.

Change-Id: I124efc82163ddae48d9e72c70a677ec4c6588fac
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-01 02:49:41 +02:00
Alexey Edelev
4333bfd9d8 Move the framework related information to the common function
Since the information about framework is performed in multiple places
it's quite hard to control its consistency. This moves the obtaining
of framework related information to the common function and adjusts
the use of the information across the repo.

Change-Id: I1f488d41dcea75a1e8c361926792a6b7c45e5a3f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-31 20:50:07 +02:00
Alexey Edelev
a1fd4f51ad Rework resource finalizer approach
In the previous implementation of the resource object finalizer, we
used the name of the resource object library without namespaces when
recording it in the resource libraries list. This causes an issue when
we or users export resource targets.

This approach marks resource object libraries with the exporting
property instead of collecting resource targets when creating them.

Amends 19e789bace

Change-Id: I8596815921f2c681ddd78d9b2e9a4e1cafe5000b
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-31 20:50:07 +02:00
Alexey Edelev
19e789bace Implement propagation of object files to the end-point executable
This proposal collects all the resource objects to the qt-specific
property of the static libraries. This is done to avoid littering
of other static libraries and put resource object files to the
source part of the linker line when linking the end-point
executable.
The way we link object resource libraries is changed back to the
target_link_libraries approach as we may omit using finalizers
with linkers other than ld. Users may enforce finalizers by calling
the qt6_enable_resource_objects_finalizer_mode function if need.

Refactor tests related to the static resources.

Amends ddaa7150d8

Task-number: QTBUG-93002
Change-Id: I74135e291cd82fb54d1b284b4b4a1e002b1fef98
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-27 14:28:17 +02:00
Alexandru Croitor
a3c430f390 CMake: Revise plugin finalizer mode usage
Only use plugin finalizer mode if qt_finalize_target is called at the
end of the user project (which we can't really check, the user has to
ensure that) or when qt_finalize_target is automatically defer-called
by CMake 3.19+ (which is done by qt_add_executable).

This removes the previous behavior of using the finalizer mode if
qt_import_plugins is called. Instead the old regular mode is used
if the above preconditions are not met.

The removed behavior had ordering issues if qt_import_plugins was called
before target_link_libraries. The dependency walking would be done
before Qt dependencies were added and thus no plugins would be
linked.

Amends 6fcc272ac9

Task-number: QTBUG-80863
Task-number: QTBUG-92933
Task-number: QTBUG-94030
Change-Id: I78702b653a35596f5581c2f4282b2336f0124e60
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-05-27 14:28:17 +02:00
Lorn Potter
a1c8530a91 wasm: fix cmake syntax for emscripten
fix debugging demangler
Emscripten apparently does not like the quotes in the compiler argument

and remove array syntax

Change-Id: I66652f6bdc5872faf540a877ca01bf75dde47bbb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-05-27 21:16:49 +10:00
Alexey Edelev
edbe0eb335 Use the correct framework name when preparing the framework paths
Amends 425ff34aa1

Task-number: QTBUG-87775
Change-Id: Ic79e77255e1f3aec9748a6770838f9eeeae94d38
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-05-27 10:36:19 +00:00
Craig Scott
d97fd7af2b Build examples in isolated sub-builds using ExternalProject
Examples are intended to show how to build against an installed Qt.
Building them as part of the main build means the way the Qt targets
are defined and created are not representative of an end user's build.
By building them as separate projects using ExternalProject, we can
more closely replicate the intended audience's environment. This
should allow us to catch more problems earlier.

Having examples built as part of the main build also creates problems
with some static builds where a tool built by the main build is needed
during configure time. This happens with other repos like qtdeclarative
but not (currently) with qtbase. Converting the examples in qtbase to
be built using ExternalProject is intended as a demonstrator for how
other repos can do similar. Until other repos are converted, they will
continue to work as they did before, with examples as part of the main
build for non-static builds only.

The new build-externally behavior is only supported for non-prefix
builds with this change. Prefix builds will continue to use the old
non-external method. Support for building examples externally in
prefix builds will be a separate change.

Task-number: QTBUG-90820
Fixes: QTBUG-91068
Change-Id: I2304329940568dbdb7da18d54d5595ea7d8668bc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-26 13:33:29 +02:00
Alexandru Croitor
c3c8b7083a CMake: Remove some dead installation code
It was copy-pasted (presumably from plugin handling code)
when initially introduced but was never used.

Change-Id: I571738b9f5269ca038f5931a773aa5c2c66aafbc
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-05-25 22:36:56 +02:00
Alexandru Croitor
1bd408d6f7 CMake: Introduce a public qt_add_library function
Internally it uses a new _qt_internal_add_library function (similar
how we have qt_add_executable and _qt_internal_add_executable) as well
as finalizer code line the executable case.

_qt_internal_add_library forwards arguments to add_library with some
Qt specific adjustments to the selected default target type (based on
whether Qt is configured as static or shared).

The new _qt_internal_add_library is now used in qt_add_plugin as well
as some internal library creating functions like
qt_internal_add_module.

This reduces some duplication of file name adjustments across
functions and creates a central point for creation of Qt-like
libraries (for some definition of Qt-like).

Change-Id: Id9a31fe6bf278c8c3bb1e61e00a9febf7f1a2664
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-05-25 22:36:53 +02:00
Haoyu Liu
c3804ba061 CMake: fix CMake function qt_commandline_addString
1. a missing '}' breaks CMake
2. the variable "opt" should really be "arg", otherwise it'll be meaningless

Pick-to: 6.1
Change-Id: If29557998bf7aa786dc5c821e2c55f1195e7922b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-05-25 12:28:32 +00:00
Alexey Edelev
ffe5f92546 Add _qt_module_interface_name for 3rdparty libraries
Since we add 3rdparty libraries to the set of the Qt modules, they are
treated as the Qt modules by the depenedcy helper as well. So give them
_qt_module_interface_name to fix dependency helper.

Amends 425ff34aa1

Change-Id: I5898c1c90156de1878aeeef5a0924349b44c50fa
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-23 16:16:09 +02:00
Alexey Edelev
ecbf6c5b00 Add export of the Private targets for the internal modules
We need to export the Private targets of the internal modules to keep
compatibility with existing internal module users across repositories.

Amends 425ff34aa1

Fixes: QTBUG-93943
Change-Id: I10234cec1eb618b69d041f80fbe29620a4e307b9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-22 18:07:02 +02:00
Tor Arne Vestbø
f9c850cc42 qmake: Pick default architecture on macOS based on uname
When dealing with a universal build of Qt, we would end up
using the QT_ARCH as the architecture for user projects,
but this architecture is always the primary one that Qt
was configured with.

Instead of relying on QT_ARCH, we start writing QT_ARCHS
(plural) to qconfig.pri, based on CMAKE_OSX_ARCHITECTURES,
and then use that to initialize QMAKE_APPLE_DEVICE_ARCHS.

We then resolve the active arch using uname -m, matching
what CMake does.

We still feed all the available architectures to the
Makefile or Xcode project, so that the user can build
for any of the available architectures without needing
a reconfigure.

Fixes: QTBUG-93760
Change-Id: I0d338241ba4d944ca36d85371e9c4df7dbc4f269
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-21 17:45:28 +00:00
Alexey Edelev
715041b663 Enable UNICODE for all Qt targets and Qt consumers by default
After discussion we decided to opt-out the UNICODE definintion
behavior. To disable UNICODE in user projects the
qt6_disable_unicode_defines function could be used.

Amends 5b64e5950c

[ChangeLog][CMake] Enables the UNICODE and _UNICODE definitions on
WIN32 platforms by default for all cmake projects to reflect the
qmake behavior. Use qt6_disable_unicode_defines function to disable
the default unicode definitions.

Pick-to: 6.1
Fixes: QTBUG-93895
Change-Id: Id70ff7dcf8c74f660ec851f8b950e1e3b94d9fb4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-21 16:05:44 +02:00
Alexey Edelev
5b64e5950c Do not expose Qt internals by the HEADER_MODULEs
HEADER_MODULEs use the INTERFACE visibility to link libraries. This
causes a transitional propagating of the Qt-internal compile definitions
and options to the user targets.

This commit avoids an implicit adding of the Qt::PlatformModuleInternal
library to the HEADER_MODULEs and stops propagation of the Qt-internal
compile definitions and options. If module wants the transitional
propagation of some properties, this needs to be done explicitly.

Amends 8b7894cb63

Pick-to: 6.1
Fixes: QTBUG-89951
Change-Id: Ia9cecc38bac98eb5bc6e47d288308b49813ab5ac
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-20 20:31:05 +02:00
Alexey Edelev
425ff34aa1 Merge main and private targets of the internal modules
In cmake, targets are used as an entity for modules. This causes a
number of problems when we want to manipulate a module as a separate
entity with properties associated with it.
The _qt_internal_module_interface_name target property is introduced to
represent the module entity. All modules write a name to this property,
which will subsequently expand into the module name matched with
the module name in qmake.

The 'qt_internal_module_info' function is responsible for providing the
correct values ​​for the module properties used when working with a module
target.

Unlike qmake, for internal modules in cmake it is expected that the
Private suffix will be specified explicitly. In case the user wants to
have a different module name, an additional argument
MODULE_INTERFACE_NAME of the qt_internal_add_module function is
introduced.

This also changes the way how target dependencies are collected and
resolved. Since the 'Private' suffix no longer means an unique
identifier of the module 'Private' part, we look for the both Private
and non-Private package names when resolving dependencies.

TODO: This change doesn't affect the existing internal modules, so to
keep compatibility with the existing code the existing internal modules
create 'Private' aliases. The code that provides backward compatibility
must be removed once all internal modules will get the proper names.

Taks-number: QTBUG-87775
Change-Id: Ib4f28341506fb2e73eee960a709e24c42bbcd5ec
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-20 19:40:45 +02:00
Joerg Bornemann
4b09522c23 Add support for building and installing repo target sets
Introduce the concept of repository target sets, which is a named set of
targets within a Qt module repository.

In a Qt repository, a repo target set 'qtfoo' can be defined in the
top-level project file with
    qt_internal_define_repo_target_set(qtfoo DEPENDS Bar Baz)

The DEPENDS argument specifies Qt components that need to be
find_package'd when building the targets that belong to qtfoo.

In subdirectory project files, use
qt_internal_include_in_repo_target_set(qtfoo) to mark the file as
belonging to the repo target set.

To build and install a single repo target set, specify
QT_BUILD_SINGLE_REPO_TARGET_SET=qtfoo when configuring the Qt
repository.

Change-Id: Ic9e6213e3225988fd561f315bc857ee44ff17420
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-20 12:08:33 +02:00
Alexandru Croitor
6fcc272ac9 CMake: Introduce finalizer mode handling of static plugins
Allow linking all plugin initializer object libraries directly
into the final target (executable or shared library).

The finalizer mode is triggered when the project adds a call
to qt_import_plugins, as well when the project has an explicit
call to qt_finalize_executable or when it is defer called by
CMake 3.19+.

Otherwise the old non-finalizer mode is used, where each plugin
initializer object library is propagated via the usage
requirements of its associated module.

A user can explicitly opt in or out of the new mode by calling
qt_enable_import_plugins_finalizer_mode(target TRUE/FALSE)

The implementation, at configure time, recursively collects all
dependencies of the target to extract a list of used Qt modules.

From each module we extract its list of associated plugins and
their genex conditions. These genexes are used to conditionally
link the plugins and the initializers.

Renamed QT_PLUGINS property to _qt_plugins, so we can safely query the
property even on INTERFACE libraries with lower CMake versions.
QT_PLUGINS is kept for backwards compatibility with projects already
using it, but should be removed in Qt 7.

The upside of the finalizer mode is that it avoids creating link
cycles (e.g. Gui -> SvgPlugin -> Gui case) which causes CMake to
duplicate the library on the link line, slowing down link time as well
as possibly breaking link order dependencies.

The downside is that finalizer mode can't cope with generator
expressions at the moment. So if a Qt module target is wrapped in a
generator expression, it's plugins will not be detected and thus
linked.

Task-number: QTBUG-80863
Task-number: QTBUG-92933
Change-Id: Ic40c8ae5807a154ed18fcac18b25f00864c8f143
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-05-20 00:55:46 +02:00
Alexandru Croitor
91c65dd80c CMake: Build plugin initializers as object libs
Instead of compiling the plugin initializers as part of a user
project, pre-compile them as object libraries while building Qt.

The installed object libraries can then be used with

    target_sources(qt_module INTERFACE $<TARGET_OBJECTS:plugin_init>)

so that they are linked into the final executable or shared library
via qt module usage requirement propagation.

This reduces the build times of user projects.

The link line placement of the object files should be correct for all
linux-y linkers because the only dependency for the object files is
Core and the Gui -> plugin -> Gui -> Core cycle does not hamper that
from empirical observations.

As a consequence of the recent change not to link plugin initialization
object files into static libraries, as well not having to compile the
files in user projects, we can get rid of the
_qt_internal_disable_static_default_plugins calls in various places.

A side note.

Consider a user static library (L) that links to a Qt static library
(Gui) which provides plugins (platform plugins).

If there is an executable (E) that links to (L), with no direct
dependency to any other Qt module and the intention is that the
executable will automatically get the platform plugin linked,
then (L) needs to link PUBLIC-ly to (Gui) so that the plugin usage
requirements are propagated successfully.

This is a limitation of using

  target_sources(qt_module INTERFACE $<TARGET_OBJECTS:plugin_init>)

which will propagate object files across static libraries only if
qt_module is linked publicly.

One could try to use

  target_link_libraries(qt_module
                        INTERFACE $<TARGET_OBJECTS:plugin_init>)

which preserves the linker arguments across static libs even if
qt_module is linked privately, but unfortunately CMake will lose
dependency information on Core, which means the object files might be
placed in the wrong place on the link line.
As far as I know this is a limitation of CMake that can't be worked
around at the moment.

Note this behavior was present before this change as well.

Task-number: QTBUG-80863
Task-number: QTBUG-92933
Change-Id: Ia99e8aa3d32d6197cacd6162515ac808f2c6c53f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-05-18 22:03:46 +02:00
Tor Arne Vestbø
f2d26f95fe cmake: Add repository name to test labels for qt5 builds
Change-Id: Icb23f2ea885f6d21bef80c587a431f7e9349f21b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-18 21:07:51 +02:00
Craig Scott
21607d5db5 CMake: Provide supported qt_internal_add_module() args via a function
This is to allow other repos like qtdeclarative to more easily pass
through supported arguments to qt_internal_add_module() from their own
functions.

Task-number: QTBUG-88763
Change-Id: I965d593de4c6f9d5295a0d427c32dc3d5b1bb639
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-18 23:59:24 +10:00
Alexandru Croitor
5268edf581 CMake: Don't do plugin initialization for static libraries
Q_IMPORT_PLUGIN generates a global static symbol that initializes a
plugin. If this symbol is added to a static library and the library
is then linked to an executable, the linker decides that the symbol is
unused (because nothing references it) and discards it.

This means there's no point to compile the Q_IMPORT_PLUGIN containing
files into static libraries.

Change the generator expression we use for plugin propagation via
associated modules to not compile and link the plugin initialization
object file into a static library.

Pick-to: 6.1
Task-number: QTBUG-80863
Change-Id: Ide32c0124c1e313c352a72280ce32ce9fbe8fff1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-05-17 19:11:10 +02:00