Commit Graph

2186 Commits

Author SHA1 Message Date
Li Xinwei
9256d9e7b6 CMake: use correct link flag for MinGW(GCC) static-runtime build
When using MinGW compiler and Qt is configured with "-static-runtime",
we should pass "-static" to g++ while linking, like Qt 5, instead of
"-Wl,-Bstatic", to get rid of dependencies on libgcc_s_seh-1.dll,
libwinpthread-1.dll and libstdc++-6.dll.

Because syncqt doesn't link to any Qt library,
"target_link_options(${target} INTERFACE -static)" has no effect on it.
So we should use "PRIVATE" instead of "INTERFACE" for executables.

Pick-to: 6.6 6.5
Change-Id: Icf551783f92ef3615b3840c9af16d163eee09fdb
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-08-22 11:41:40 +08:00
Joerg Bornemann
e05b779c88 CMake: Don't create superfluous qtrepo_XXX_for_examples targets
Only create a qtrepo_src_for_examples target that examples, built as
external projects, can depend on.

Change-Id: I334bc67b9b78f49d5c345cb256132f42dc2c5f5e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-08-21 08:35:52 +02:00
Joerg Bornemann
ba96238600 Fix running CMake test projects in prefix builds
Consider the following situation: There are CMake tests in
qttools/tests/auto/cmake that configure and build CMake test projects,
essentially as external projects. One of those test projects does
find_package(Qt6 COMPONENTS LinguistTools). This call fails in a prefix
build, because Qt6LinguistToolsConfig.cmake is not installed yet. It
merely exists in qttools-build/lib/cmake/Qt6LinguistTools.

We must adjust CMAKE_PREFIX_PATH to be able to find Qt6LinguistTools. We
also must adjust QT_ADDITIONAL_PACKAGES_PREFIX_PATH to be able to find
the LinguistTools component of the Qt6 package.

Use the prefixes setup from the support for building examples as
external projects and use it for CMake test projects as well.

Task-number: QTBUG-84884
Change-Id: I1bd5d5084cf931196bdb014cd75ca7578cd9decb
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-08-19 11:03:36 +02:00
Marc Mutz
11d6932560 Mark all of Qt as free of Q_FOREACH, except where it isn't
The density of Q_FOREACH uses in this and some other modules is still
extremely high, too high for anyone to tackle in a short amount of
time. Even if they're not concentrated in just a few TUs, we need to
make progress on a global QT_NO_FOREACH default, so grab the nettle
and stick to our strategy:

Mark the whole of Qt with QT_NO_FOREACH, to prevent new uses from
creeping in, and whitelist the affected TUs by #undef'ing
QT_NO_FOREACH locally, at the top of each file. For TUs that are part
of a larger executable, this requires these files to be compiled
separately, so add them to NO_PCH_SOURCES (which implies
NO_UNITY_BUILD_SOURCES, too).

In tst_qglobal.cpp and tst_qcollections.cpp change the comment on the
#undef QT_NO_FOREACH to indicate that these actually test the macro.

Task-number: QTBUG-115839
Change-Id: Iecc444eb7d43d7e4d037f6e155abe0e14a00a5d6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-08-19 05:19:42 +00:00
Alexey Edelev
7544d91ae1 Use the relative header path when checking if it's 3rdparty
If source or build directry contain '3rdparty' in their path, all
header files are marked as 3rdparty and will never be installed.
This commit is CMake counterpart of
ea4a3d78a7

Amends ea4a3d78a7

Fixes: QTBUG-116137
Pick-to: 6.5 6.6
Change-Id: Ib93fb879867e3aeb6e44193c4253e73173c141d2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-08-17 13:09:46 +02:00
Fredrik Ålund
6e9f989eb6 Fix architecture selection for Mimer SQL client library
Case-insensitively match the architecture string for x86 and amd64.

Fixes: QTBUG-111219
Pick-to: 6.6
Change-Id: I775e81965f46bb7479e0e9a05e66b8a080656ee5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-16 17:04:40 +00:00
Alexandru Croitor
121f7f382b CMake: Allow installation of example sources into the Qt prefix
In Qt 5 times, if Qt was configured with -make examples, running
make install would not only build and install the example binaries,
but would also install the example sources into the prefix.
Installation of example sources was not implemented when the Qt 6
build system has switched to using CMake.

