Commit Graph

2246 Commits

Author SHA1 Message Date
Alexandru Croitor
65e04162d1 CMake: Recompute features when dependent features are marked dirty
Before this change, if a user toggled a FEATURE_foo variable, we only
recomputed the value for dependent features who's CONDITION would break
with the new value. If the CONDITION was not broken, the dependent
feature value would remain unchanged.

For example if FEATURE_developer_build was OFF, and the user
toggled it to ON, the FEATURE_private_tests value would remain OFF,
because OFF is a valid value for private_tests' CONDITION.

But we would like FEATURE_private_tests to become ON if we toggled
FEATURE_developer_build to ON.

To address this case, we need to recompute features who's dependent
feature values have changed.

The algorithm introduced by this change is:
- keep track of initial dirty features, aka track when FEATURE_foo is
  different from QT_FEATURE_foo. We expect FEATURE_foo to be the
  variable that a user toggles in the cache file or an IDE.
- when evaluating feature values, collect feature dependencies from
  the various expressions given to options like CONDITION, AUTODETECT
- if any feature dependency is marked dirty, reset the feature value
  to its auto-computed value and mark the reset feature as dirty
- repeat for all feature evaluations

Because feature evaluation is eagerly recursive, we will successfully
reset all features that need resetting.

To ensure against unforeseen breakages, allow disabling this behavior
by configuring with -DQT_NO_FEATURE_AUTO_RESET=ON

Adjust some of the messages to contain more details.

Note that the pre-existing behavior of resetting feature values when
the condition can't be satisfied, stays. For example if
FEATURE_developer_build is OFF and FEATURE_private_tests is manually
toggled to ON, it will reset to OFF
because its condition can't be satisfied (developer_build is still
OFF).

Amends 61943aefd6

[ChangeLog][Build System] The build system will now try to recompute
configure features when dependent feature values are toggled by the
user.

Pick-to: 6.6
Fixes: QTBUG-96936
Task-number: QTBUG-85962
Task-number: QTBUG-112957
Task-number: QTBUG-116209
Change-Id: Ib627f3675df8a3b08f4936cdc9c51f2d6e15f58c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-09-06 17:22:07 +02:00
Alexandru Croitor
c1d2356856 CMake: Move dirty feature / dirty build detection into QtFeature.cmake
It makes more sense for it to live next to the other feature code.

Pick-to: 6.6
Task-number: QTBUG-96936
Task-number: QTBUG-85962
Task-number: QTBUG-112957
Task-number: QTBUG-116209
Change-Id: I8438e6fce9deaa5e709e4b0e2e1ea4eb0600a89a
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-09-06 17:22:07 +02:00
Christian Strømme
9c3c87f6d0 Add enablers to expose semi-public APIs for QtQuick3D
Follow the same patterns as for qpa and rhi. Semi-public APIs will be
put under the "namespace" ssg which is short for Spatial Scene Graph.

Taks-number: QTBUG-116570
Change-Id: I38887f129ec90e67f6a929a0d8ea5ea8b8c49ee8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-09-05 13:42:50 +02:00
Alexey Edelev
d4eda5d34d Make sure that tests use the module build directory but not install path
If we configure module that is already installed it's expected that
tests use the build directory to resolve all the depdencies, but not
the install directory. This is especially sensetive if the module cmake
scripts were changed.

This changes the order of find_<package|dependency> PATHS that are
used to locate Qt package. QT_EXAMPLES_CMAKE_PREFIX_PATH now is used at
first, so we guarantee that we look into the build directory at
first place. This trick only works if build directory is added to
CMAKE_FIND_ROOT_PATH. The reason for that is the internal CMake logic
that tries to relocate the search PATHs and put the paths that are
subdirs of or exact CMAKE_FIND_ROOT_PATH higher in search list.