There is still a use case for it though, mainly for Qt Creator, which
only shows the examples of a Qt kit if the sources are available.

In contrast to Qt 5, in Qt 6 we will not install example sources
by default. It will be opt in.

To enable installation of examples sources, configure with

 configure -make examples -install-examples-sources

or

 cmake -DQT_BUILD_EXAMPLES=ON -DQT_INSTALL_EXAMPLES_SOURCES=ON

The -make examples part is required, otherwise
-install-examples-sources has no effect.

All example sources can be installed by calling
 cmake --install . --component examples_sources
in the qt repo build directory.

In a top-level build, per-repo installation can be done using
 cmake --install . --component examples_sources_<repo_name>
where repo_name could be 'qtbase'.

A single example's source can be installed by calling
 cmake --install . --component examples_sources_<subdir_name>
where subdir_name is the subdirectory name of the example, e.g.
'gallery'.

Implement installation of example sources by hooking into the
qt_internal_add_example command.
This means that all examples in all repos need to be added via
qt_internal_add_example instead of add_subdirectory, to ensure the
sources are installed. The majority of repos already use it.

For testing purposes one can configure with
-DQT_BUILD_EXAMPLES=ON -DQT_INSTALL_EXAMPLES_SOURCES=ON
-DQT_INTERNAL_NO_CONFIGURE_EXAMPLES=ON to allow testing installation
of examples sources without building them.

Take into account an additional variable called
QT_INTERNAL_EXAMPLES_SOURCES_INSTALL_PREFIX to allow installation of
example sources into a location different from the example binaries.

As a cleanup, the NAME option that could previously be passed to
qt_internal_add_example_external_project has been removed.
That's because it's never used anywhere and could not have worked
anyway because qt_internal_add_example_in_tree never handled it.

Pick-to: 6.6
Fixes: QTBUG-112135
Change-Id: I52aa5ec643ff7e212276c88d8dd2dfecdbdbeb0d
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-08-16 19:04:40 +02:00
Morten Sørvig
f7953cdee6 wasm: handle missing qconfig.h
There's no guarantee that qconfig.h will be present
when __qt_internal_get_qt_build_emsdk_version() is called
during configure, since the file is written by a file(GENERATE)
call which does not write the file immediately.

Handle this case and allow configure to complete.

Change-Id: Iab85790f9f133fd1ba5f276cdd7bc55f9af1d980
Pick-to: 6.6
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2023-08-16 08:42:32 +00:00
Alexey Edelev
139f3f61bd Do not override the generator type in configure script
If '-G<generator type>' is passed to configure script we should respect
this argument but not override it by the autodetected generator type.
'-cmake-generator' option will still have higher priority, but if
generator is set using CMake argument it will not be auto-detected by
other build config specific options, like '-debug-and-release'.

Change-Id: I75b49e33fa717f90bbd74045948fccb9f5350e8d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-08-14 10:00:05 +02:00
Alexey Edelev
d09a9f6de3 Use Release and Debug configuration for multi-config Qt builds by default
If user attempt to build Qt using multi-config generator set Release
and Debug configurations by default if they are not set, instead of
relying on what CMake suggests as default value for a platform.

Pick-to: 6.6
Change-Id: I4bdb33e56818984c189b737acccc9ac50659db96
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-08-11 11:11:49 +02:00
Alexey Edelev
ecda814b91 Allow disabling QT_USE_QSTRINGBUILDER definition for module targets
Currently QT_USE_QSTRINGBUILDER is added for all Qt module targets by
default, and it's not possible to remove this definition.
Replace this definition with the generator expression that is
propagated by the PlatformModuleInternal target.

Change-Id: I1c606e16809dc720e2eb72191e1670dfc48f1b48
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-08-09 15:53:08 +02:00
Alexey Edelev
d14f15f380 Allow disabling QT_USE_QSTRINGBUILDER definition for tool targets
Currently QT_USE_QSTRINGBUILDER is added for all Qt tool targets by
default, and it's not possible to remove this definition.
Replace this definition with the generator expression that is
propagated by the PlatformToolInternal target.

Change-Id: Iac3bd3ea76e7b439cf7957146b4b6dd20ecdbe3a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-08-09 15:53:07 +02:00
Alexey Edelev
a9e548963e Use QT_USE_QSTRINGBUILDER by default for all internal plugin targets
Change-Id: I24839d260dc6e3624bcedcdfe799871b239191f6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-08-08 09:47:33 +02:00
Marc Mutz
51b3269eef cmake helpers: support NO_PCH_SOURCES wherever NO_UNITY_BUILD_SOURCES are
The former implies the latter, so it makes little sense to treat them
differently. Even if some types of targets are (currently) never
compiled with PCH, users of qt_internal_all_x() shouldn't need to know
such details.

Pick-to: 6.6 6.5
Change-Id: I8ead238a8d9e55da632b2929638b67724a42d73c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-08-07 23:56:10 +02:00
Alexey Edelev
d7a3733056 Fix standalone headersclean_check targets
If module depends on some module Private part only the sync_headers
dependencies from this public part of this Private module is skipped.
Check if the module is Private and use the public module to read the
_qt_internal_sync_headers_target property.

Amends 0006a564c8

Fixes: QTBUG-115712
Pick-to: 6.6
Change-Id: I4678e2a6c9ec8f80862a97d48f0a3b4214ae2307
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-08-02 20:22:52 +02:00
Alexey Edelev
8c41125118 Allow using custom CMAKE_<CONFIG>_POSTFIX when building Qt
Do not override CMAKE_<CONFIG>_POSTFIX if it's specified by user.
Using custom CMAKE_<CONFIG>_POSTFIX can potentially break qmake,
since qmake relies on pre-defined postfixes that are set by Qt build
by default. Building Qt with CMAKE_<CONFIG>_POSTFIX different from
default one will now warn about potential issues. Assume that we
still doesn't support setting of CMAKE_<CONFIG>_POSTFIX, but also
don't force our default values.

Fixes: QTBUG-115045
Change-Id: I75a34913189eae77062afa10d384eccf4edfc849
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-08-02 14:47:15 +02:00
Michael Brüning
ebb361ee3f qt_enable_separate_debug_info: Enable custom location of dSYM directory
It is part of a solution to produce notarizable binaries for
application using Qt WebEngine.

Pick-to: 6.6 6.5
Task-number: QTBUG-99555
Change-Id: Ice0bbcfb12829906328f55158b0c37f03878f17c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-07-31 17:11:01 +02:00
Alexandru Croitor
8c912cddeb CMake: Make sure to follow BuildInternals CMAKE_BUILD_TYPE on Windows
A regression was introduced in
48841c34d2
when configuring qtshadertools with -prefix -debug and
no -developer-build.
qtbase would have been built as Debug, but qtshadertools as release.

This caused qsb.exe to link to a debug c++ runtime via QtCore, and a
release one via QtShaderTools libraries and thus cause heap corruption
crashes during runtime due to the mismatch.

This happened because the check in cmake/QtSetup.cmake thought Debug
was the default build type (nothing was specified on the command line)
without knowing it was explicitly set BuildInternals.

Set a variable when BuildInternals sets CMAKE_BUILD_TYPE and make
sure QtSetup does not override it then.

Augments 33af62db37
Amends 48841c34d2

Fixes: QTBUG-114958
Change-Id: I5e0a27b4d77512494c026dd911ec5757889a5a1a
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-07-26 15:51:04 +02:00
Assam Boudjelthia
abe7c77d6d COIN/Android: Move android_emulator_launcher.sh to qt5.git
The android emulator launcher script is mainly used in CI and thus
makes sense to be moved there. This also makes it easier to make changes
without having to wait for submodule updates.

ANDROID_EMULATOR_RUNNER is defined in qt5's Android provisioning script.

Also, change the order of instructions execution to set COIN_CTEST_RESULTSDIR
env variable before running the emulator script. That var points to the path
to where the emulator logs are saved.