Fixes: QTBUG-115730
Change-Id: Icab721f0a6eac7301c626350ab214cc4545b368b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-09-01 11:12:23 +00:00
Thiago Macieira
946f15efb7 CMake/ELF: hide all Standard Library symbols
We've had issues in the past where Standard Library constructs either
with or without a Qt type mangled in the middle get exported from our
ABI and thus get marked with the Qt version numbers. For example, I can
see in our libraries:

  517: 000000000010e608     24 OBJECT  GLOBAL DEFAULT       22 typeinfo for std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>@@Qt_6
  615: 00000000000eb2a0     47 OBJECT  GLOBAL DEFAULT       17 typeinfo name for std::_Mutex_base<(__gnu_cxx::_Lock_policy)2>@@Qt_6
  706: 000000000010e5f8     16 OBJECT  GLOBAL DEFAULT       22 typeinfo for std::_Mutex_base<(__gnu_cxx::_Lock_policy)2>@@Qt_6
  750: 00000000000ed5f0     16 OBJECT  GLOBAL DEFAULT       17 std::_Sp_make_shared_tag::_S_ti()::__tag@@Qt_6
  754: 00000000000da408      1 OBJECT  GLOBAL DEFAULT       17 std::piecewise_construct@@Qt_6

This causes user content to break when an update to Qt stops exporting
such symbols, either because of code changes or because of changes to
the compiler and its optimizer.

In fact, this commit will cause that, for the symbols above. But this
will no longer be random-looking.

[ChangeLog][Important ABI Changes] On ELF-based platforms (e.g., Linux,
FreeBSD), the linking process has been updated to exclude Standard
Library symbols from getting the "Qt_6" ELF version. This solves the
problem of applications and libraries breaking arbitrarily after Qt
updates, but will cause such breakages right now. Content built with
older versions of Qt may need to be relinked.

Change-Id: I5acc02341c5940499682fffd1775edce0021ce6d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-08-30 23:26:26 -07:00
Thiago Macieira
a93f02e3ad CMake: remove test for eventfd, replace with __has_include
This also removes the configure option and therefore makes the feature
not disable-able. Saves 350 ms of CMake time.

Change-Id: Ifbf974a4d10745b099b1fffd17775528767595d4
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-08-29 07:41:11 -07:00
Joerg Bornemann
b1aa6c2bc8 CMake: Fix early exit in qt_build_repo_post_process()
This is a macro. We cannot use return() here or we're skipping code at
the call site.

This commit amends b684984939.

Task-number: QTBUG-88264
Change-Id: Icf6dd06338584239873bf4d66a4bbceef9071399
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
2023-08-24 15:14:53 +02:00
Joerg Bornemann
d5c4d6eb77 CMake: Rename QT_EXAMPLES_CMAKE_PREFIX_PATH
...to QT_BUILD_CMAKE_PREFIX_PATH, because the variable is now used for
examples and tests.

Change-Id: Ie6d32a0c99f46407f2771e12638456078c59fb18
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-08-23 16:21:58 +02:00
Joerg Bornemann
2ab80a2c18 CMake: Allow find_package(Qt6 COMPONENTS Foo) in tests
In prefix builds of non-qtbase repositories, calls to find_package(Qt6
COMPONENT Foo) did not work in tests, because the find_package calls in
Qt6Config.cmake use NO_DEFAULT_PATH, and thus CMAKE_PREFIX_PATH is
ignored.

Non-external-project examples had the same problem. This was fixed by
ffe0889413 which introduced the variable
QT_EXAMPLES_CMAKE_PREFIX_PATH as additional parameter in all relevant
find_package calls.

We now set this variable in qt_build_tests where it should be local to
the tests directory and its children.

We cannot use QT_ADDITIONAL_PACKAGES_PREFIX_PATH, because it's value is
read once and cached in Qt6Config.cmake - we would have to clear the
internal cache variable.

It would probably be good to rename QT_EXAMPLES_CMAKE_PREFIX_PATH to
reflect that it's not just used for examples. However, my naming skills
are drained for today.