Task-number: QTQAINFRA-5596
Change-Id: If6ac285fecdc49611c398e8185e6e3e6b9c353fb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-07-25 23:07:45 +03:00
Kai Köhne
892448b6e0 Make Qt headers work with MSVC /W4
This requires explicitly marking constexpr if conditions to fix C4127
issues:

  qtbase/src/corelib/text/qstringbuilder.h(112):
  error C2220: the following warning is treated as an error
  qtbase/src/corelib/text/qstringbuilder.h(112):
  warning C4127: conditional expression is constant
  qtbase/src/corelib/text/qstringbuilder.h(112):
  note: consider using 'if constexpr' statement instead

Change-Id: I9787fb37099f811c52f93c94c9edb4da8aafdfe5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-07-18 14:48:19 +02:00
Alexandru Croitor
53b6c88a25 CMake: Fix gc_sections genex evaluation in pkgconfig file creation
The gc_sections linker flag was recently wrapped in a
$<CXX_COMPILER_ID> genex to prevent adding it the command line when
using an incompatible compiler.

This causes an issue when generating .pc pkg-config files because
$<CXX_COMPILER_ID> can't be used in the output of a file(GENERATE)
call.

Record the flag in a global property, both the genex-wrapped and bare
forms, so that we can perform a string replacement when generating
the pkg-config file to remove the genex wrapping.

This is not perfect, in the sense that consumers of the .pc file
might get the wrong flag if using an incompatible compiler, but
it's better than outright failing the Qt build.

Distros will be expected to patch the .pc files if necessary.

Note the issue does not usually happen for regular Qt builds because
gc_sections is only enabled automatically for static builds, but for
static builds we don't currently generate .pc files.
So the issue only happens in shared Qt builds where the gc_sections
feature is enabled manually.

Amends a2b6c2f343

Pick-to: 6.5 6.6
Fixes: QTBUG-115243
Change-Id: I3f6bdf86c24ee90b6da04994e458b438cc41fc7a
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
2023-07-14 18:40:44 +02:00
Marc Mutz
7a1625abf1 modulecppexports.h.in: replace non-ASCII with ASCII characters
Qt 6 requires /utf-8 for user-projects by default, but allows users to
opt-out (cf. 0cdcbb40a1), so we shouldn't
use non-ASCII characters in public headers.

Amends 97f643faee.

Fixes: QTBUG-115229
Pick-to: 6.6 6.5
Change-Id: Ieb93ea9f3526e7bcc2e5aeffb5e69c68d10db792
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-07-14 16:02:12 +00:00
Alexandru Croitor
b9b5ed3aa6 CMake: Don't set QT_BUILDING_QT for single standalone tests
Standalone test projects have the following condition in the
beginning of their project:

 if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
     find_package(Qt6BuildInternals COMPONENT STANDALONE_TEST)
 endif()

When configuring the project the first time, QT_BUILDING_QT is not
set, find_package is called, configuration succeeds.
But because standalone projects implicitly include QtSetup.cmake,
that file sets the QT_BUILDING_QT cache var to true, and upon test
reconfiguration, cmake errors out with:
 Unknown CMake command "qt_internal_add_test"
or similar.

This happens because QT_BUILDING_QT is true on the second
reconfiguration and the find_package mentioned above is not executed
anymore, leading to unknown internal command errors.

Set a new QT_INTERNAL_IS_STANDALONE_TEST variable when we detect
a standalone test and check for its value in QtSetup so we don't
set QT_BUILDING_QT to TRUE anymore.

Adjust a few code locations where QT_BUILDING_QT being false might
trigger different behavior for standalone tests.

Task-number: QTBUG-93020
Change-Id: I5413b9f37653225175a1006f7626e023045b5979
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
2023-07-12 18:38:31 +00:00
Michal Klocek
ec2faefbc2 Explain why we can't use -Za in MSVC headersclean check
Bring back & update comment on -Za, which was removed
in 8bf60251 (in turn reverted in commit 2dcc3059).

For the details on -Za vs -permissive, see
   https://devblogs.microsoft.com/cppblog/permissive-switch/:
and the official Microsoft documentation.

This amends 2dcc30592b.

Change-Id: Ibeb135218dd0a17eddf821ad79246906993c586f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-07-12 11:37:54 +02:00
Yaroslav Isakov
929d9a4ca5 Allow OpenGL to be found on X11-less Linux systems (using libOpenGL)
Cmake supports finding OpenGL, even if there is no GLX (for glvnd) or
old-style libGL. This change keeps old behavior, but in case, if
X11-related OpenGL libraries cannot be found on Linux, it adds logic
to check for (and link with) libOpenGL, if it is present.

[ChangeLog][QtGui] Allow OpenGL to be found on X11-less Linux systems
(using libOpenGL)

Change-Id: Iccfeba83292a14081544c64ea8ce24fb52d1ee2f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-07-12 11:25:23 +02:00
Amir Masoud Abdol
70fc6b4581 Disable vcpkg detection/integration by default
We should not automatically enable vcpkg as soon as we find it on the
system. With this change, we disable the automatic
detection/integration.

[ChangeLog][configure] Vcpkg detection/integration is now disabled by
default, and it can be enabled by either passing `-vcpkg` to the
configure script, or by passing `-DQT_USE_VCPKG=ON` to cmake.

Change-Id: I4f098db670f11373064c071f1c3204e2e183d3db
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-07-12 11:24:15 +02:00
Giuseppe D'Angelo
95332cc376 Enable QT_NO_CONTEXTLESS_CONNECT in headersclean
Change-Id: I8b21a9666bb273929f740382fb6de8a1bb5ca911
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-07-12 01:33:16 +02:00
Amir Masoud Abdol
ab89b9cab3 Set VCPKG_CHAINLOAD_TOOLCHAIN_FILE to supplied_toolchain_file
Just a minor change, so that it's clear that we are setting the supplied
toolchain as the VCPKG_CHAINLOAD_TOOLCHAIN_FILE.

Change-Id: I10b35f04e7ad684015062066f67117ce4a964c1c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-07-11 17:32:25 +02:00
Amir Masoud Abdol
044cc7c90b Detect vcpkg after everything else
In order to use multiple toolchain, e.g., when we are cross compiling,
we need to load the detect, and load vcpkg's toolchain after our
toolchain file.

Change-Id: I7f3374363f725a634356788e22ac21835505c4b0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-07-11 17:32:25 +02:00
Hatem ElKharashy
a11ee31883 Add a private API to capture a graphics frame
This commit provides a minimal API for capturing a graphics
frame, save it and replay it later for debugging. The intention
here is to provide the basic need for future work to allow capturing
through tooling or programmatically from code. This API is
intended to be cross-platform by using Metal Capture Manager on
Apple devices and RenderDoc C++ API everywhere else.

Task-number: QTBUG-114067
Change-Id: If72d92bdef5e5985a0ec2e85e97fd1182da3c53c
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
2023-07-11 15:24:26 +03:00
Joerg Bornemann
f7b7262f11 CMake: Prevent infinite loop when generating module .pri files
CMake find modules of third-party libraries may create dependency cycles
in their imported library targets. For example, Conan's Vulkan::Vulkan
is such a candidate.

Prevent an infinite loop when generating .pri files for Qt modules that
link against such targets.

Pick-to: 6.5 6.6
Fixes: QTBUG-95569
Change-Id: I09b4a281930f7c6ce5e8c716fe0ab91e2453a24a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-07-10 14:53:33 +02:00
Alexey Edelev
d22a696b66 Add '_sync_headers' for interface libraries to "ALL"
Interface libraries don't build anything, commands that belong them
might not run if nothing depends on an interface library. We still need
to make sure that we run syncqt for interface libraries.
Add '_sync_headers' for interface libraries to "ALL" explictily.

Amends a8cf976ce6

Fixes: QTBUG-115101
Pick-to: 6.5 6.6
Change-Id: I24b34574fdc3060e3a60886620dbe5c1b526f1a7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-07-07 09:20:38 +02:00
Mårten Nordheim
20d3827ecc Android[openssl]: Check existence of OpenSSL .so file before use
VCPKG by default does static builds when building for Android.
This is at odds with the bundling-concept, so it should not be done
unconditionally.

Since we don't necessarily have the WrapOpenSSL target on-hand, let's
just do a file-exists test for the one of the paths we would include.

Pick-to: 6.6 6.5
Change-Id: I3693354308d5168d8a9c3d1659bfa51540114b7f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-07-06 21:25:51 +02:00
Amir Masoud Abdol
594b932c58 Silence the missing BundleIdentifier warning for non-Xcode generators
It's a bit excessive to warn every developer about this, especially if
they are using non-Xcode generators; besides, we are already generating
a bundle identifier if it is missing anyway.