Task-number: QTBUG-88264
Change-Id: I8bcfe9b7f2ee1f1b75dc725977924d09cb36822c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-08-23 16:21:58 +02:00
Joerg Bornemann
b684984939 CMake: Fix find_package(Qt6*Tools) in non-qtbase tests
Tests in non-qtbase modules could not find_package their own Qt6*Tools
packages, because add_subdirectory(tests) was called before the config
files for Qt6*Tools were created.

The creation of tools config files is done in QtPostProcess.cmake, which
was included in qt_build_repo_end(). Move that include into its own
macro, qt_build_repo_post_process() and remove it from
qt_build_repo_end(). Call qt_build_repo_post_process() before the
'tests' directory is added in qt_build_repo().

Every call site of qt_build_repo_end() must now be adjusted and call
qt_build_repo_post_process().

Task-number: QTBUG-88264
Change-Id: I80d60a1b5c0e9b715c298ef4934b562f815432d1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-08-23 16:21:58 +02:00
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
Mikolaj Boc
1f6cac0da9 Make WASM export names different across modules
The export name is now ${TARGET_NAME}Entry. This can also be overridden
by using QT_WASM_EXPORT_NAME, both in CMake and qmake

Change-Id: I59c97ae6e22f0b2720716e9d7eff7b6b13d37ab5
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-06-20 09:08:03 +02:00
Amir Masoud Abdol
45e17162ba Set QT_COMMAND_LINE_PARSER_NO_GUI_MESSAGE_BOXES before TRY_RUN
Set `QT_COMMAND_LINE_PARSER_NO_GUI_MESSAGE_BOXES` before trying to run
qt tools for correctness. This is to suppress QCommandLinerParser from
showing a message box when console is not available.

Pick-to: 6.5.2 6.5 6.6
Task-number: QTBUG-114530
Change-Id: Ib3d264a799a5da1f620d2bebe55539bafc43da0f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-06-20 07:34:09 +02:00
Amir Masoud Abdol
1bf144ba78 Resolve an issue with detecting GSSAPI on macOS
Spack, like VcPkg, sets the `CMAKE_FIND_FRAMEWORK` to `LAST`, as a
result, similar to VcPkg, when Spack is used, FindGSSAPI opts for
`gssapi_krb5` which is not what we want. By dropping the `gssapi_krb5`
from the list of alternative names we can resolve this without much
tinkering with internals of these package managers.

Pick-to: 6.5 6.6
Fixes: QTBUG-114537
Change-Id: If517c409511f58e3bed78316a2030393dc249a40
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>
2023-06-20 07:34:09 +02:00
Amir Masoud Abdol
331f316b91 Disable TRY_RUN when cross compiling
Fixes: QTBUG-114625
Pick-to: 6.5.2 6.5 6.6
Change-Id: Idec5ea438ebf3f88d63da7d956ab52e2a0fa1821
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
2023-06-17 20:26:12 +02:00
Joerg Bornemann
4d1525b0b8 CMake: Remove the dysfunctional -testcocoon configure option
TestCocoon is not maintained anymore, and the -testcocoon configure
option of Qt didn't do anything useful since Qt 6.0.0.