Pick-to: 6.5 6.6
Change-Id: Ib11ad51a0e516e0ea61ad2f7bf499b846bc0b792
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-07-06 18:06:34 +02:00
Alexandru Croitor
3f6041a24f CMake: Add missing check for tool target promotion
We shouldn't try to promote tool targets if they were not created
when Qt6FooTools_FOUND is FALSE due to missing dependencies and
Qt6FooToolsTargets.cmake is not included.

Add a check for Qt6FooTools_FOUND to prevent errors like:

 CMake Error at lib/cmake/Qt6/QtPublicTargetHelpers.cmake:257
 (get_property):
  get_property could not find TARGET Qt6::qtprotobufgen.  Perhaps it
  has not yet been created.

Pick-to: 6.5 6.6
Change-Id: Ie26db637d4d8ef682a0ada5ea36ef0e8ceced008
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-07-05 15:09:33 +02:00
Mårten Nordheim
ee736717d3 CMake: Don't use VCPKG_DEFAULT_TRIPLET for triplet deduction
This environment variable is used by vcpkg to avoid having to pass
the --triplet argument on the command line on every vcpkg invocation
and shouldn't influence the triplet used during build. In fact,
the vcpkg.cmake toolchain will automatically attempt to deduce the
target triplet if we don't define this beforehand.

As a replacement, read from the QT_VCPKG_TARGET_TRIPLET environment
variable. It has the QT_ prefix to make it clear this is not a
standard vcpkg environment variable.

[ChangeLog][Build System] Qt no longer uses the VCPKG_DEFAULT_TRIPLET
environment variable to deduce target triplet. By default we let
vcpkg's toolchain file automatically deduce the triplet to use.
The new QT_VCPKG_TARGET_TRIPLET environment variable can be used
instead, or pass -DVCPKG_TARGET_TRIPLET=<triplet> to CMake.

Pick-to: 6.6
Change-Id: Idc6cbd52a68578d1762ca175c4973355409688ac
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-07-05 08:42:54 +00:00
Volker Hilsheimer
b3608700f9 Android: Downgrade OpenSSL configure error to warning
Amend 9d5a8162a5, after which building Qt
for Android locally required an OPENSSL_ROOT_DIR variable to be set.
Instead of making it harder for everyone to build Qt for Android (even
if no intention to work on or test network code locally), downgrade the
fatal error to a warning.

Pick-to: 6.6 6.5
Change-Id: I6f2176a40663cc9f55aa3066af78499af1f20894
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-07-04 10:46:23 +02:00
Amir Masoud Abdol
86e0c111fd CMake: Avoid creating empty directories when installing Find*.cmake
Surprisingly, CMake copy/install empty directories when `file` or
`install` are used with `FILES_MATCHING PATTERN` argument.
In order to avoid this, we can exclude the empty directories using a
PATTERN EXCLUDE argument.

Pick-to: 6.5 6.6
Change-Id: I17a22f9b9e317bc4a66cee3df39815659ddb4c04
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-07-04 07:34:14 +02:00
Amir Masoud Abdol
f1db0ca251 Look for MoltenVK headers if there are installed separately using Brew
Homebrew offers a formula for `vulkan-headers`, which does not include
the MoltenVK headers. MoltenVK does include the vulkan headers, but if
someone passes the vulkan-headers path to CMAKE_PREFIX_PATH, then our
module cannot pick up the MoltenVK headers. Brew's MoltenVK
installation is a bit odd as well, as in, one needs to point the
CMAKE_PREFIX_PATH to `HOMEBREW_PREFIX/molten-vk/libexec/` instead of
the directory head.

Pick-to: 6.6
Change-Id: I933faeb16b3f54597e3a0af0af584d79b3c0a344
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-30 10:55:01 +00:00
Alexey Edelev
49ce711796 Fix syncqt compiler and linker flags handling
We want syncqt to be built optimized by default. The current approach
set the default build type for the external projects and optimized
flags for the non-configure-time syncqt build. The problem is that
syncqt still have compiler flags littered by either the Qt configuration
type or the system defaults that are applicable for RelWithDebugInfo
configuration(the default one we chose for syncqt).

This patch makes sure that we cleanup all compiler flags from any
optimizations and apply optimized flags for all configurations. Also
we discard '/RTC1' flag if it's set. Configure time executables now
respect the language related flags that are set in the project and
adjust the flags passed to try_compile.

For linker flags we should use those that are applicable for the
preferred build type. Since syncqt is built in RelWithDebugInfo
by default we should replace linker flags in all configs with
those are used for RelWithDebugInfo configuration.

Fixes: QTBUG-114925
Pick-to: 6.5 6.6
Change-Id: I782f81a36f5ef7ee4d342ce8ac6c217cb2552f3b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-29 18:49:45 +02:00
Alexandru Croitor
961ff0cc8a CMake: Don't use check_language for Objective-C/C++
The check_language macro spawns a new cmake subprocess to detect
availability of a language. We use that to detect availability of
the Objective-C/C++ languages when targeting Apple platforms.

That's problematic because the parent process CFLAGS / LDFLAGS env
vars influences the result of the subprocess compiler detection,
and in some cases that can fail the detection.
An example of that is passing iOS specific flags which then get
mixed with the default macOS flags added by CMake, resulting in
a linker failure.

Instead of using check_language, explicitly enable the Objective-C
and C++ languages when targeting Apple platforms because we know
that we need them for compiling Qt.

This avoids the issue because enable_language is not spawning a
separate cmake sub-process and thus passes more information to the
underlying try_compile project to ensure a successful check.

The change also means that CMake will error out earlier in case if the
Objective-C compiler is not found, which was not the case before.

Pick-to: 6.5 6.6
Fixes: QTBUG-114470
Change-Id: I1a16c1e5828dfe10b2d7da27cc9a8c787517ab8e
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-06-29 16:28:53 +02:00
Amir Masoud Abdol
f607e22d59 Update the implementation of -unity-build
I added the ability to use `-no-unity-build`, and included the
batch size in the config.summary as well. In addition, qt_feature is not
being used for `-unity-build` anymore.

Pick-to: 6.5 6.6
Change-Id: I4a10e03d3505336d2256280ed2854ec0425df47f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-29 10:20:25 +02:00
Alexandru Croitor
9ef864f56f CMake: Require CMake 3.21 when building/using Qt on Apple platforms
Explicitly check that at least CMake 3.21 is used when building Qt or
when using Qt in a project.
This only affects macOS and iOS builds.

We check for 3.21 instead of 3.21.1 as described in the documentation
to avoid an error like:

 Policy VERSION range "3.21.1...3.21" specifies a larger minimum than
  maximum.

Until the technical limitation is addressed, if someone does end up
using 3.21.1, another existing check for "unsuitable" cmake versions
(as opposed to minimum required) will let them know they should use
something newer.

Amends 1cf3295cef321c9a587af2f2de7740c0cd3ca743.

Pick-to: 6.6
Fixes: QTBUG-114869
Change-Id: I2a479baaa63cfbe23af187cf0796e1c00042692b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-06-28 22:09:20 +02:00
Michal Klocek
2dcc30592b Fix headers clean for newer msvc
Newer msvc gives C4309 warning for 'initializing':
truncation of constant value

Warning would go away if we had 'enum foo: unsigned'.
Disable the warning for problematic enums is not enough
as it also complains about headers coming from windows sdk
like:

C:\Program Files (x86)\Windows
Kits\10\include\10.0.22621.0\shared\wtypesbase.h(395): warning C4309:
'initializing': truncation of constant value

Note 10.0.22621.0 is the latest sdk already.

Do not disable language extensions for header clean target.

This reverts commit 8bf602518d

Task-number: COIN-1059
Fixes: QTBUG-114931
Pick-to: 6.6
Change-Id: Ifc3883f88a6bd52794a37dc640eca99c158a40e0
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-06-28 16:02:45 +00:00
Alexey Edelev
a8cf976ce6 Introduce QT_SYNC_HEADERS_AT_CONFIGURE_TIME flag
The syncqt tool was originally designed to run at build time, as a
part of dependency chain of Qt modules. This works well unless we need
the code model of the Qt project in IDE, since Qt source code actively
uses header aliases, and creating them at build time breaks the code
model until the initial build is done. So we made syncqt the configure
time tool to not break the developer experience.