Remove the option. It's possible to create an instrumented build by
using dedicated CMake toolchain files as described in the documentation
of Squish Coco (TestCocoon's replacement).

Fixes: QTBUG-88316
Change-Id: I8a565cdd288aca9208f48138d2b663802cc0de90
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-06-16 23:39:01 +02:00
Amir Masoud Abdol
c5b0fa6082 Use QT_64BIT instead of checking CMAKE_SIZEOF_VOID_P
Pick-to: 6.6
Change-Id: I7db7b8f6c354df264a467538fffffab726ea1b61
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-06-16 21:54:36 +02:00
Alexey Edelev
28c9625d00 Fix CMP0099 impact - disallow propagating internal linker options
CMP0099 changes the way of LINK_ONLY genex works. With CMP0099 set to
OLD LINK_ONLY genex only links the exact library binary/archive without
propagating other interface options from the target. This feature was
exploited by PlatformXInternal targets to avoid propagating of their
linker options. Nowadays when CMP0099 is forced to NEW by Qt scripts,
including user-facing, we cannot rely on LINK_ONLY genex.

Introduce _qt_is_internal_target property that is set for all Qt
executables and explicitly limits the propagation of the linker
options from PlatformXInternal targets.

Pick-to: 6.5 6.6
Fixes: QTBUG-113641
Change-Id: I3a0ecddb65886e435073feb24c1b47035130ba70
Reviewed-by: Alexandru Croitor (OOO) <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-06-16 20:58:02 +02:00
Amir Masoud Abdol
69d74afd43 Add TRY_RUN_FLAGS argument to customize the TRY_RUN command
Some of our tools don't have the `-h`, or `-v` flag, or it could be
that the `-v` flag also prints the entire `--help` as well, e.g.,
`androiddeployqt`. When running in Jenkins, this may lead to a message
box being shown and consequently stopping the build. By customizing the
flag per tool, and limiting the TRY_RUN to tools that support `-v` or
`--version`, we can avoid this.

Also removed TRY_RUN from `macdeployqt` which doesn't need it anyway.

Amend 41b32cd2c4

Pick-to: 6.5.2 6.5 6.6
Fixes: QTBUG-114530
Change-Id: I78e3344d2553c0050c285ae86f2310bd373c6c57
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-06-15 11:46:00 +00:00
Alexey Edelev
4e74fa8119 Fix typo in qt_internal_add_global_definition
Fix the argument prefix that is used in the cmake_parse_arguments call.

Pick-to: 6.5 6.6
Change-Id: Ie02bdf7d2769ce084b0d173c1e8152ca6fc4fe53
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-06-14 16:18:55 +02:00
Alexey Edelev
a2b6c2f343 Wrap the GNU/Clang compiler-dependent flags with genex conditions
If flags use CMake scopes that propagate them to user libraries, it may
lead to an issue, if user projects are built using different compiler.
We need to guard these flags to make sure that they only will apply to
respective compilers.

Pick-to: 6.5 6.6
Change-Id: I0fd5847447bd8373e8e07f64dae11f27f48c915d
Reviewed-by: Alexandru Croitor (OOO) <alexandru.croitor@qt.io>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
2023-06-13 14:48:11 +02:00
Alexey Edelev
59a740e997 Replace list(FIND with simplified IN_LIST check
Pick-to: 6.6 6.5
Change-Id: I2ed1803adabc36e646edae3b2bb07e5ff2194d9b
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-06-13 14:48:10 +02:00
Amir Masoud Abdol
14b01b0aad Silence a warning in EGL check
There is a chance that an unused variable warning will be treated as an
error, and in that case, this check will fail, and as a result FindEGL
will fail.

Pick-to: 6.2 6.5 6.6
Fixes: QTBUG-114431
Change-Id: Iaac49589144dbe4172ec58c6705a9f899c25f01f
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-06-12 21:55:36 +00:00
Alexey Edelev
65b0bc0eed Fix external header support in qtsync
We should sync external headers for 3rdpary projects
like freetype and harfbuzz-ng and keep the directory
structure.

Fixes: QTBUG-113416
Pick-to: 6.6 6.5
Change-Id: Ie66edb9a21cff37ca6c8c68b6d225de6d8bbad81
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
2023-06-09 13:42:05 +00:00
Amir Masoud Abdol
5d12d9846a Fix the issue with setting the QT_BUILDING_QT
`TYPE` argument is not a thing, and if it is there, QT_BUILDING_QT is
set to `TRUE;CACHE;TYPE;STRING;When this is present and set to true, it
signals that we are building Qt from source.` instead of `TRUE`.

Pick-to: 6.2 6.5 6.6
Change-Id: I24784e9aead4929d408d06bce72d3f33ee21eb63
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-09 13:50:18 +02:00
Amir Masoud Abdol
9a5de496f1 Move QT_ALLOW_SYMLINK_IN_PATHS warning to config.summary
I think this needs to be more prominent, as I noticed during the testing
that it could cause issues if it gets lost in between the config
messages, as we knew of course.

Pick-to: 6.5 6.6
Task-number: QTBUG-113463
Change-Id: I2ece498a8d3604362a49cc10499b92b0d2764fb9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-08 19:29:34 +02:00
Amir Masoud Abdol
9d8a04cd1f Remove debug symbols from Android's release build
Android's toolchain file, ie., android-legacy.toolchain.cmake assumes
that the default build is a Debug build, and it adds the `-g` flag to
CMAKE_<LANG>_FLAGS, as a result, our release Android build always
contains debug symbols. In this patch, I basically move the `-g` flag
from CMAKE_<LANG>_FLAGS to CMAKE_<LANG>_FLAGS_DEBUG, and
CMAKE_<LANG>_FLAGS_RELWITHDEBINFO.

Pick-to: 6.5 6.6
Fixes: QTBUG-111901
Change-Id: I31eadb07d9172c923e8beaf0ac6c6e34fe1ebefb
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-06-08 16:25:59 +00:00
Kai Köhne
7626736a5f Fix indentation of generated cmake code snippet
Pick-to: 6.5 6.6
Change-Id: I41a1998bd45fbbf2ec81fe7e3ce042bcb3aae308
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-08 16:07:57 +00:00
Alexandru Croitor
48841c34d2 CMake: Unify CMAKE_BUILD_TYPE behavior on all platforms
Before this change, we had the following behaviors.

On platforms other than Windows-MSVC:
- when no build type was specified, we defaulted to Release
- when -developer-build was specified, we defaulted to Debug
- regardless of platform, unless the option was explicitly specified,
we never defaulted to -debug-and-release.

On Windows-MSVC, we always defaulted to Debug. Which is inconsistent
with the rules above.
The difference happens because CMake always sets CMAKE_BUILD_TYPE to
Debug during the first project() call when targeting the Windows-MSVC
platform.

We interpreted that as the user setting the build type, and thus we
didn't want to override what the user specified.

After this change, if we detect that it's cmake setting the build
type, we assign a build type that follows the non-Windows-MSVC rules.

This change unifies the behavior across all platforms.

Adjusted the configure help with the new reality.

Augments 33af62db37

[ChangeLog][configure] When no explicit build type is specified,
Windows will now default to building Release like the other
platforms.

Pick-to: 6.5 6.6
Change-Id: Id2bf269c51cf300ec09751ece2ad721869e0f90c
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-06-08 13:04:45 +02:00
Alexandru Croitor
e3c6754760 Revert "CMake: make compile options consistent for Qt created libraries"
This reverts commit 389507a047.

Reason for revert: The original patch unintentionally changes
the deprecation warning behavior for user projects. Merging
the current change will resurface the original static qt build
bug until a new fix is developed.

Pick-to: 6.6
Change-Id: I29b41b43fdd76b19bc46439470e04443dc2b8ddb
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Yuhang Zhao <yuhangzhao@deepin.org>
2023-06-08 11:04:45 +00:00
Thiago Macieira
604eb6f4cd CMake: apply OpenBSD patch to enable $ORIGIN
Found at https://github.com/openbsd/ports/blob/master/x11/qt6/qtbase/patches/patch-cmake_QtRpathHelpers_cmake

There are a lot more patches there whose purpose I can't tell. This is
the only CMake one that I do understand. They should upstream those
changes to us with an explanation, instead of carrying patches...

Found while researching if 9caac0f176 was
still necessary for OpenBSD.

Pick-to: 6.5 6.6
Change-Id: I63b988479db546dabffcfffd17661fdd376bf8c8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-07 17:09:52 -07:00
Amir Masoud Abdol
076b4bed9f Resolve an issue when running /qt-configure-module .
Accounting for the case where `MODULE_ROOT` is set to `.` which then
makes the `get_filename_component` command to return an empty string;
consequently, we cannot find the `config_file.txt`, and cannot process
the features correctly.

Amend f4bf7982a6

Pick-to: 6.5 6.6
Fixes: QTBUG-114085
Change-Id: I55c7529be6caba4691adec80efca8021bd03c500
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-08 01:18:04 +02:00
Amir Masoud Abdol
b738ad7e3a Fix an issue with processing -prefix paths ending with \ on Windows
In cases like `C:\` or `C:\D\E F G\`, we had the issue were Windows'
path separator was acting as an escape and was corrupting configure
arguments', so, we were ending up with `-DCMAKE_INSTALL_PREFIX=C`, or
were cutting the argument list short, and ended up ignoring some of the
arguments.

Pick-to: 6.5 6.6
Change-Id: I433af61d5c143cc37a64dcf8ac82a1a78ce543a5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-08 01:18:04 +02:00
Amir Masoud Abdol
a471324a03 Use parentheses for Xcode specific variables
If I'm not mistaken we would like to leave this to Xcode, if so, we can
use `$()` to make our intention more clear in the code.

Pick-to: 6.5 6.6
Change-Id: I3867f68f371a1cf1a5db5e639ec740f2546ccd75
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-06-06 19:49:02 +00:00
Kai Köhne
b63bf98329 CMake: Remove local __PPS target
Remove the local __PPS target and make PPS::PPS itself the
imported target. This is not only simpler, but also hopefully resolves
an issue with static builds, where PPS::PPS was not properly promoted
to a global target, leading to linker errors.

Fixes: QTBUG-108794
Pick-to: 6.5 6.6
Change-Id: Ia9334a27312ba9bfeec964f6bd6a82652e5f9d37
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-06 15:33:41 +00:00
Amir Masoud Abdol
1eb4d17cb4 Generate and set a CFBundleIdentifier when none were provided on macOS
When using Ninja generator on macOS, we now do a bit of extra work to
make sure that bundle identifier is always set.

- In the case where no identifier was provided, the warning message has
  been updated indicating that the user can set either of the
  properties.
- If both `MACOSX_BUNDLE_GUI_IDENTIFIER` and
  `XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER` were set but have
  different values, a warning will be shown to encourage the user to set
  only one of them.
- In addition `_qt_internal_get_ios_bundle_identifier_prefix` is renamed
  to `_qt_internal_get_apple_bundle_identifier_prefix` to be more
  platform specific.

Note:
    In general, if Ninja is the generator, we set the value of
    `MACOSX_BUNDLE_GUI_IDENTIFIER` and don't touch the
    `XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER`. If Xcode is the
    generator, we set the value of
    `XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER`, and in addition, to
    silence a Xcode warning, we set the `MACOSX_BUNDLE_GUI_IDENTIFIER`
    to `${PRODUCT_BUNDLE_IDENTIFIER}`, ie., let Xcode figures it out if
    needed.

[ChangeLog][CMake][macOS] When using Ninja generator, if neither
`XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER` nor
`MACOSX_BUNDLE_GUI_IDENTIFIER` is provided for a target, a bundle
identifier, i.e., `com.yourcompany.<teamid>.<target>` will be generated
and set as CFBundleIdentifier.

Pick-to: 6.5
Fixes: QTBUG-110889
Change-Id: Ie071085bbaf465afcb022b760423eb6b3c921f6d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-02 19:28:04 +02:00
Alexey Edelev
0006a564c8 Collect module_sync_headers targets from the target deps
Use the internal target property to store the module_sync_header target
name. The property then is used to collect module_sync_header targets
and build the dependency tree between them. This mechanism only works
for Qt dependencies that are added using qt_internal_extend_target call
that works well at least for out CI builds. The mechanism allows to
omit the race in sync_header runs that might lead to unexpected results
since internal targets like automoc or headersclean_check only depend
directly on module_sync_header target that belong to the module.

Change-Id: I564f3ea0f3c1703e70c4c300fd1307c3214d39d8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-02 15:12:09 +02:00
Alexey Edelev
251e3b44fa Add the description for the QT_ALLOW_DOWNLOAD option
Introduce QT_ALLOW_DOWNLOAD option that should be used the downloading
of the resources from web in Qt builds. Calls like file(DOWNLOAD or
FetchContent_* should be wrapped with this option, so users that build
Qt could control this and disable functionality that requires
resources from web.

Change-Id: Ie0494265c0c5fe93a7ef0d1cbcee1af919d57fa5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-02 15:12:08 +02:00
Tor Arne Vestbø
1d3ae5f0e9 cmake: Add known translations to CFBundleLocalizations in Info.plist
For untranslated applications we set CFBundleAllowMixedLocalizations to
true, so that the application's locale will not be limited to the
development region "en".

But once we have a set of known translations, added by qt_add_translations,
we can turn these into CFBundleLocalizations, which lets macOS/iOS
choose a best match between what the app supports and what the user
preferences are.

[ChangeLog][Internationalization] Translations added via
qt_add_translations are now reflected as CFBundleLocalizations
entries in the application's Info.plist file on Apple platforms.
to disable this behavior, set QT_NO_SET_PLIST_LOCALIZATIONS.

Change-Id: I3f7ae1a1884eaf269038fa8ee49dbe6cac855706
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-02 15:12:06 +02:00
Tor Arne Vestbø
21000ede37 cmake: Always copy Info.plist to build directory manually
Allows us to modify this file in place, before CMake copies it into
the application bundle during its generator step.

Change-Id: I73325c66b5b8919f57dbaa1cc76a7edbc145609c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-02 15:12:05 +02:00
Amir Masoud Abdol
6f6bd2c4dc Set QT_FORCE_FEATURE_neon to ON for x86_64h arch as well, on macOS
We were not accounting for `x86_64h` arch, and as a result
cross-compiling with `-DCMAKE_OSX_ARCHITECTURES="x86_64h;arm64`
was failing.

Pick-to: 6.5
Fixes: QTBUG-113694
Change-Id: Ieb50a7a62aabcca76b09f9c853b3faf915eab1a3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-01 22:27:06 +02:00
Amir Masoud Abdol
63a0f4dc3b Set CMAKE_<LANG>_FLAGS in PARENT_SCOPE as well
Previously, we were not setting the CMAKE_<LANG>_FLAGS, instead we were
only processing the CMAKE_<LANG>_FLAGS_<CONFIG>. This patch amends that
so we also update the default flags list as well.

Pick-to: 6.5
Change-Id: I7ceb87850a806fe8ad4eac6f8147b312eba01bc6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-01 19:10:12 +02:00
Tor Arne Vestbø
2f273f5dfd cmake: Copy template Info.plist for macOS manually, like we do for iOS
Unifies the approach between iOS and macOS. By copying the Info.plist
to the build directory, we also open up the possibility to modify it,
which we can't do when CMake does the copy during its generator step.

Change-Id: I59f9f69ac368166bb26d8a5c57bf4ea3f503d51b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-01 14:07:18 +02:00
Amir Masoud Abdol
a33dd60e21 Add TRY_RUN option to qt_internal_add_tool
To make sure that Qt essential tools can be executed after a successful
build, we can now pass the TRY_RUN argument to `qt_internal_add_tool`.
On Windows, this option creates a custom command and a custom target
(${target}_try_run) for the tool, and tries to run the tool from a batch
script. If the program fails to run because of missing libraries, an
error will be shown, and build halts; otherwise,
`${target_name}_try_run_passed` file will be generated and the build
continues.

Pick-to: 6.5
Task-number: QTBUG-113273
Task-number: QTBUG-112747
Change-Id: I760588714bcf9db69505abe3df717733352a8284
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-01 12:02:28 +02:00
Amir Masoud Abdol
672a1d022c Implement qt_internal_get_file_path_mode for changing the file path mode
In cases where we allow symlink, we need to use ABSOLUTE path, and don't
resolve the symlink. This function returns ABSOLUTE only if we are on
Apple platform, and have QT_ALLOW_SYMLINK_IN_PATHS enabled. While this
is mainly to resolve the issue report by Homebrew, it might be useful if
a user really want to build with symlink.

Pick-to: 6.5
Task-number: QTBUG-113463
Change-Id: Ided141ed8de66cc1d3717ec2719eb703fa7fc589
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-05-31 16:37:25 +02:00
Amir Masoud Abdol
585dd9d8d5 Add NOMINMAX to PlatformCommonInternal
By not explicitly disabling min/max macros of `windows.h`, we may see
some unintended substitutions. This is especially important now that we
are moving toward enabling Unity Build, and some of the constructs for
manually dealing with this issue, eg., `#ifdef max`, `#undef max`, might
not make it to the pool, and as a result we get build failure.

Pick-to: 6.5
Change-Id: Ie3c31aebe00300126a2ac3a6044876ab92d5d99c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-05-31 16:37:22 +02:00
Alexey Edelev
65c1ac1df6 Avoid adding the redundant install rules for module headers
If module doesn't contain headers we should skip adding install
rule of the geneated by syncqt module headers, since the staging
directory will not be created in this case.

Change-Id: I89db5f1447d60cae48cd6ae4b9ef080dcf50e34c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-05-31 13:01:35 +02:00
Alexey Edelev
5cf79c2b9b Fix Clang platform detecting mechanism
CMake not necessarly sets MSVC or MINGW when detecting Clang compiler.
We should rely on CMAKE_CXX_COMPILER_FRONTEND_VARIANT instead when
detecting Clang platform.

Fixes: QTBUG-113630
Pick-to: 6.5 6.2
Change-Id: I8c14939ddc0839ddf2b3419392aa843deeef4bb5
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-31 12:58:00 +02:00
Yuhang Zhao
389507a047 CMake: make compile options consistent for Qt created libraries
Currently some libraries created by Qt are lacking some compile
definitions and compile options, and this issue is causing us
troubles when building Qt statically. This patch tries to reduce
the parameter difference when compiling Qt's own libraries.

Change-Id: I3842943a874fab32ef90980e8aa29f5beb01feeb
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-05-31 01:08:45 +00:00
Alexey Rochev
d68dbd8b7d Fix version script test
1. Don't reassign different versions to same symbol
2. Define symbols used
This fixes warnings with LLD linker (or errors if -Wl,--fatal-warnings is added by toolchain e.g. with Android NDK)
3. Add -Wl,--version-script to CMAKE_REQUIRED_LINK_OPTIONS instead of CMAKE_REQUIRED_FLAGS to prevent unused argument warning in compilation phase
(there is no need for _SAVE variable because we are inside a function and our CMAKE_REQUIRED_LINK_OPTIONS won't escase its scope)
4. Fix removal of version script file (incorrect file name was used)

Pick-to: 6.2 6.5
Task-number: QTBUG-111514
Change-Id: I0a1548c4268ad511760a0d4aa69ba7a0bdcbb0bc
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-05-30 23:25:57 +03:00
Amir Masoud Abdol
574cf24a65 Replace AUTO_RESOURCE_PREFIX with RESOURCE_PREFIX in qt-cmake-project
Pick-to: 6.5
Change-Id: I53b9e8887e8e79c1c1e836c514171aece8cf35aa
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-05-30 10:38:33 +02:00