It's more likely that developers build Qt using command line or don't
need the code model before the first build. So running the tool at
configure time should be optional.

QT_SYNC_HEADERS_AT_CONFIGURE_TIME switches the "mode" of the syncqt
tool from build time tool to the configure time tool. Without the
option enabled build procedure runs all the syncing targets at build
time only. The exception are the developer builds, if the
'-developer-build' option is enabled, QT_SYNC_HEADERS_AT_CONFIGURE_TIME
is set to TRUE by default. This gives better development experience for
the developers that don't use the code model in their IDE or don't
require it before the first build is finished. Also this build time
mode is preferred for the CI or similar build procedures where code
model is not required at all.

By default, the option initialized from the
QT_INTERNAL_CONFIGURE_FROM_IDE CMake variable.

TODO: The option is forced to TRUE for the static Ninja Multi-Config
builds. See QTBUG-113974 for details.

[ChangeLog][Build System] When building Qt from sources, syncqt and Qt
header files are now created at build time, not configure time. This
should speed up the configuration step. You can set the CMake variable
QT_CONFIGURE_TIME_SYNC_HEADERS to ON to use the previous behavior,
though. The old behavior is also preserved if cmake/configure is run
from inside an IDE - Qt Creator, Visual Studio Code, and CLion are
currently detected.

Task-number: QTBUG-111163
Task-number: QTBUG-109792
Pick-to: 6.6
Change-Id: Ib61bda9546e58492be874a8591c37e100313d02c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-27 17:27:28 +00:00
Amir Masoud Abdol
b3f27f75b6 Introduce -no-vcpkg flag for disabling vcpkg detection/integration
Vcpkg detection is enabled by default, but we did not have a flag to
disable it, and it was not showing up in config.summary either. By
adding a -vcpkg flag, we get to use `-no-vcpkg` when necessary, as well
as adding an entry to config summary indicating whether vcpkg is in use
or not. Besides `-no-vcpkg`, one can pass `-DQT_USE_VCPKG=OFF` to cmake
command in order to disable the automatic vcpkg detection/integration.

[ChangeLog][configure] vcpkg detection, and integration can be disabled
by passing the -no-vcpkg flag to the configure command, or by passing
`-DQT_USE_VCPKG=OFF` to the cmake command.

Pick-to: 6.6
Change-Id: Ide8da70a7b473ec23995104d162356e75e6d1240
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-27 18:41:00 +02:00
Joerg Bornemann
6fec9646ac Fix comment in QtModuleHelpers.cmake
Don't talk about syncqt.pl anymore.

Change-Id: If153ffde9992c784cf71ae1bb5192e5e4bbb8628
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-06-27 18:36:06 +02:00
Piotr Wierciński
9f11a038b5 wasm: update emscripten to 3.1.37
Qt 6.6 will require emscripten 3.1.37

Pick-to: 6.6
Change-Id: Id036d799d5730ac8d8a5f7914d56a1ed421f9222
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
2023-06-26 07:58:11 +02:00
Morten Sørvig
70f5d396be wasm: enable asyncify for batched tests only
It should be possible to build a test in any configuration
by building Qt in that configuration, and then building
the test with qt-standalone-test.

Not all Qt configurations will be able to run all tests,
(due to exec() calls and similar) but that's OK - some
tests don't have exec() calls, and we want to be able
to run tests for a given configuration to figure out
how well it works.

On CI we want to use batching and asyncify, so it makes
sense to tie usage of asyncify to batching.

Pick-to: 6.6
Change-Id: I05553d250a45c1831f43dc71a43ef02d01d70535
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
2023-06-21 20:12:42 +02:00
Assam Boudjelthia
9d5a8162a5 Android:CMake: Add argument to bundle OpenSSL libs for internal tests
The new argument would allow bundling the prebuilt OpenSSL libs
into the test apk so that SSL can actually run. It expects the CMake
argument OPENSSL_ROOT_DIR to be set ( we set that in Coin configs).

Task-number: QTBUG-110025
Pick-to: 6.6 6.5
Change-Id: I4c82796635ca89f5511255ae26182f41a504b026
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-06-21 01:04:04 +03:00