Commit Graph

1929 Commits

Author SHA1 Message Date
Alexandru Croitor
af56a6f0cb CMake: Don't force CONFIG mode when looking for system PCRE2
This allows picking up 3rd party Find modules. One use case is
Conan-generated Find modules.

Also add TODO in case we ever need to handle finding the upstream
target name rather than the Hunter chosen one.

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-104542
Change-Id: I243987c657f74e8127076666d9734b2b657bc0ee
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-02 00:11:12 +02:00
Alexandru Croitor
bfd9e195a3 CMake: Fix lookup of system PCRE2 version
The version option needs to be specified before the COMPONENTS
option, otherwise it is treated as another component.

This causes failures when a Conan provided FindPCRE2.cmake script is
picked up, which actually does validation of component names based
on the component information stored in the conanfile.py recipe.

Move the version value to be before COMPONENTS.

Amends 1007aac63a

Pick-to: 6.2 6.3 6.4
Task-number: QTBUG-104542
Change-Id: I92c70f266a07c4aabdadcecda1ba7e107a033604
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-02 00:11:12 +02:00
Alexandru Croitor
dd1030a450 CMake: Record used package version for each target dependency
When recording which package version to look for in
QtFooModuleDependencies.cmake and other files like it,
instead of using PROJECT_VERSION, use the version of the
package that contains the dependency.

For example if we're hypothetically building the qtdeclarative repo
from the 6.4 branch, against an installed 6.2 qtbase, then
the Qt6QmlModuleDependencies.cmake file will have a
find_package(Qt6Core 6.2) call because qtdeclarative's
find_package(Qt6Core) call found a 6.2 Core when it was configured.

This allows switching the versioning scheme of specific Qt modules
that might not want to follow the general Qt versioning scheme.

The first candidate would be QtWebEngine which might want to
follow the Chromium versioning scheme, something like
Qt 6.94.0 where 94 is the Chromium major version.

Implementation notes.
We now record the package version of a target in a property
called _qt_package_version. We do it for qt modules, plugins,
3rd party libraries, tools and the Platform target.

When we try to look up which version to write into the
QtFooModuleDependencies.cmake file (or the equivalent Plugins and
Tools file), we try to find the version
from a few sources: the property mentioned above, then the
Qt6{target}_VERSION variable, and finally PROJECT_VERSION.
In the latter case, we issue a warning because technically that should
never have to happen, and it's a bug or an unforeseen case if it does.

A few more places also need adjustments:
 - package versions to look for when configuring standalone
   tests and generating standalone tests Config files
 - handling of tools packages
 - The main Qt6 package lookup in each Dependencies.cmake files

Note that there are some requirements and consequences in case a
module wants to use a different versioning scheme like 6.94.0.

Requirements.
 - The root CMakeLists.txt file needs to call find_package with a
   version different from the usual PROJECT_VERSION. Ideally it
   should look for a few different Qt versions which are known to be
   compatible, for example the last stable and LTS versions, or just
   the lowest supported Qt version, e.g. 6.2.6 or whenever this change
   would land in the 6.2 branch.
 - If the repository has multiple modules, some of which need to
   follow the Qt versioning scheme and some not,
   project(VERSION x.y.z) calls need to be carefully placed in
   subdirectory scopes with appropriate version numbers, so that
   qt_internal_add_module / _tool / _plugin pick up the correct
   version.

Consequences.
 - The .so / .dylib names will contain the new version, e.g. .so.6.94
 - Linux ELF symbols will contain the new versions
 - syncqt private headers will now exist under a
   include/QtFoo/6.94.0/QtFoo/private folder
 - pri and prl files will also contain the new version numbers
 - pkg-config .pc files contain the new version numbers
 - It won't be possible to write
   find_package(Qt6 6.94 COMPONENTS WebEngineWidgets) in user code.
   One would have to write find_package(Qt6WebEngineWidgets 6.94)
   otherwise CMake will try to look for Qt6Config 6.94 which won't
   exist.
 - Similarly, a
   find_package(Qt6 6.4 COMPONENTS Widgets WebEngineWidgets) call
   would always find any kind of WebEngine package that is higher than
   6.4, which might be 6.94, 6.95, etc.
 - In the future, if we fix Qt6Config to pass EXACT to its
   subcomponent find_package calls,
   a find_package(Qt6 6.5.0 EXACT COMPONENTS Widgets WebEngineWidgets)
   would fail to find WebEngineWidgets, because its 6.94.0 version
   will not be equal to 6.5.0. Currently we don't pass through EXACT,
   so it's not an issue.

Augments 5ffc744b79

Task-number: QTBUG-103500
Change-Id: I8bdb56bfcbc7f7f6484d1e56651ffc993fd30bab
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-01 10:50:57 +02:00
Alexandru Croitor
74d8321771 CMake: Don't show the incompatible version warning when not needed
If a find_package(Qt6Foo) call has the QUIET option passed, don't
display the incompatible version warning.

Also if the find_package call has the EXACT option passed, and the
searched for version does not match the package version exactly,
there's no point in showing the warning because find_package
will reject the package anyway, even if we set
PACKAGE_VERSION_COMPATIBLE to TRUE

Pick-to: 6.2 6.3 6.4
Change-Id: I78ef95cf4a045034fc50853465f3ba1db84bba63
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-01 10:50:55 +02:00
Thiago Macieira
db342f42a4 CMake: update the x86 intrinsic checks
Merge all the existing checks into a single one, which is a simple pass
or fail, since all our supported compilers support all the intrinsics up
to Cannon Lake. The two I've recently added (AVX512VBMI2 and VAES)
aren't yet supported everywhere, so they stay.

For some reason, all intrinsics seem to be disabled on Android. It looks
like some support was missing during the CMake port and this was never
again looked at. I'm leaving it be.

As for WASM, discussion with maintainers is that the WASM emulation of
x86 intrinsics is too hit-and-miss. No one is testing the performance,
particularly the person writing such code (me). They also have some
non-obvious selection of what is supported natively and what is
merely emulated. Using the actual WASM intrinsics is preferred, but
someone else's job.

Change-Id: Ib42b3adc93bf4d43bd55fffd16c10d66208e8384
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-06-28 03:28:42 +00:00
Thiago Macieira
500c116ced CMake: disable the attempt to force SIMD on iOS simulator builds
This will stop working with the next commit, which merges all basic x86
SIMD intrinsics into one configure test. As a result, linking almost
anything graphical on iOS (which is almost everything) causes the linker
to fail with undefined references to SIMD-optimized versions that didn't
get compiled.

Change-Id: Ib42b3adc93bf4d43bd55fffd16c288f4104a6ccc
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-06-27 20:28:41 -07:00
Kai Köhne
267db4eab4 Doc: Skip 'qt5/' part in 3rd party documentation
Pick-to: 6.4
Fixes: QTBUG-104463
Change-Id: I7596118e147c9b5b12b49c4cf2692626697f309e
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2022-06-23 01:30:23 +02:00
Thiago Macieira
c83a87eca7 CMake: fix build with FreeBSD 13.1
I don't know if they've just added the libs and therefore the GSSAPI
content wasn't enabled before, but libgssapi_krb5.so does not have the
symbols we need.

ld: error: undefined symbol: gss_acquire_cred
>>> referenced by qauthenticator.cpp:1803 (/usr/home/tjmaciei/src/qt/qt6/qtbase/src/network/kernel/qauthenticator.cpp:1803)
>>>               src/network/CMakeFiles/Network.dir/kernel/qauthenticator.cpp.o:(qGssapiTestGetCredentials(QStringView))

ld: error: undefined symbol: gss_release_name
>>> referenced by qauthenticator.cpp:1808 (/usr/home/tjmaciei/src/qt/qt6/qtbase/src/network/kernel/qauthenticator.cpp:1808)
>>>               src/network/CMakeFiles/Network.dir/kernel/qauthenticator.cpp.o:(qGssapiTestGetCredentials(QStringView))
[...]

Pick-to: 6.2 6.3 6.4
Change-Id: I6d3880c7d99d4fc494c8fffd16fabf70bbd272f5
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-22 12:42:11 -07:00
Alexandru Croitor
754512a64d CMake: Fix prl files not to contain hard-coded library paths
Make sure to convert absolute paths generated using the
$<TARGET_LINKER_FILE> generator expressions into relative paths.

Because prl files are generated for both modules and plugins, we need
to pass both a list of qt module locations and qt plugin locations
to QtFinishPrl.cmake, and then try to make the absolute path relative
to each passed directory.

A warning assertion is shown if we no relative path could be made,
which will cause an absolute path to be embedded. This should not
happen though.

Amends f4e9981259

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-104396
Change-Id: Id68395c0dbb20aad5c510d77835cc931b9396556
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-22 20:18:39 +02:00
Lorn Potter
1e2d67152f wasm: Optimize use of opengles
- USE_WEBGL2 is depreciated, Emscripten now uses MAX_WEBGL_VERSION
- Optimize and remove use of emulated ES2 and ES3, which means
only use WebGL friendly subset.
Users can add USE_ES3=1 and USE_ES2=1 to the final linker arguments
for those respective versions in order to enable using
glDrawArrays and glDrawElements with unbound buffers.
See https://emscripten.org/docs/porting/multimedia_and_graphics/OpenGL-support.html

Pick-to: 6.4
Change-Id: I11ae359966964b3e7aa6e61ccc714c2bfbf61f96
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-06-22 13:59:25 +10:00
Marc Mutz
06f21a3870 headerclean: remove dead code
The variable was misspelt, so we obviously don't need these
exceptions.

Pick-to: 6.4 6.3 6.2
Change-Id: I691c9315bcde3aad72410ce01ae6dc6a013ee6fd
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-06-22 03:09:24 +02:00
Marc Mutz
97f643faee Long live QT_INLINE_SINCE!
We have now had several requests for inlining previously-exported
member functions, but no standard mechanism to effect it.

As QT_REMOVED_SINCE has shown, there is great value in having such a
standard mechanism, so here is one.

With this change, to inline a previously exported (member) function,
simply

- mark the declaration with QT_<MODULE>_INLINE_SINCE

- move the definition into the header file (outside the class),

  - wrap it in QT_<MODULE>_INLINE_IMPL_SINCE

- #include the header into the module's removed_api.cpp

Just including the header into removed_api.cpp is enough, so you may
want to add a comment:

    #include "header.h" // uses QT_<MODULE>_INLINE_SINCE

The effect is as follows:

- A TU in a _different_ library will see an inline declaration,
  followed by the definition, and so it will see a normal inline
  function.

- A TU in the same library will, however, see a non-inline
  declaration, to avoid the ODR violation that at least GCC/ld are
  able to detect.

  - When QT_<MODULE>_BUILD_REMOVED_API is in effect, the TU will also
    see the definition, which is the same setup as before the change,
    except in a different TU, and therefore export the member.

  - When, OTOH, QT_<MODULE>_BUILD_REMOVED_API is _not_ in effect, the
    TU will see no declaration, assuming (correctly), that the
    definition will be supplied by a different TU.

This is, of course, an ODR violation, but not worse than what we do
elsewhere, as the definitions differ only between library and user.

The function is inline only for the users of the library, not the
library itself, which will still see the function as non-inline. If
inlining is critical within the library, too, the existing function
should call a new inline function, and calls in the same library should
be changed to call the new inline function instead.

Use the new mechanism to inline the QLocale ctor we intended to inline
for 6.3, but couldn't, because we hadn't found the magic incantation,
yet. Thiago found it a few weeks later, and this is what this patch is
based on.

Fixes: QTBUG-100452
Pick-to: 6.4
Change-Id: Ia0030cddc64b6b92edfed860170d5204aa74b953
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-06-22 01:09:24 +00:00
Yuhang Zhao
11e6e9bccd CMake: Mark chosen C++ standard as required for building Qt
Change-Id: I7d3187e74251059c7536f3e34d8c87f54c673146
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-19 14:45:07 +08:00
Alexey Edelev
4d7ba44e4d Add missing argument to list(APPEND in __qt_internal_get_tool_imported_location
Amends f9e48854af

Pick-to: 6.4
Change-Id: Iea525c70cca9873c0f3d96967af6cd95d57cac9b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-17 18:02:24 +02:00
Alexandru Croitor
b3e3b12489 CMake: Warn when using CMake 3.21.1
Changing a C++ source file can trigger rebuilds of a lot of other
source files that might include AUTOGEN'ed headers or sources.

See https://gitlab.kitware.com/cmake/cmake/-/issues/22531 for some
details. Fixed in CMake 3.21.2.
There are still files that are rebuilt even in 3.21.2, but it's less,
and it returns to the status quo of how it was in 3.21.0 or earlier
versions.

Pick-to: 6.2 6.3 6.4
Task-number: QTBUG-104352
Change-Id: Ie1c991d52df48442d4134e4ed22a8137a3c993c8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-16 19:29:35 +02:00
Dimitrios Apostolou
fe0e87c9a6 Add ASAN build for qtbase
The test run is wrapped with a special TESTRUNNER script that ignores
failing tests (there are several tests failing when built with ASAN) and
also ignores LSAN errors (memory leaks - but still visible in the
output).

The test run only fails if a test reports ASAN errors or if it
crashes (or times out, which is like a crash caused by qtestlib's
watchdog timer).

Fixes: QTQAINFRA-5025
Change-Id: I861756ab49388ac4a52409d3a780684244e469b1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-15 23:58:16 +02:00
Marc Mutz
ecbe56825a modulecppexports.h.in: re-indent nested preprocessor directives
Amends 0d9f4e7526.

Task-number: QTBUG-100452
Pick-to: 6.4 6.3 6.2
Change-Id: Iaa6626853a4241f750a6929fc9f604a149c874eb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-14 03:30:48 +02:00
Kai Köhne
04cc705947 CMake: Fix typos
Found by codespell

Pick-to: 6.4
Change-Id: I4907e423b6b345acf82f2d7e0ed62479719d694e
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-13 15:37:36 +02:00
Thiago Macieira
88f5955cb7 CMake: up the minimum C version to C11
We're in 2022. A 11-year-old C standard probably suffices, especially
since we require C++17 anyway.

Pick-to: 6.4
Change-Id: Ibcde9b9795ad42ac9978fffd16f3555327097ded
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-11 10:58:43 +00:00
Alexandru Croitor
b3d0325a8d CMake: Ensure top-level builds are affected by our chosen log level
This will hide the configuration summary and cmake feature summary and
found packages output upon reconfiguration.

Pick-to: 6.2 6.3 6.4
Task-number: QTBUG-104128
Change-Id: I42270b99e45076052ec176df4652661cae10ac0c
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-06-10 21:10:34 +02:00
Alexandru Croitor
dd5c860a7b CMake: Show configuration summary on first configuration
or when feature changes are detected, even when the log-level is set
to NOTICE (which is the default for non-developer-builds).

We want to show the summary during the first configuration so we don't
force users to look into the config.summary file.

We want not to show the summary upon reconfigurations, to keep regular
reconfigurations as quiet as possibe, so it's easy to notice any new
warnings.

Amends e2a0ddbb69
Amends 384dfceb53

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-104127
Change-Id: I506f33b4bae9da8957e04bb69c206bf00e3f7b0e
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-06-10 21:10:34 +02:00
Joerg Bornemann
f318c0e2d6 CMake: Find system harfbuzz even if pkg-config is disabled
FindWrapSystemHarfbuzz.cmake relied on pkg-config to find system
harfbuzz.  This patch makes it find system harfbuzz even if pkg-config
is not available or disabled.

Pick-to: 6.2 6.3 6.4
Task-number: QTBUG-103894
Change-Id: I2a8fc64c738c7604f47de89f387002e40a9fa5e0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-10 14:25:45 +02:00
Joerg Bornemann
71a0b893fb CMake: Fix check for system harfbuzz if pkg-config is unavailable
We need to check whether pkg_check_modules returns success before
setting up target name etc.

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-103894
Change-Id: I12702639683723d976e93be95443099b88885869
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-10 14:25:41 +02:00
Joerg Bornemann
4cef4f1c1b Make configure -no-pkg-config actually work
Turning off pkg-config with the configure flag -no-pkg-config did not
work.  There are different defaults for FEATURE_pkg_config on different
platforms (e.g. Linux: ON, Windows: OFF).  The existing code that
calculated the initial FEATURE_pkg_config value assumed that the default
is OFF and never turned the feature off.

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-104123
Change-Id: I33b9687c55c60d4ec9224324951a8838741ee976
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-10 14:11:09 +02:00
Allan Sandfeld Jensen
dc3b2ac81d C++23/c++2b support
Change-Id: I33b2a48312ae94e3d5ebb4097e50c4953e14d533
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-08 19:43:34 +02:00
Lorn Potter
acfcd1e61f wasm: Replace depreciated --embind compiler argument
As of Emscripten 3.1.3, the --embind compiler argment has been
depreciated for -lembind

Change-Id: Iac5bc21602f27fda7c1ea6814a1c9525b9a5afab
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-06-02 19:11:58 +10:00
Morten Sørvig
86103f3af5 wasm: don't enable specialHTMLTargets by default
Adding specialHTMLTargets to EXPORTED_RUNTIME_METHODS carries the
obligation to actually use it as well; failing to do so makes Emscripten
stop with a reference error on startup.

However, we can't guarantee that Qt will use it in all cases. The
current usage depends on QGuiApplication being used. Application code
could be using QCoreApplication, or no application object at all.

Detect if specialHTMLTargets is present instead, and then enable the code
paths which uses it if that's the case. This means that apps which want
to use e.g. multiple browser windows can opt into support by making sure
EXPORTED_RUNTIME_METHODS contains specialHTMLTargets.

Change-Id: I81105aa01946602fcf593f170e305d7dc9bad3be
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-06-01 13:52:47 +02:00
Ville Voutilainen
5431b40ee8 Avoid some new clang 14 warnings on Android NDK 24 build
Task-number: QTBUG-99663
Change-Id: I1aa408ba468342e2fac2323ae91ff650b871c563
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-05-27 17:28:37 +03:00
David Skoland
1a0eb4fa01 Adjust installing and running wasm-testrunner
Added a small helper function that also installs the script to
prefix builds. Additionally, leveraging the cmake option
CROSSCOMPILING_EMULATOR for the testrunner fits neatly in the rest
of our cmake code.

Change-Id: I75288e97c81b250ac3997f2e7a22bc7bd82b7b69
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-05-27 14:50:17 +02:00
Lorn Potter
e3757df526 wasm: update emscripten to 3.1.10
Qt 6.4 will require Emscripten 3.1.10

Change-Id: I34d6288489b6674f6fd75134dd1855ae931c79c2
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: David Skoland <david.skoland@qt.io>
2022-05-27 17:46:29 +10:00
Alexandru Croitor
55eb94cdbd CMake: Use the PRODUCT_NAME for the iOS display name like qmake
This ensures that the Xcode 'Display name' input under
${target} -> General -> Identity -> Display name is not empty.

Because adding ${PRODUCT_NAME} directly in the Info.plist.in template
will cause CMake to evaluate it as variable expansion, work around the
issue by putting the dollar sign into a separate cache variable that
after evaluation will result in ${PRODUCT_NAME} being in the file
verbatim, so that Xcode evaluate it at build time.

Amends 4d838dae5a

Pick-to: 6.2 6.3
Task-number: QTBUG-95838
Change-Id: I2d1090cc8e84b32442f7daca2d4ce5e3ad413c68
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-05-20 13:06:06 +02:00
Alexandru Croitor
c0188b2dbd CMake: Fix issue with linking against static library on iOS
Currently our iOS CMake toolchain file sets the global
XCODE_EMIT_EFFECTIVE_PLATFORM_NAME property to OFF, to work
around a CMake issue regarding usage of object libraries in
conjunction with Xcode. The error was

 The OBJECT library type may not be used for IMPORTED libraries under
  Xcode with multiple architectures $(CURRENT_ARCH)

While this got rid of the error, it introduced a regression where
linking an executable against a static library in the same project
failed due to the library not being placed in a directory where Xcode
expects it to be.

 clang: error: no such file or directory:
  '~/build-untitled4-Qt_6_0_2_for_iOS/Debug/libuntitled4.a'

The actual library is created in Debug-iphoneos/libuntitled4.a
Note the -iphoneos suffix, which is related to the
EFFECTIVE_PLATFORM_NAME.

This could be further worked around by either explicitly setting the
library ARCHIVE_OUTPUT_DIRECTORY property in the project, or flipping
the value of the XCODE_EMIT_EFFECTIVE_PLATFORM_NAME to ON at the
end of the project. Both workarounds are not project-friendly.

In the mean time CMake got a fix for the original error
at https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5771
which got released with CMake 3.20.0.

That was unfortunately not sufficient to remove our initial
workaround, because removing it would trigger a different
error at generation time

CMake Error:
  Error evaluating generator expression:
    $<TARGET_OBJECTS:Qt6::Quick_resources_1>
  The evaluation of the TARGET_OBJECTS generator expression is only
  suitable for consumption by CMake (limited under Xcode with multiple
architectures). It is not suitable for writing out elsewhere.

Fortunately, another fix landed in CMake 3.21.0 to address that
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/6161

Because static builds (iOS) require CMake 3.21, with both of these
fixes we can now remove our workaround.
Even projects that set ARCHIVE_OUTPUT_DIRECTORY or flip
XCODE_EMIT_EFFECTIVE_PLATFORM_NAME to ON still continue to work
fine.

This also fixes installation of libraries, which also took into
account the effective platform name and thus caused a mismatch between
the expected output dir and the real one.

This reverts 1e1805ed36

Pick-to: 6.2 6.3
Fixes: QTBUG-93268
Fixes: QTBUG-95381
Task-number: QTBUG-87198
Change-Id: Ifcaf0f89e4328ae9859c596882ce32401fa491c3
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-05-20 13:06:03 +02:00
Alexandru Croitor
a3917126e8 CMake: Automatically use Xcode generator in qt-cmake + iOS
When calling qt-cmake on the command line, we don't usually force
usage of a particular CMake generator and defer to the user's choice
or CMake's default for the host OS.

In the case of iOS, the generator that makes the most sense to use is
Xcode. One could also use Ninja / Unix Makefiles if the project
is only building static libraries, but for shared libraries and
executables the project likely needs the code signing
provided by xcodebuild.

When targeting iOS, use a different qt-cmake file template.

The iOS-specific shell script will set the CMAKE_GENERATOR environment
variable to 'Xcode'.
If no -G or -D CMAKE_GENERATOR is provided on the command line then
the project will use the Xcode generator. Otherwise the generator
given on the command line takes precedence.

The CMAKE_GENERATOR environment variable from the parent process is
completely ignored.

The logic is only done for iOS, to reduce the likeliness
of breaking the qt-cmake script for other platforms.

Note that Qt Creator does not use qt-cmake, but rather calls cmake
directly with additional options like the toolchain file,
architecture, sysroot, etc.

[ChangeLog][iOS][CMake] qt-cmake now defaults to using the Xcode
generator when targeting iOS projects.

Pick-to: 6.2 6.3
Fixes: QTBUG-100834
Change-Id: I39b3dce47cc9ee2f98678631e4bd035c59c65294
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-20 13:06:00 +02:00
Li Xinwei
9539c8a7f8 CMake: set correct COMPILE_PDB_NAME for static libraries
Output names of static libraries might be different from target names.
For example, the library name of Qt6::DeviceDiscoverySupportPrivate is
"Qt6DeviceDiscoverySupport.lib", and the library name of
Qt6::QTlsBackendCertOnlyPlugin is "qcertonlybackend.lib".
This commit make pdb files names consistent with the library names.

And make sure we have set correct OUTPUT_NAME property before calling
qt_set_common_target_properties()/qt_internal_set_compile_pdb_names().

Change-Id: Idb3cacd7a46a4f298fd584b927b5d726956faea8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-20 17:41:20 +08:00
Tinja Paavoseppä
9af1f3557a Add option to not include native libraries in APK
Sometimes it is not desirable to include the libraries in the APK,
e.g. system and vendor apps could prefer having one set of libraries
installed on the device. If unbundled deployment is specified,
native libraries will not be included in the APK.

With unbundled deployment, optional arguments can be passed to
set the path to load the libraries on the device.

[ChangeLog][Android][Deployment Changes] Adds option for Unbundled
deployment, where native libraries are not packaged in the APK.

Task-number: QAA-771
Change-Id: Ica51ef83a24dad58c7586bf610a58abe21fc1100
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-05-20 08:08:02 +03:00
Alexey Edelev
38bb294fb7 Avoid using add_custom_command with PRE_LINK for version script
add_custom_command with PRE_LINK doesn't work correctly with
Multi-Config builds. The better solution is to introduce a custom
target that generates the final version script and link the target to
the library target as the dependency.

Change-Id: Ib7420af752a6a46f29f411f9f0dc8557410b4f22
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-05-19 15:34:26 +02:00
Joerg Bornemann
6dffc1c438 CMake: Fix line endings of wrapper scripts
If QT_GENERATE_WRAPPER_SCRIPTS_FOR_ALL_HOSTS is ON then we generate
Windows scripts on Unix and vice versa.  We always used the host
platforms line endings for generating the scripts.  This leads to
Windows line endings in Unix scripts and vice versa.

Explicitly specify the line endings style when generating wrapper
scripts.

Fixes: QTBUG-102747
Pick-to: 6.2 6.3
Change-Id: I1603add46f276a5d91bbf0f103a261cdd84c343b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-05-17 11:09:19 +02:00
Lucie Gérard
05fc3aef53 Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.

Task-number: QTBUG-67283
Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-16 16:37:38 +02:00
Alexandru Croitor
f4e9981259 CMake: Fix static library link order when using qmake
qmake adds QMAKE_PRL_LIBS values on the link line after the currently
processed library. Because CMake adds resource object files into
QMAKE_PRL_LIBS, they end up on the link line after the library.
This causes issues on Linux with GNU ld and ld.gold, because the
linker discards symbols from the library which are then later referenced
by the object files.

Work around that by placing the path to the library directly into
QMAKE_PRL_LIBS after the resource object files.
This ensures the linker doesn't discard the symbols required by the
resource object files.

This means that each library encountered in qmake's LIBS variable will
be temporarily referenced twice in qmake's project state: once from
LIBS / QMAKE_PRL_TARGET, and once when the QMAKE_PRL_LIBS values are
added. On the link line it will appear only once though, because qmake
does library deduplication during prl file processing, which only keeps
the last occurrence.

Amends 4ab5432081

Pick-to: 6.2 6.3
Fixes: QTBUG-103002
Change-Id: I97647b64de22b158424850915fee62b5fea5f995
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-05-12 21:45:59 +02:00
Alexey Edelev
a3e13cdacf Use full file path for the generated dbus files
Change-Id: Idb7cb49800eaef4a2e09d3e03d2e44528d992d75
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-05-12 16:34:25 +02:00
Morten Sørvig
b119f26a56 wasm: enable WASM_BIGINT
JavaScripts's BigInt feature provides support for arbitrary-precision
integers. This makes it possible to represent 64-bit integers; the
standard JS Number type supports 32-bit integers only (or more
accurately 53-bit integers - see Number.MAX_SAFE_INTEGER).

Enable WASM_BIGINT which makes Emscripten map int64_t and uint64_t
to BigInt when interfacing with JavaScript code.

This removes one of the conditions which enables
wasm-emscripten-finalize.

Task-number: QTBUG-103352
Change-Id: Ia70d599daaf34c92695f5a2b61665e0c237e6b95
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Reviewed-by: David Skoland <david.skoland@qt.io>
2022-05-12 16:34:24 +02:00
Morten Sørvig
bd8d3fb47c wasm: set ASSERTIONS level to default (1)
This removes one of the conditions which enables
wasm-emscripten-finalize.

Task-number: QTBUG-103352
Change-Id: Id05db4b081dec360cdad2e611622e5baf09aeb23
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: David Skoland <david.skoland@qt.io>
2022-05-12 16:34:24 +02:00
Dmitry Shachnev
e2a8b0adbd Hardcode atomic_LIB as -latomic
find_library does not always work because libatomic.so may be in a path
like /usr/lib/gcc/x86_64-linux-gnu/11/libatomic.so, which CMake does not
consider by default.

Pick-to: 6.3
Change-Id: I73a657c470efa4f84f8629bd531edfcac3b3a352
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-12 17:34:24 +03:00
Alexandru Croitor
ff0ee3d985 CMake: Handle strip wrapper creation more robustly
Unsetting CMAKE_STRIP and including CMakeFindBinUtils to find it again
is not safe, because CMakeFindBinUtils has logic to search for
additional tool names depending on the currently processed language.

The currently processed language is set in _CMAKE_PROCESSING_LANGUAGE
only when CMake is doing it's language introspection via
CMakeCXXCompiler.cmake.

This resulted in the build system finding a regular host-OS strip,
rather than an android specific llvm-strip when doing an Android
build, which then silently failed to strip the Android libraries
and caused us to ship big binaries.

Improve the strip wrapper creation in a few ways:
- Save the original strip value on first configuration
- Restore it if needed, without using CMakeFindBinUtils
- Don't apply the strip wrapper creation logic to Android,
  we currently don't need it there
- Add some informational messages about which CMAKE_STRIP
  ends up being used even if log-level is not DEBUG
- Fix a typo

Amends 39f657032b

Pick-to: 6.2 6.3
Fixes: QTBUG-103356
Task-number: QTBUG-101653
Change-Id: I23d98180446d5bb7628e783668f46e4e546ed700
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-05-11 18:53:37 +02:00
Joerg Bornemann
7f94aa23f5 CMake: Fix initialization of QT_BUILD_TOOLS_BY_DEFAULT
...when QT_BUILD_TOOLS_WHEN_CROSSCOMPILING is ON.

When QT_BUILD_TOOLS_WHEN_CROSSCOMPILING is ON, we want to set
QT_FORCE_BUILD_TOOLS.  But this happened too late: after the
initialization of QT_BUILD_TOOLS_BY_DEFAULT.  This value depends on
QT_FORCE_BUILD_TOOLS.

This amends commit acfbe3b779.

Change-Id: Ibdba54da943aea1b55618f10d2b8485f4390878a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-05-11 18:53:37 +02:00
Alexey Edelev
f087e63bf5 CMake: Make possible building Qt tools without the use of core library
Replace BOOTSTRAP option with the single value CORE_LIBRARY argument
in qt_internal_add_tool and qt_internal_add_executable functions.
The introduced argument now may accept 'Bootstap' and 'None' values.
Use 'Bootstap' to link Qt::Boostrap library instead Qt::Core or 'None'
to avoid any core library linking. This is useful for tools that need
to use the CMake deployment routines, but not require the Qt::Core
functionality.

Task-number: QTBUG-87480
Change-Id: I64a8b17f16ac5fe43c6b385252dc21def0c88d2c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-05-06 22:06:22 +02:00
Thiago Macieira
acfbe3b779 CMake: also allow building tools when found elsewhere in host builds
Previously, this was only supported when cross-compiling, but that's an
unnecessary limitation. Instead, make it possible to build the "host"
tools (notably qmake) even when they've been found elsewhere due to
QT_FORCE_FIND_TOOLS=ON and a supplied QT_HOST_PATH.

The combination of QT_FORCE_FIND_TOOLS and QT_FORCE_BUILD_TOOLS set to
ON is useful for developers who touch content that ends up in the
bootstrap library.

QT_BUILD_TOOLS_WHEN_CROSSCOMPILING is deprecated in favor of
QT_FORCE_BUILD_TOOLS.

[ChangeLog][CMake] QT_BUILD_TOOLS_WHEN_CROSSCOMPILING has been
deprecated in favor of QT_FORCE_BUILD_TOOLS. The latter can be used in
combination with QT_FORCE_FIND_TOOLS and QT_HOST_PATH to use tools from
a host Qt even for a non-cross build and still build the tools.

Fixes: QTBUG-99683
Change-Id: I0e5f6bec596a4a78bd3bfffd16c8fb486181f9b6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-05-04 15:20:35 +02:00
Joerg Bornemann
687f22671f CMake: Fix typo in error message
Pick-to: 6.2 6.3
Change-Id: Iace4fe19c0bdbcb61f667363d86b22abf6ec7d24
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-05-02 23:24:41 +02:00
Alexey Edelev
40ba4b2437 Add qpa include directory to the return values of qt_internal_module_info
Change-Id: I0540ce70e4a5dbde4027d97d9308c61248230c96
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-05-02 12:03:42 +02:00
Allan Sandfeld Jensen
c164b75c17 Pass compilers on to examples configs
Otherwise they will just use default compiler

Pick-to: 6.3
Change-Id: Id5813b99fbbb6b0d8b0ee658e06312b637a097c1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-04-26 22:58:56 +02:00
Alexandru Croitor
7616e4aecf CMake: Handle detection of linux-g++-32 mkspec
If Qt is configured with -platform linux-g++-32 , make sure
to add the -m32 compile options for all built targets.

On 64 bit host OSes that provide both 32 and 64 bit libraries
we need to exclude the 64 bit libraries from being picked up.
The locations of the libraries are distro-specific.

This change by default excludes the Ubuntu x86_64 libraries
paths.
Opt outs are provided, which when used, forces Qt builders to
specify their own ignore paths in a custom CMake toolchain file.

The compile option and default path exclusions are added to the
Qt-generated CMake toolchain file as well, so they are reused
when building other Qt repositories.

Note that there is no foolproof way to tell CMake to ignore all
x86_64 packages / libraries, even if CMake 3.23
CMAKE_IGNORE_PREFIX_PATH is used, because there might not be
a single sysroot to exclude.
Both x86 and x86_64 libraries can co-exist in the same sysroot,
e.g in /usr

One would have to list each package / library directory in
CMAKE_IGNORE_PATH manually.

Additionally, the PKG_CONFIG_LIBDIR environment variable is also set
to Ubuntu specific prefixes, to ensure that pkg_check_modules ->
pkg-config don't pickup x86_64 libraries.

Fixes: QTBUG-101963
Change-Id: Ib17c8d2cd0ba33b2cf748772245bcd558de9120c
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-04-25 15:42:19 +02:00
Kai Köhne
48561178e2 zlib as static library
Do build zlib as static 3rdparty library. This makes it easier to
disable warnings.

Pick-to: 6.3
Change-Id: I1db331b671b64e68d81c56b0df337983c3bbe7fa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-04-22 14:34:47 +02:00
Alexandru Croitor
dc4bc1e575 CMake: Fix interleaved configure output
message(STATUS) prints output to a buffered stdout, whereas
message(NOTICE) or just message() print to unbuffered stderr.

We use a mix of message() calls when printing the configuration
summary, which caused interleaved output.

Because CMake offers no message(FLUSH), we work around the issue
by calling execute_process(COMMAND -E echo " ") which does
call std::cout << s << std::flush;

We seem to have to do it twice, before and after the
detailed configuration summary is printed.

Pick-to: 6.2 6.3
Change-Id: Ibc075551fc0547073f0696477e54d9b9c1edca97
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-04-22 14:34:47 +02:00
Alexandru Croitor
8a56b4ad9b CMake: Embed an empty qt_prfxpath if Qt is relocatable
When Qt is configured as relocatable,
 QT_CONFIGURE_PREFIX_PATH_STR -> qt_configure_prefix_path_str ->
 qt_prfxpath
is not used in relevant code paths.

Specifically qlibraryinfo.cpp getPrefix() uses getRelocatablePrefix()
instead of QT_CONFIGURE_PREFIX_PATH.

Thus, when Qt is configured as relocatable, set qt_prfxpath to an
empty string.
This avoids embedding a CI path like /home/qt/work/install into the
official packages, which makes reproducible builds a closer reality.

Change-Id: I9209b08e651ad0b7fdc4049df333e0978e05f1f5
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-04-22 14:34:47 +02:00
Alexandru Croitor
251033fb0a CMake: Work around build rpath issue when CMAKE_STAGING_PREFIX is set
CMake has logic to rewrite build rpaths that contain
CMAKE_STAGING_PREFIX to instead point to CMAKE_INSTALL_PREFIX.

This breaks running executables from the build directory, because
their build rpath will point to a location where the libraries might
not exist yet (we didn't install Qt yet).

Work around this by setting CMAKE_STAGING_PREFIX to a fake path, so
that CMake does not do the rewriting anymore.

CMAKE_STAGING_PREFIX needs to be set at subdirectory scope, not
function scope, which is why
qt_internal_apply_staging_prefix_build_rpath_workaround() is a macro
that is called from within each Qt internal function that creates
a target.

The workaround can be disabled by configuring with
-DQT_NO_STAGING_PREFIX_BUILD_RPATH_WORKAROUND=ON

The downside of this workaround is that it breaks per-subdirectory
install rules like 'ninja src/gui/install'.
Regular global installation like 'ninja install' works fine.

This is similar to what we do for tests in
qt_set_up_fake_standalone_tests_install_prefix()
introduced by 20292250d4
The reason it's not as good for other target types is because in
contrast to tests, we do want to install them.

In case if someone does call `ninja src/gui/install' they will most
likely get a permission error, telling them it's not possible to
install into
/qt_fake_staging_prefix/
 check_qt_internal_apply_staging_prefix_build_rpath_workaround

Fixes: QTBUG-102592
Change-Id: I6ce78dde1924a8d830ef5c62808ff674c9639d65
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-04-22 14:34:47 +02:00
Lorn Potter
3de6cd9bd1 wasm: add specialHTMLTargets to EXPORTED_RUNTIME_METHODS for qmake
The change
0ec75f4b99
missed adding specialHTMLTargets for qmake

Also add warning to keep QtWasmHelpers in sync with qmake.conf

Change-Id: Idb363e77f0cecb4f125d3cb4f7507899149a3bac
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-04-21 13:00:57 +10:00
Alexandru Croitor
a1d8b9023f CMake: Disable CMAKE_INSTALL_RPATH_USE_LINK_PATH
There should be no need for CMake to add rpaths pointing to
directories outside of the build tree to the installed libraries.
All relevant install rpaths are handled by qt_apply_rpaths().

Change-Id: If554b1e3c790c2bb04a34e8b0524aab3febf5afc
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-04-19 17:20:14 +02:00
Alexandru Croitor
8254ee6a3b CMake: Fix implementation of qt_apply_rpaths
There were a few things that were not ported correctly.

Make sure to disable rpath manipulation if the rpath feature is
disabled.

Fix if(IS_ABSOLUTE) conditions to actually take values.

Don't embed bogus relative rpaths if the platform does not support
it. QNX is such a platform, it does not support $ORIGIN (at least from
my scouring of QNX documentation and manual testing via QEMU).

Handle the extra rpath case where they are relative, but the platform
does not support relative rpaths, by transforming them into absolute
ones.

Amends 67ee92f4d8

Change-Id: I04168633ec51b3cc5d580b738a7dc280fe6e0d2d
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-04-19 17:20:14 +02:00
Alexandru Croitor
e28a32ea45 CMake: Sync rpath documentation with the current implementation
Pick-to: 6.2 6.3
Change-Id: Id3af1cdfd66cd9527ab76137d72e354edfc3de75
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-04-19 17:20:14 +02:00
Alexandru Croitor
e327ed191c CMake: Print prefix info when building qtbase
Pick-to: 6.2 6.3
Change-Id: Ib76d94b1c51f99d5ce007d463d97b5d2b256d2bf
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-04-19 17:20:14 +02:00
Alexandru Croitor
5059f7adc2 CMake: An -extprefix -developer-build should install by default
Previously if
 -extprefix /tmp/sysroot (CMAKE_STAGING_PREFIX)
 -developer-build (FEATURE_developer_build)
were specified, but
  -prefix (CMAKE_INSTALL_PREFIX)
was not,
the build system would set the CMAKE_INSTALL_PREFIX to the
qtbase build dir.

Then, if targeting desktop, this would be considered a non-prefix
build (ninja install would refuse to work), whereas in a cross-build
it would be considered an installable build.

In both cases though, the rpath of installed binaries would point to
the qtbase build dir (because CMAKE_INSTALL_PREFIX would be set to the
qtbase build dir).

This is quite confusing behavior, in more than one way.

Change the build system to consider that an explicit -extprefix should
cause Qt to always be installed, even if -developer-build is
specified.

This means the installed rpaths and on-device install prefix
(CMAKE_INSTALL_PREFIX) will now use the default computed install
prefix, e.g. /usr/local/Qt

It also means that to get a non-installable developer + custom staging
and install (on-device) prefix build, users will have to be explicit
and set all the options
 -extprefix ~/qt/qtbase_build_dir
 -prefix /usr
 -developer-build

Pick-to: 6.2 6.3
Change-Id: Ib560452a4b4778860e0fd7666c76f8a6745773ee
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-04-19 17:20:14 +02:00
Alexandru Croitor
f3483e6b96 CMake: Allow no install + custom on-device prefix for desktop builds
Allow such a combination
- staging prefix (CMAKE_STAGING_PREFIX / -extprefix) set to the
  qtbase build dir
- install prefix (CMAKE_INSTALL_PREFIX / -prefix / on-device prefix) set
  to some custom location
even for non-cross builds.

An example would be
    configure -prefix    /usr \
              -extprefix ~/qt/qtbase_build_dir

CMake will put the Qt libraries in the qtbase build dir, ninja install
will not be required, but ultimately in order to run applications,
the Qt libraries are expected to be in /usr.

Support for this scenario was originally added for cross-builds in
062318feb2 , but not desktop builds.

Such a build is useful when you want to have install rpaths different
from where Qt is initially installed to (the staging prefix).

This case doesn't really happen often when targeting desktop
platforms, it's mostly used for cross-compilation (e.g yocto).

Being able to have the same setup with a desktop build is nevertheless
useful for faster iteration on build system issues in such a scenario.

Amends 062318feb2

Pick-to: 6.2 6.3
Change-Id: I42be3628a30025f14eebaf0a79401b54e95cde26
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-04-19 17:20:14 +02:00
Tor Arne Vestbø
857264715a configure: Add newline between configure summary and build instructions
Otherwise we get:

    Styles ................................. Basic Fusion Imagine iOS
    Material Universal macOS Windows
    -- Qt is now configured for building. Just run 'cmake --build .
    --parallel'

Pick-to: 6.2 6.3
Change-Id: Ie8d009455e4f45c9eb0557c4a08e9d0a94030c3a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-04-19 12:46:18 +00:00
Moody Liu
4088b27b93 Explicitly check for atomic addition and relaxed load operation support
...and properly find and link against `libatomic` using find_library.
This fixes the qtdeclarative build on the RISC-V platform.

Initial-patch-by: Sprite <SpriteOvO@gmail.com>
Pick-to: 6.2
Pick-to: 6.3
Task-number: QTBUG-99234
Change-Id: I2b5e4812886ce45cb02bed3106ce8c519b294cbe
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-04-18 15:01:53 +00:00
Lorn Potter
0ec75f4b99 wasm: use emscripten::val for specialHTMLTargets
We need to add specialHTMLTargets to EXPORTED_RUNTIME_METHODS in order
to use it, as Emscripten does not export it.

Also, EM_ASM is not allowed for SIDE_MODULES, so it's better to use
emscripten::val methods.

Change-Id: I9b352ac98e2a961157f5bb36456bec3e35891270
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-04-15 21:06:32 +10:00
Morten Sørvig
28e0c938bf wasm: remove SAFE_HEAP=1
This adds significant run-time overhead and should not be on by default.

Pick-to: 6.3
Change-Id: I33d312e31bd714f696d8acf2066eb4b285ff04af
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-04-13 00:26:09 +00:00
Alexey Edelev
8eef32d460 Suppress cmake warning about empty string argument
When generating .pc files there is a warning when executing
QtFinishPkgConfigFile.cmake:

  Ignoring empty string ("") provided on the command line.

This happens because the 'postfix' argument is a part of the script
command line even if it's empty. It also makes no sense to check if
'postfix' is empty using genex, use configuring-time check instead.

Pick-to: 6.2 6.3
Change-Id: If52d9634f4885caefb828976b3c99592a6db3d3c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-04-12 04:57:14 +00:00
Jonas Kvinge
1007aac63a Fix check for pcre2 using cmake
When PCRE2 is compiled using cmake, a pcre2 cmake file is installed
and Qt fails to configure because components isn't specified for
find_package.
In recent PCRE2 releases components needs to be specified for
find_package.

Fixes: QTBUG-102358
Pick-to: 6.2 6.3
Change-Id: Ib842b2c4b1c0bf38aa5da5475eaa2b3c56c6b822
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-04-08 13:03:30 +02:00
Alexey Edelev
6569a4068b Map the 'verbose' configure option to CMake
Raise the CMake log level to STATUS when the 'verbose' argument is
passed to the configure script.

Change-Id: I736d95ab66b115f8416eec7f9e2ee96d1580c78d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-04-06 16:46:59 +02:00
Yuhang Zhao
42287255d3 Build system: Allow user to enable Intel CET
MSVC:
https://docs.microsoft.com/en-us/cpp/build/reference/guard-enable-eh-continuation-metadata?view=msvc-170
https://docs.microsoft.com/en-us/cpp/build/reference/cetcompat?view=msvc-170

GCC:
https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Instrumentation-Options.html

Clang:
Don't know where's the documentation but should use
the same parameter with GCC.

Change-Id: I654618e45743a5ad1394c930932b9d0044572725
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-04-06 13:06:24 +08:00
Tatiana Borisova
8116fdde1c Reorganize work with graphical libraries on INTEGRITY
- Currently we manually unpack all platform libraries,
  that are required for GUI apps, and pack it into single eglmegapack.a library.
  It could be better do not execute such additional step,
  but have possibility to add required graphical libs
  to cmake interface lib via toolchain file list variable.

Pick-to: 6.2 6.3
Change-Id: Ic4122600f02e6828d528ee4f00075f8c27f42e38
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-04-05 17:27:15 +03:00
Alexandru Croitor
9a18facc66 CMake: Allow specifying custom install dir for non-EP examples
Originally, QT_INTERNAL_EXAMPLES_INSTALL_PREFIX was added to
control the installation of examples when they are built as
ExternalProjects, and was not considered for the non-EP case because
we hoped to switch entirely to EP-based building.

Due to some unsolved issues regarding using EP builds in CI, add the
ability to control the installation of non-EP examples.

This will be used in the CI to allow removing the hacky
INSTALL_EXAMPLEDIR and INSTALL_EXAMPLESDIR assignments in example
projects.

It is also likely that we will not deprecate the non-EP based
building, because it is useful for IDE integration (EP targets
are not as developer-friendly to work with in an IDE in regards
to rebuilding).

Amends 98c89c8cc1

Pick-to: 6.2 6.3
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I02264aaa1daa2c80bb9ef3d02b1831b4ca5d2b84
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-04-04 15:41:20 +02:00
Alexandru Croitor
33f631920f CMake: Rename QT_INTERNAL_CUSTOM_INSTALL_DIR
to QT_INTERNAL_EXAMPLES_INSTALL_PREFIX so it's clear that the
variable only affects the location of where examples
are installed.

And make sure the paths are passed as CMake paths.

Amends 1031fa1547

Pick-to: 6.2 6.3
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: Ib92c55488b736d980da2bd88255de78e183de824
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-04-04 15:41:20 +02:00
Alexandru Croitor
c926ef55de CMake: Allow passing -v to ninja when building examples as EPs
By default when building ExternalProjects, even if the main ninja
invocation has -v passed, that won't be passed to the nested ninja
calls.

When building examples in the CI, we want to see the full command line
invocations.

Allow passing -v to the nested EP ninja calls by configuring Qt with
-DQT_INTERNAL_VERBOSE_EXAMPLES=ON, which we will use in our CI.

We don't want to add -v by default because if the main ninja does not
have one, the nested calls will still be verbose.

Pick-to: 6.2 6.3
Change-Id: Ifd4b312c6eaa7354e8870f4fb0a77fadf0f33ab7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-04-04 15:41:20 +02:00
Alexandru Croitor
2061cea0f3 CMake: Pass -v to ninja when using ctest --build-and-test
So we can see the command line invocations of the built cmake
auto tests.

To achieve that, we create a ninja shell script wrapper, because
ctest --build-and-test does not currently allow specifying custom
build tool options.

Details at
https://gitlab.kitware.com/cmake/cmake/-/issues/22443

Pick-to: 6.2 6.3
Change-Id: I7fb3b7f7f802943a7013c859b2cf39842a34e2e4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-04-04 15:41:20 +02:00
Alexey Edelev
a42e7839b2 Make possible to set android SDK/NDK roots from environment
Read the ANDROID_<SDK|NDK>_ROOT environment variables in qt toolchain
file and use them to chainload the android toolchain file.

Pick-to: 6.2 6.3
Change-Id: I1940ffbaa557974fc26005f4d051030f2cc5c7e0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-04-04 15:41:19 +02:00
David Skoland
b01ee1d44c Add WASM testrunner
Add a python script that allows us to run wasm tests in CI, along with
the necessary cmake logic to install the script and execute tests
accordingly.

Change-Id: I93b95c115538c4e27b2b833405acab8162be2a8a
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-03-31 16:50:25 +02:00
Tasuku Suzuki
5cbb93adc7 configure: Add mold to help
Pick-to: 6.2 6.3
Task-number: QTBUG-99270
Change-Id: I08ee2b328a1dba2bf0172e5a03ddb32925401d3b
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-31 01:22:02 +09:00
Alexandru Croitor
939a8281e6 CMake: Fix picking of the binary_for_strip project location
Fix binary_for_strip project not being found when the following
conditions were met:
- building a repo other than qtbase
- qtbase sources are not available on the machine
(usually happens in CI where only the current repo sources are
available).

The issue was that QT_CMAKE_DIR would always be defined, regardless of
which repo was being built and the system would incorrectly assume
the location of the project files.

The fix is to always pick up the sources from qtbase's source dir if
they are available (this time done with an appropriate check),
otherwise use the installed files.

Note that the behavior of always using the qtbase sources if available
is not exactly the best, but it is a more general issue that affects
other code too.
In the name of consistency, make it so for the binary_for_strip
project as well, but add TODOs in code to address the situation
in a separate change.

Amends 39f657032b

Pick-to: 6.2 6.3
Fixes: QTBUG-102064
Task-number: QTBUG-88090
Task-number: QTBUG-101653
Change-Id: I0649f945e9ff0ab1f597c51bb5ab389fa665c021
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-03-29 14:56:14 +02:00
Christophe Giboudeaux
8924cc13be CMake: Don't hardcode the library directory name
Using INSTALL_LIBDIR is the only reliable way to get the library install directory.

Amends: d1c56073b4

Pick-to: 6.2 6.3
Change-Id: Ib8c4fb8b4d339c63209393d7fdb3d1c3425b03a4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-29 00:16:54 +01:00
Joerg Bornemann
02e5b0ffda CMake: Fix handling of the CROSSCOMPILING_EMULATOR property
CROSSCOMPILING_EMULATOR is a target property, not a test property.

Fixes: QTBUG-87864
Pick-to: 6.2 6.3
Change-Id: Icb07e9ed71a6bcbfceb7aa2116bf56eaa0a545c6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-25 22:43:49 +01:00
Alexandru Croitor
b34ed061e3 CMake: Fix typo in configuration summary message
Amends 384dfceb53

Pick-to: 6.2 6.3
Change-Id: Ica36551b64899848ab40e507ddf002af55b7db8c
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-03-25 16:19:20 +01:00
David Skoland
8413c06e2e Disable SAFE_HEAP_LOG for wasm
This option completely ruins the output when running test, as it logs
every single safe heap operation. I don't think this detailed logging
is necessary or reasonable in a normal debug build.

Pick-to: 6.3
Change-Id: I4bb740299d631d21453f9b4a8959634801fb3a1e
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-03-25 16:19:20 +01:00
Alexandru Croitor
39f657032b CMake: Generate and use a wrapper script for stripping binaries
MinGW 11.2.0 comes with a strip.exe that strips the ".gnu_debuglink"
section in binaries, a section that is needed for the separate debug
information feature.

binutils version 2.34 mentions the feature for the first time:
https://sourceware.org/binutils/docs-2.34/binutils/strip.html#strip

To ensure the debuglink section is preserved, generate a shell wrapper
that calls the original strip binary with an extra option to keep the
required section.

To determine if the option is supported, we build a real shared library
on which strip will be called with the --keep-section option.
If the option is not supported, a wrapper is not generated and the
stock strip binary is used.

This logic only applies when targeting Linux and MinGW + a shared
library Qt. For other targets, the stock strip binary is used.

Developers can opt out of this logic by passing
-DQT_NO_STRIP_WRAPPER=TRUE when configuring each Qt repo.

Pick-to: 6.2 6.3
Fixes: QTBUG-101653
Change-Id: Idd213d48d087d3c9600c853362aebaba348cde33
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-03-24 21:50:50 +01:00
Alexandru Croitor
70c3dd4a54 CMake: Enable verbose autogen for cmake auto tests and EP examples
So we can see the exact moc invocations when debugging issues in the
CI.

For ExternalProject examples, it is conditional on whether Qt is
configured with QT_INTERNAL_VERBOSE_EXAMPLES set to ON, otherwise
calling the main ninja without -v will end up cluttering the output
with AUTOGEN output.

Pick-to: 6.2 6.3
Change-Id: I6468ab0e461b3be283e2428e3515cae4d5986242
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-03-24 21:50:50 +01:00
Alexandru Croitor
64d5708458 CMake: Enable debug verbosity for cmake auto tests and EP examples
Since e2a0ddbb69 , if Qt is configured
as a non-developer-build, some of the CMake tests that include QtSetup
would have their CMAKE_MESSAGE_LOG_LEVEL set to the reduced NOTICE
value.
Make sure that tests always have a DEBUG level, so that if they fail
in the CI, we have more info on what goes wrong.

For ExternalProject examples, it is conditional on whether Qt is
configured with QT_INTERNAL_VERBOSE_EXAMPLES set to ON, otherwise
calling the main ninja without -v will end up cluttering the
output a non default log level.

Amends e2a0ddbb69

Pick-to: 6.2 6.3
Change-Id: Icd3b6e0fcc6c73e4b53b6c4a6d8354c96077a050
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-03-24 21:50:50 +01:00
Alexandru Croitor
384dfceb53 CMake: Mention where the configure summary can be found
when configuring for the first time.

Also mention how to increase output verbosity.

Unfortunately there is no way to check what is the current log
verbosity to only show the latter message conditionally.
Setting --log-level does not assign the same value to
CMAKE_MESSAGE_LOG_LEVEL.

Amends e2a0ddbb69

Pick-to: 6.2 6.3
Change-Id: I22101b9dc7c407cc54aa5e7964dec50c7490f8f5
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-03-23 19:09:21 +01:00
Pasi Petäjäjärvi
5c85b0c7a4 CI: QNX qemu need docker service ports explicitly defined for visibility
Network autotests cannot connect to services on docker containers from
QNX qemu without all ports explicitly defined (both host and container)
side.

Pick-to: 6.2 6.3
Task-number: QTQAINFRA-4684
Change-Id: Iba44cfa17d42d43ecec3e29985e404f75d5fc232
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
2022-03-21 22:30:01 +02:00
Alexey Edelev
ea30708972 Install QtCopyFileIfDifferent as the 'public' cmake helper
QtCopyFileIfDifferent needs to be both installed and copied to a build
folder as a public CMake helper. Otherwise it's not found when building
tests inside the Qt build tree.

Pick-to: 6.2 6.3
Fixes: QTBUG-101916
Change-Id: I8d081e594fe694f528ebac4c13bbdf6d3b8402b9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-21 21:16:14 +01:00
Janne Juntunen
64847af6e6 QtPlatformSupport: add support for detecting webOS
Some autotest CMakeLists.txts need to know whether the target is webOS.
This change enables that.

Task-number: QTBUG-101933
Pick-to: 6.3
Change-Id: I7b4ebe89622a4ad8bc313e807d9fa50152c96d14
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-21 21:36:23 +02:00
Alexey Edelev
68c0e932a5 Unify DEPFILE support check
Add common function that unifies the check for the DEPFILE support.
Update the check according to the recent CMake version.

Task-number: QTBUG-99354
Change-Id: Ia2abf46fe3a9a3d17ea7a37eaf6c9c6a697c5b84
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-21 12:39:49 +01:00
Alexandru Croitor
b858704e1f CMake: Mitigate moc not finding correct headers in framework builds
When CMake generates compilation rules, it extracts the values from
INTERFACE_INCLUDE_DIRECTORIES and checks if any of the values
are framework paths.
If they are, instead of adding an -I ./lib/My.framework to the
compilation rules, it adds -iframework ./lib or -F ./lib.

The same transformation does not happen when AUTOMOC passes include
paths to moc, nor during a headersclean check. The values there
are passed verbatim, with an -I prepended.

This causes issues when the include file name is the same as the
framework name.
E.g. #include <QtQml> + -I ./lib/QtQml.framework because moc
then ends up silently including the shared library
 ./lib/QtQml.framework/QtQml
instead of the header
 ./lib/QtQml.framework/Headers/QtQml

This can lead to a variety of silent issues during moc generation,
because all the definitions of QtQml will be missing.

Unfortunately, there does not seem to be a clean way to fix this in
the build system due to CMake semantics.
See https://gitlab.kitware.com/cmake/cmake/-/issues/23337 for details.

We can mitigate the issue by ensuring that
 -I ./lib/QtQml.framework/Headers
comes before
 -I ./lib/QtQml.framework

by manipulating the order of values in INTERFACE_INCLUDE_DIRECTORIES.

We might want to consider implementing an additional mitigation in
AUTOMOC, so that it filters out include paths like
 -I ./lib/QtQml.framework, thus ensuring that a newer CMake version
will not exhibit the same issue when used with an older Qt.

We could consider doing the same in moc. The advantage of doing it
in moc is that that moc will consider fewer invalid include paths
when searching for headers.

Amends 4b2de41b13
Amends d7efb2a419

Pick-to: 6.2 6.3
Fixes: QTBUG-89545
Fixes: QTBUG-101718
Fixes: QTBUG-101775
Change-Id: Ib2c25b5744bd2b5c9c83813bb04ad88c0179f6ec
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-18 08:08:52 +01:00
Mårten Nordheim
71edd2e4d8 Bump QT_DEPRECATED_WARNINGS_SINCE
When building Qt we should have warnings of any internal use
of deprecated API, so set it to Qt7.
Also added comments to clarify what the macros do.

Change-Id: Ib47278fed9ab1ec4411ed9f69a9a9c0f811db02d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-18 07:00:30 +01:00
Alexey Edelev
97ef7752a2 Remove the LINK_LANGUAGE genex condition when generating .pc file
Conditions with the LINK_LANGUAGE genex are not parsed correctly when
generating .pc file. So link options will be added unconditionally.

Amends d1e02c3855

Pick-to: 6.2 6.3
Fixes: QTBUG-101723
Change-Id: Ib837b3f3429d195a469450ef25af9630ad7d15e2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-17 16:25:00 +01:00
Alexey Edelev
8adacba3e6 Add VERBATIM option to add_custom_command calls
Use VERBATIM option to prepare the correct command line for the
add_custom_command. This especially sensitive when using build
directories with names containing special symbols, that cannot be
handled by shell correctly.

Change-Id: I51d7041cb806411135fd59bf6273c04a3c695443
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-17 15:15:06 +01:00
Alexandru Croitor
d1c56073b4 CMake: Don't rely on CMAKE_FIND_ROOT_PATH_MODE_PACKAGE for examples
We shouldn't set CMAKE_FIND_ROOT_PATH_MODE_PACKAGE to BOTH when
cross-building examples without ExternalProjects.

Instead append the $build_tree_prefix to CMAKE_FIND_ROOT_PATH
and $build_tree_prefix/lib/cmake to QT_EXAMPLES_CMAKE_PREFIX_PATH
to circumvent the usual CMake path-rerooting issue.

This ensures that the build-tree Config files are found by the in-tree
find_package calls when cross-building examples.

Pick-to: 6.2 6.3
Task-number: QTBUG-96232
Change-Id: I4e31f0bf3dbfeb4339823fe09addda3ae83f12c3
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-03-16 15:56:17 +01:00
Alexandru Croitor
c89da21249 CMake: Fix cross-building examples in prefix builds as ExternalProjects
For examples to successfully find not yet installed Config files in a
prefix cross-build, both CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH
need to be adjusted when toolchain files set
CMAKE_FIND_ROOT_PATH_MODE_PACKAGE to ONLY.

Before this change, we lacked two things.

1) If the chain-loaded toolchain file sets CMAKE_FIND_ROOT_PATH
(instead of appending), then the initial value of CMAKE_FIND_ROOT_PATH
that was passed by ExternalProject's initial cache would be
overridden.

2) The prefixes we passed via QT_EXAMPLES_CMAKE_PREFIX_PATH did not
end in lib/cmake, to work around the path re-rooting problem in CMake.

We can handle both of these points by using
QT_ADDITIONAL_PACKAGES_PREFIX_PATH which was introduced for Conan
usage.

Each value assigned to QT_ADDITIONAL_PACKAGES_PREFIX_PATH
gets prepended to CMAKE_FIND_ROOT_PATH by qt.toolchain.cmake AFTER the
original toolchain file is chain-loaded.

And each value also gets lib/cmake appended and assigned to
both CMAKE_PREFIX_PATH and _qt_additional_packages_prefix_paths (used
by Qt6Config.cmake.in to work with find_package + NO_DEFAULT_PATH).

This is exactly what we need to ensure examples build.

Pick-to: 6.2 6.3
Task-number: QTBUG-96232
Change-Id: I11a52457ff795a6661a3a7b68e823e0615d0ce89
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-03-16 15:56:16 +01:00
Alexey Edelev
d1e02c3855 Add '-stdlib=libc++' only for c++ compilers
Pick-to: 6.2 6.3
Task-number: QTBUG-101602
Change-Id: I4ecbb73f845d94156189acfd1a3074b676c90fc4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-14 20:52:47 +01:00
Giuseppe D'Angelo
297fdcaf30 Enable QT_TYPESAFE_FLAGS in headersclean
Change-Id: Ie40a18af7f97b73ea79a09e0dea3fe08c56a1ebb
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-12 06:33:29 +01:00
Fabian Kosmale
57c1e8d533 build system: support module local definitions
This introduces a new helper function,
qt_internal_add_repo_local_defines and makes use of it in
qt_internal_add_{module,test,executable,benchmark,plugin}. That function
checks whether QT_EXTRA_INTERNAL_TARGET_DEFINES is set. If it is, the
defines listed in there will be aded to all targets passed to the
functions mentioned above.

The intended usage is that QT_EXTRA_INTERNAL_TARGET_DEFINES gets set
in the repository local .cmake.conf. This allows e.g. opting in to
source incompatible changes in leaf modules (as long as those are
guarded by some define).

Pick-to: 6.2 6.3
Fixes: QTBUG-101640
Change-Id: I06c3693ee69f46e95a48de724621f0c97e7cc3a8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-11 20:32:08 +01:00
Assam Boudjelthia
db2f47337b CMake:Android: Use ANDROID_PLATFORM instead of ANDROID_NATIVE_API_LEVEL
ANDROID_NATIVE_API_LEVEL is an alias for ANDROID_PLATFORM and the
Android's CMake docs [1] uses directly ANDROID_PLATFORM so let's use
that as well. Also, NDK r23b seems to have removed the part of code from
android.toolchain.cmake that handles ANDROID_NATIVE_API_LEVEL to set
the correct value to ANDROID_PLATFORM.

With this change, CMake will pass the value from the configure argument
-android-ndk-platform as -DANDROID_PLATFORM instead of
-DANDROID_NATIVE_API_LEVEL. Otherwise, if if  -DANDROID_NATIVE_API_LEVEL
is passed directly to CMake, it should work as before.

[1] https://developer.android.com/ndk/guides/cmake#build-command

Pick-to: 6.3
Task-number: QTQAINFRA-4837
Change-Id: I5c21af53ac91e11a27c4b033313d22d1115c1abc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-11 18:30:32 +02:00
Alexandru Croitor
7cc5fbe424 configure: Don't escape backslashes in passed configure arguments
It broke drive-less (no C:\ prefix) paths passed to configure.

Invoking configure on Windows with the following args
  qtbase/configure --
 -DCMAKE_INSTALL_PREFIX=\Users\qt\work\install

called CMake with
 -DCMAKE_INSTALL_PREFIX=\\Users\\qt\\work\\install

saying
 Qt will be installed into '//Users/qt/work/install'

and while the build succeeded, installation would fail with

  CMake Error at cmake_install.cmake:41 (file):
    file cannot create directory:
    //Users/qt/work/install/lib/cmake/Qt6BuildInternals.  Maybe need
    administrative privileges.

Note the double slash in the beginning is likely interpreted as a
Windows share URI / UNC path.

The same would happen when passing -prefix '\Users\qt\work\install'

As a reminder, we want to support drive-less prefix paths because
that's what Qt's Coin CI uses passes to ensure DESTDIR installation
works correctly.

Amends cb7f4030bc

Pick-to: 6.2 6.3
Fixes: QTBUG-94366
Change-Id: I9267b6f784babfbdaeafc65267ba96c75fa24112
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-03-11 02:43:46 +01:00
Thiago Macieira
19b7f854a2 Enable -mno-direct-extern-access and ELF protected visibility
The -mno-direct-extern-access tells the compiler and linker that
references to symbols outside this ELF module mustn't be direct and must
instead always go through the GOT or PLT (the PLT can additionally be
disabled with -fno-plt). The ELF protected visibility tells the compiler
and linker that this symbol is present in the dynamic symbol table as an
export, but it cannot be interposed by another ELF module.

This option is required for user code to link properly to Qt, otherwise
they will get linker errors (assuming GNU binutils >= 2.39) or runtime
failures (glibc >= 2.35). Both versions of glibc and binutils are older
than GCC 12, so it's a safe assumption they are in use and downgrading
the toolchain or libc is not supported. Adding this option to the
compilation is assured for CMake and qmake-based projects.

For example, all accessess to QCoreApplication::self in QtCore, after
this change and with GCC 12 are relocation-free and direct:

000000000013ebf0 <QCoreApplicationPrivate::checkInstance(char const*)>:
  13ebf0:       cmpq   $0x0,0x4f73d0(%rip)        # 635fc8 <QCoreApplication::self>
  13ebf8:       setne  %al
  13ebfb:       je     a90fe <QCoreApplicationPrivate::checkInstance(char const*) [clone .cold]>
  13ec01:       ret

Meanwhile, accesses to the same variable in other modules are indirect
via the GOT:

   66650:       mov    0x876e1(%rip),%rax        # edd38 <QCoreApplication::self@Qt_6>
   66657:       cmpq   $0x0,(%rax)

This replaces the -Bsymbolic and -Bsymbolic-functions (broken)
functionality that Qt has been using or attempting to use since ~2006.

See https://gitlab.com/x86-psABIs/x86-64-ABI/-/issues/8#note_606975128

Change-Id: Iad4b0a3e5c06570b9f5f571b26ed564aa0811e47
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-03-10 17:10:57 -08:00
Thiago Macieira
38e6b637b7 CMake: add detection of x86 VAES and AVX512VBMI2 features
We have VAES code in qhash.cpp that isn't getting compiled right now.

Change-Id: Ibf4acec0f166495998f7fffd16d6961261dec361
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-03-08 00:31:30 -08:00
Alexandru Croitor
eec317a138 CMake: Generate wrapper shell scripts for all hosts when requested
This is useful for Qt for Android builds, where we want to build Qt on
a single host, but make the Qt installation usable on any host
(Windows, Linux, macOS).

There are only two flavors of shell scripts, unix ones that use sh and
Windows batch files.

If Qt is configured with
-DQT_GENERATE_WRAPPER_SCRIPTS_FOR_ALL_HOSTS=ON
then we generate both of them regardless of the current host platform.

Note that the target_qt.conf file still needs to be patched to specify
a correct HostSpec value so that qmake operates correctly.

Other target_qt.conf values might also need path adjustments depending
on use case (like HostPrefix and HostData).

Pick-to: 6.2 6.3
Task-number: QTBUG-101357
Change-Id: Ic86caaa8b318467528cc82dc7fbfecde998cdb71
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-03-04 01:58:10 +01:00
Alexandru Croitor
e2a0ddbb69 CMake: Make configure less verbose by default
Only show the more verbose configure output when configuring
with -developer-build (which matches --log-level=STATUS)

Otherwise in a non-developer build, restrict the output
to NOTICE+ message (includes WARNINGs and ERRORs).

Developers can still pass a custom log level when configuring.
For example -DCMAKE_MESSAGE_LOG_LEVEL=STATUS or
--log-level=STATUS.
The former method will be cached, while the latter is only applied
to the current configure invocation.

Also show the build instructions hint message only when configuring
for the first time.

[ChangeLog][CMake][configure] The configure output verbosity of
non developer-builds of Qt is now reduced by default. Pass
"-- --log-level=STATUS" to configure to make it verbose again.

Pick-to: 6.2 6.3
Change-Id: I7583a9c92142e0b1d7c5411b06403f40d8ebaf20
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-03-04 00:21:44 +01:00
Lorn Potter
66a76a5def wasm: enable mobile native keyboarding
This works on iOS and Android, and Windows with touchscreen.

On Android, we need to listen to the input event
of a hidden text element and synthesize Qt keyboard
events from that in order to get input events into Qt.

On Windows, we need to be more creative about bringing the native
virtual keyboard up.

Because the entire canvas is contenteditable, we need to specify the
inputmode is set to 'none', otherwise the v keyboard pops up
when user clicks anywhere on the canvas. Therefore we set a hidden
element as contenteditable, which pops up keyboard when Qt
needs it for editable widgets. On Android, this is the same
element that is used to proxy the keyboard input.

[ChangeLog][wasm] Add support for native mobile keyboard

Done-with: Morten Johan Sørvig <morten.sorvig@qt.io>
Fixes: QTBUG-83064
Fixes: QTBUG-88803
Change-Id: I769fe344fc10c17971bd1c0a603501040fe82653
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-03-03 12:30:59 +10:00
Kai Köhne
dfe6601974 Bootstrap: Make compiler warnings fatal
Prevent compiler warnings from creeping into the bootstrap library.

Pick-to: 6.3
Change-Id: I8054416564c91fee256cad616911dd4ad231d0df
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-03-02 11:03:44 +01:00
Alexey Edelev
e7586119e1 Add the _qt_internal_android_executable_finalizer wrapper function
_qt_internal_android_executable_finalizer wraps Android-related
function that are needed to created an Android package.
The function is added to the INTERFACE_QT_EXECUTABLE_FINALIZERS
property in Qt Core so it's called implicitly for user projects.

Pick-to: 6.3
Change-Id: I140f53341691dcfdc6ae2ddea520818cf2834eb6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-02 10:23:54 +01:00
Alexandru Croitor
34a4fe0166 CMake: Rename FindZSTD to FindWrapZSTD
And the target ZSTD::ZSTD to WrapZSTD::WrapZSTD.
This should allow building Qt with the
-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON set.

Pick-to: 6.2 6.3
Fixes: QTBUG-100537
Change-Id: I748601e4ad6f518323bf1034d6fc1de582c815e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-02-28 23:08:20 +01:00
Martin Reboredo
5b07f14a4f CMake build: generate pkgconfig for public modules
After the update to the CMake based build system the ability to
generate pkgconfig files, like it was with QMake, was lost.

This patch adds pkgconfig generation again via a new internal command
named qt_internal_export_pkg_config_file.

The functionality of this command consists in checking if the target
is internal. Then gets the compile definitions. It performs a search
for dependencies that is somewhat similar to
qt_get_direct_module_dependencies, although it won't recurse down for
more deps. Each dependency is then again, checked if it's internal or
has a public interface. Later these deps get deduplicated and lastly
a pkgconfig file is filled.

The resulting pkgconfig files of many of the Qt6 packages were
validated via invocations of `pkg-config --validate` and
`pkg-config --simulate` commands and later used to build local
projects plus tests that use the pkg-config provided details at
compilation time.

Although it has some limitations, with qt_internal_add_qml_module if
it specifies non-public deps these won't be listed and with non-Qt
requirements, notably in static builds, not being appended to the
PkgConfig file.

Task-number: QTBUG-86080
Change-Id: I0690bb3ca729eec328500f227261db9b7e7628f6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-28 08:39:54 -03:00
Alexandru Croitor
32b596b7b1 configure: CMake: Add -no-prefix option
Introduce a new -no-prefix option that can be used to build Qt without
having to install it.

Currently, -no-prefix is already implied by -developer-build, but
-developer-build also implies -warnings-are-errors and
-feature-private-tests, which not everyone might want to use.

Some Qt builders likely use -developer-build for the no-prefix
behavior, hence we introduce a standalone -no-prefix option to offer
a nicer user experience without -Werror and friends.

Previously it was possible to achieve the same by specifying
-prefix $PWD, but that relies on $PWD expanding property in the used
shell.

The new -no-prefix doesn't depend on the type of the shell and
is shorter to type.

Internally this gets passed by configure as -DINPUT_no_prefix=yes to
CMake, and transformed into a -DQT_FEATURE_no_prefix=ON feature.

The feature also gets automatically auto-detected to ON if
developer-build is set, -prefix is either unset or $PWD.

CMake code should still query QT_WILL_INSTALL to decide whether
files need to be installed or not.

As a drive-by, we now also export QT_FEATURE_developer_build to
be available for querying during configuration of other repos
(previously it was only possible to query FEATURE_developer_build).

Pick-to: 6.2 6.3
Change-Id: Iaa6c8d8ae2b736282e9949d2a5d7f412e290a253
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-02-24 19:46:01 +01:00
Joerg Bornemann
599c648b77 CMake: Read QT_HOST_PATH from the environment too
For cross-compiled conan packages we need conan to export QT_HOST_PATH
as an environment variable.  The Qt build now picks up this environment
variable if no QT_HOST_PATH cache variable was specified.

Pick-to: 6.2 6.3
Change-Id: I0c3e15e82842061d5db81949ffcc1c240f6ed6a4
Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-02-24 17:07:43 +01:00
Joerg Bornemann
27bd7e0093 CMake: Forward QT_ADDITIONAL_(HOST_)PACKAGES_PREFIX_PATH to try_compile
All variables that are used in qt.toolchain.cmake should be recorded in
__qt_toolchain_used_variables.  This is mostly done for consistency and
to avoid surprises in future configure checks.

Pick-to: 6.2 6.3
Change-Id: I1ae18c5dfe9677c5f46a102e434e32187cb0d703
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-02-24 17:07:43 +01:00
Alexey Edelev
bb209b5715 Fix the mapping between configure arguments and CMake variables
Pick-to: 6.2 6.3
Fixes: QTBUG-101172
Change-Id: Ie1e01880911e771eedbf29b0d2d0607bc25b0549
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-24 03:42:28 +01:00
Joerg Bornemann
71d011d35a Fix QT_ADDITIONAL_(HOST_)PACKAGES_PREFIX_PATH environment variables
Except on Windows, the values in CMake environment variables that
contain path lists are separated by colons, not semicolons.  See
documentation of CMAKE_PREFIX_PATH.

This is necessary for conan's virtualenv generator which sets these
environment variables with native list separators.

This amends commit e044c94a61.

Pick-to: 6.2 6.3
Task-number: QTBUG-94524
Change-Id: I7f3d140a8462347b181f1d9601fd11cc1ba449db
Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-23 17:06:20 +01:00
Alexandru Croitor
56abd7e4e0 CMake: Fix exclusion of QtFoo in QtBarDepends for 3rd party libs
When configuring a static Qt with the -qt-zlib option and the build
system creates a 3rd party header module QtZlib, syncqt
does not generate a QtZlib header file that would include all its
public headers.

Then when the QtSvgDepends header is generated, it would add an
 #include <QtZlib> which would break compilation of the QtSvg PCH
file (which compiles QtSvgDepends).

We have logic to exclude addition of headers from regular 3rd party
static libraries, but not header only 3rd party libraries.

Adjust the code to handle header-only 3rd party libraries, as well as
make sure it works across repos by exporting the relevant properties.

As a drive-by, also rename and export some other informational
properties.

Amends af00402d64
Amends 6fdeaea24f
Amends be2745e478

Pick-to: 6.2 6.3
Change-Id: I087f50b193dd845e4a5ec906e8851d63122faf80
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-02-23 15:17:42 +01:00
Lorn Potter
af36dc7d76 wasm: move user configurable settings
Both INITIAL_MEMORY and PTHREAD_POOL_SIZE are settings users can
change, they are not interface settings.

Fixes: QTBUG-100693
Pick-to: 6.3 6.2
Change-Id: Ie1547c7f52c9fe109a313260616705728024b6b8
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: David Skoland <david.skoland@qt.io>
2022-02-23 12:04:37 +10:00
Joerg Bornemann
d48609a9c4 CMake: Add INSTALL_DIR argument to qt_internal_add_app
Add the possibility to install a Qt app into a directory different from
${INSTALL_BINDIR}.

If INSTALL_DIR is not specified, qt_internal_add_app still installs to
${INSTALL_BINDIR}.

Pick-to: 6.2 6.3
Task-number: QTBUG-99295
Task-number: QTBUG-100047
Change-Id: I52371aa0f770d80c32bb0b3442ce3c463916be63
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-22 18:37:48 +01:00
Tim Blechmann
d2ceb2e353 cmake: avoid unused parameters in cmake tests
unused parameters in cmake tests cause the tests to fail when the
project is configured with `-Werror,-Wunused-parameter`

Change-Id: If3065d008753a7718282dfc6ba0d79d46576cb34
Pick-to: 6.2 6.3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-02-22 02:02:48 +08:00
Michal Klocek
be2745e478 Install 3rdparty headers for static builds
For static builds we need 3rdparty headers to be installed.
Leaf modules like qtwebengine needs 3rdparty libs and header for
zlib, freetype, harfbuzz, png, jpeg. Without those the Chromium bundled
versions are used, however it might end up badly if qt has already
bundled one.

Introduce new header only modules with additional arguments for
qt_internal_add_module:

 * EXTERNAL_HEADERS to pick exactly which headers are public
 * EXTERNAL_HEADERS_DIR to include whole directory preserving the
   files directory structure

Fix qtsync so it keep directory structure for all non-qt modules when
syncing headers and do not generate warnings for headers files.

Task-number: QTBUG-87154
Task-number: QTBUG-88614
Change-Id: If1c27bf8608791cd4e0a21839d6316a445a96e9f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-19 01:52:32 +01:00
Joerg Bornemann
006224eb17 CMake: Fix cross-build without qt.toolchain.cmake
If there's no qt.toolchain.cmake used, QT_HOST_PATH_CMAKE_DIR is not
set.  Use the location calculated from the Qt6HostInfo package in that
case.

This amends commit e044c94a61.

Pick-to: 6.2 6.3
Change-Id: I99aed8e920b8c1aa6efd8f18301cc34aca5559ca
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-02-18 13:44:40 +01:00
Alexandru Croitor
e5b3436255 CMake: Add default launch screen storyboard for iOS apps
Bundle a default LaunchScreen.storyboard file for an iOS app and make
sure it's referenced in the generated Info.plist file.

When launching Qt examples, it ensures the app uses the whole screen
space on the device rather than just a square-ish part of it.

The storyboard file is a copy of the qmake one, which qmake adds
to the Xcode projects it generates.

A custom launch screen can be provided either by setting the
QT_IOS_LAUNCH_SCREEN variable or by setting the
QT_IOS_LAUNCH_SCREEN target property.
The value must be an absolute path to the launch screen file.

The automatic addition of the launch screen entry in the Info.plist
file can be prevented by setting the QT_NO_SET_IOS_LAUNCH_SCREEN
variable to TRUE.

The automatic bundling of the launch screen file in the application
bundle can be prevented by setting the
QT_NO_ADD_IOS_LAUNCH_SCREEN_TO_BUNDLE variable to TRUE.

The current implementation has a limitation that only one launch
screen storyboard and one iOS executable can exist within a project.

If there are multiple executables in the project, all of them will
use the launch screen that is specified last (the last
qt_add_executable call).

Because of this limitation, the API is marked as Technical Preview,
to be improved upon in the future. For now it simply serves as an
improvement to the out-of-the-box experience of iOS apps built
with CMake.

Amends 4d838dae5a

Pick-to: 6.2 6.3
Fixes: QTBUG-95837
Change-Id: I6b067d703d635122959a1ef17fcca713da694a86
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-16 05:14:24 +01:00
Joerg Bornemann
e044c94a61 CMake: Introduce QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH
When installing conan packages we have one installation prefix per
package.  When cross-building a conan package, we need to make known
those multiple host prefixes to Qt, analogous to
QT_ADDITIONAL_PACKAGES_PREFIX_PATH.

Pick-to: 6.2 6.3
Fixes: QTBUG-94524
Change-Id: I68cbede350f95266a5fd3559e9b9c214c5858eed
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-15 14:48:20 +01:00
Alexey Edelev
fdf5d11ff6 CMake: Add BUILTIN_TESTDATA option to qt_internal_add_test
Multiple tests use qt_internal_add_resource that copies the
functionality that is already implemented inside the
qt_internal_add_test function. Simplify these test by replacing
the qt_internal_add_resource call with the new BUILTIN_TESTDATA
option.

Change-Id: I18475b817d6f87264f0de53817d6c26c5ccab4e2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-11 21:54:44 +01:00
Pino Toscano
0a41399c2d CMake: enable machine_tuple also on GNU/Hurd
On the Hurd there is the standard GCC toolchain, so it is possible to
query GCC for -dumpmachine.

Change-Id: Idc8e80c0937147a8ea656bc0320a83d647278455
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-11 00:31:30 +01:00
Alexey Edelev
723a4e2b89 Add missing include of QtPublicCMakeHelpers
Amends 2201934efa

Pick-to: 6.2 6.3
Task-number: QTBUG-99491
Change-Id: I449f0705f1e41fd4609008ae6a7f4107cd0a4ca6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
2022-02-10 15:43:00 +01:00
Alexey Edelev
2201934efa Use 'copy' but not 'copy_if_different' on Windows platforms
Use custom script to copy big Android artifacts on Windows platforms.
The script uses 'copy' but not 'copy_if_different' when source file
size is bigger than 2GB. 'cmake -E copy_if_different' only compares
first 2GB of files because of cmake issue, so this step only
workaround the problem.

Pick-to: 6.2 6.3
Task-number: QTBUG-99491
Change-Id: Id076734700e334dfc3330da412462c2b53829b33
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-10 02:31:05 +01:00
Alexandru Croitor
92dff7c5f8 CMake: Handle slashes in qt_internal_add_example
qtdeclarative has a call like
 qt_internal_add_example(imagine/automotive)

This causes issues when trying to pass that as the name of the
external project. Use the last part after the last slash as the name
of the project.

Pick-to: 6.2 6.3
Change-Id: Ifc074e50e537f07f3636699ed255d2561930d873
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-02-09 16:48:25 +01:00
Alexandru Croitor
94b158134c configure: Switch error to warning when -skip used in per-repo build
Yield a warning instead of an error that -skip and -submodules have
no effect in a per-repo build.

Amends acaba63260
Adjusts to 11ae0e772c

Pick-to: 6.2 6.3
Change-Id: Ic26b0ba29e48be5162f13ad75308f8358d8878e3
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-02-09 15:33:46 +01:00
Alexey Edelev
3bee7db419 Fix the run of _check targets in multi-config builds
With Ninja Multi-Config generator it's necessary to provide the
'-C' option matching the build configuration when running
ctest. This patchset adds the missing option to the command line
of the '_check' targets.

Pick-to: 6.2 6.3
Change-Id: I42acfba26a09877a6d3a5be9230860f15f95a0cd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-09 15:33:45 +01:00
Alexandru Croitor
90b07054f6 CMake: Assign proper postfixes in multi-config builds
In a single-config build on Linux, we usually don't want a debug
postfix in library names (as opposed to Windows/macOS).

But when doing a multi-config build on Linux, assigning no postfixes
causes CMake to generate rules for a single config only, the first one
specified in CMAKE_CONFIGURATION_TYPES.

This leads to being unable to build all configurations from the same
build.ninja file as well as other obscure issues like race-conditions
when generating prl files.

To address this, when doing a multi-config build, always assign a
postfix for each config except the first release-like one, while
preserving the existing rules we had for debug postfix names.

Pick-to: 6.2 6.3
Fixes: QTBUG-100493
Change-Id: Ie9c88e074abdcf2961d7b3dee19a5694292717b8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-02-09 15:33:45 +01:00
Alexandru Croitor
bb9be22133 CMake: Fix rpath set for Qml plugins to not contain lib64
Qt6QmlMacros uses the value of GNUInstallDirs's CMAKE_INSTALL_LIBDIR
to calculate the rpath from a Qml plugin's location to the Qt
libraries.

By default CMake detects the value of CMAKE_INSTALL_LIBDIR, and on an
RHEL system it is set to 'lib64', whereas we usually configure Qt with
the lib dir set to just 'lib'. This might cause issues with Qml
plugins not locating the Qt libs due to an incorrect rpath.

Ensure that when building Qt libraries and plugins,
CMAKE_INSTALL_LIBDIR is set to the same lib dir value that Qt was
configured with.

Pick-to: 6.3
Fixes: QTBUG-99707
Task-number: QTBUG-100432
Change-Id: I17b2a22d46ef3b40084a2f6a4992f0e23b35d4d3
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-02-03 21:55:38 +01:00
Alexandru Croitor
acaba63260 configure: Raise error if -skip/-submodules is used in per-repo build
Specifying the options would do nothing, so it's better to error out
early in case the developer accidentally added them.

Pick-to: 6.2 6.3
Change-Id: Ia516468a22c3c48e9e84dc78e522e8870186d96b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-02-03 21:21:29 +01:00
Alexandru Croitor
7cb2bbd9e7 configure: Introduce -submodules option
The option is used to specify a list of Qt repos (git submodules)
that should be included in the configuration of a top-level Qt build.

The option takes a comma-separated list of qt submodule names e.g.
'qtbase,qtsvg,qtdeclarative'

It can also take a single value like 'qtbase' or 'qtquick3d'.

Each specified submodule and all of its transitive dependencies will
be included when configuring the top-level Qt build (assuming that the
submodules have previously been already checked out).

Any missing submodules or dependencies will not be automatically
checked out, but rather skipped. This can result in a failed
configuration if a required submodule is missing.

If some optional transitive submodule dependency is not desired in the
build, you can combine the -submodules option together with -skip
options.

E.g. configuring with

  -submodules qtdoc,qtnetworkauth -skip qtmultimedia,qtimageformats

will result in a top-level build with the following  submodules:

 - qtbase (common dependency)
 - qttools (dependency of qtdoc)
 - qtactiveqt dependency of qttools)
 - qshadertools (dependency of qtdeclarative)
 - qtdeclarative (explicit)
 - qtnetworkauth (explicit)
 - qtdoc (explicit)

Pick-to: 6.2 6.3
Fixes: QTBUG-100388
Change-Id: Ie8c47cfd1d1e0e44a27260bf9ddf968531cc1cc0
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-03 21:21:29 +01:00
Alexandru Croitor
40155ddd0e configure: Allow specifying a comma separated list to -skip option
This makes skipping a list of submodules more concise.

e.g. instead of passing

 -skip qtsvg -skip qtimageformats -skip qtmultimedia

pass

 -skip qtsvg,qtimageformats,qtmultimedia

Pick-to: 6.2 6.3
Change-Id: I6a48828b2fd7cec9f6e19988f7b4033333768abb
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-02-03 21:21:28 +01:00
Alexandru Croitor
d1c825ae8c CMake: Temporarily disable building external examples in prefix builds
There are issues when building examples as external projects in the CI
in child repos like qtsvg.

QEMU configurations fail to find some CMake Config files, Windows
configs fail to find libraries.

Until these issues are fixed, build examples in-tree (without using
external projects) like we did before.

Temporarily disables 98c89c8cc1

Pick-to: 6.2 6.3
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: Ia4b39812b27cfde5f5a103fd39cc1cb032842643
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-03 19:29:44 +01:00
Alexey Edelev
fd3341a74e Add qt_internal_undefine_global_definition function
qt_internal_undefine_global_definition disables an internal global
definition that is defined by the qt_internal_add_global_definition
function for a specific target.

Remove the ability to set the custom "undefine" flag for the
definitions since it's hard to control it using the introduced
function.

Pick-to: 6.2 6.3
Task-number: QTBUG-100334
Change-Id: Ic1637d97aa51bbdd06c5b191c57a941aa208d4dc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-02 16:45:37 +01:00
Alexey Edelev
e2b98627a8 Use builtin test data on Integrity
Looks like Integrity doesn't deal well with external test data either.

Pick-to: 6.3
Change-Id: I8beb5ac4d2440d40a7efdceae973e430a2354e9d
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-02 09:18:25 +01:00
Ilya Fedin
5a0849ed6b Handle glib optional components properly
Fixes: QTBUG-97929
Pick-to: 6.3
Change-Id: Ic73548cb10680a2ccd60faed2b0548c82892eaa1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-02 08:56:10 +04:00
Alexandru Croitor
1031fa1547 CMake: Allow installing examples outside of the Qt prefix
Introduce a new QT_INTERNAL_CUSTOM_INSTALL_DIR variable to
allow specifying an 'examples install dir' outside of the Qt prefix.

It will be used in a follow-up change to ensure we don't package
the example binaries in our CI artifacts (thus saving space).

This will be even more important when the examples will contain code
to deploy Qt libraries alongside each deployed example (which would
significantly increase the package size).

Pick-to: 6.2 6.3
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I06b4a8f9e8c57a712a356bca0f5c351a9362bc30
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-01 16:51:01 +01:00
Alexandru Croitor
98c89c8cc1 CMake: Build examples as ExternalProjects in prefix builds
Change prefix builds to use ExternalProjects to build examples
by default. This will affect our CI which only does prefix builds.

To make it work, we have to do a few adjustments:
- look for Config files in the build-tree (before Qt is installed)
- build only one examples with only a single config,
   even if Qt is a multi-config build
- install examples as part of main make install step, rather than
  as part of the make step (which is the default for EPs)
- adjust CXX flags when building with MSVC to ensure we can still
  use sccache and separate debug info
- derive the correct install prefix for each example and pass it
  to the ExternalProject

As a drive-by, add TODOs to address tidiness of the code and corner
cases that likely don't work (Conan).

Amends d97fd7af2b

Pick-to: 6.2 6.3
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I3060da5dc64e7b06052f9dcb720d4d250f876450
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-02-01 16:51:01 +01:00
Alexandru Croitor
1273ffb000 CMake: Copy FindFoo.cmake scripts to build dir in prefix builds
They are used by build dir Qt6FooConfig.cmake files in conjunction
with export(EXPORT)'ed target files when building ExternalProjects
against a non-installed Qt (or in a top-level build).

Change-Id: I688caf1bd1b8a8fe7e549cebade2aef6f928bd6c
Pick-to: 6.2 6.3
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-02-01 16:51:01 +01:00
Alexandru Croitor
ac4a913f33 CMake: Deduce install prefix of example in qt_internal_add_example
We want to get rid of the INSTALL_EXAMPLEDIR and INSTALL_EXAMPLESDIR
code in each example project.

This was an internal workaround to ensure examples are installed into
a relative path somewhere under $qt_prefix/examples and not in
$qt_prefix/bin or similar.

To achieve that we do two things.

First, deduce the install prefix for each example in the
implementation of qt_internal_add_example (our add_subdirectory
wrapper) and assign it to CMAKE_INSTALL_PREFIX before calling
add_subdirectory. We need to make sure to remove the default
value of CMAKE_INSTALL_PREFIX in the generated
cmake_install.cmake file.

Second, we set an internal variable called
QT_INTERNAL_SET_EXAMPLE_INSTALL_DIR_TO_DOT before the add_subdirectory
call, which will be checked whenever find_package(Qt6Core) is called
in an example project. If the variable is set, the
INSTALL_EXAMPLEDIR var is set to "." in the scope of where Qt6Core
is found.

This ensures that the hardcoded INSTALL_EXAMPLEDIR values in our
example projects are changed to ".".

With both changes, our example project install(TARGET DESTINATION)
calls will now install to
"${CMAKE_INSTALL_PREFIX}/examples/${example_relative_dir}/."

Once all repositories are updated to use qt_internal_add_example
instead of add_subdirectory, we can get rid of the
QT_INTERNAL_SET_EXAMPLE_INSTALL_DIR_TO_DOT workaround.

For repositories that still don't use qt_internal_add_example,
the install prefix rewriting will not happen, but the examples will
still be installed to the proper place because they use their own
hardcoded INSTALL_EXAMPLEDIR value.

Amends d97fd7af2b

Pick-to: 6.2 6.3
Task-number: QTBUG-96232
Task-number: QTBUG-98545
Change-Id: I78c118e10c41b519c570c7d87529afd15aeed900
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-02-01 16:51:00 +01:00
Alexandru Croitor
1a103beff6 CMake: Shorten ExternalProject example project paths
Instead of nesting the external project build dir under the current
binary dir, place the EP build dir where it would usually be when we
use add_subdirectory.

Shorten the name of the external project to just ${subdir} instead
of using the relative current binary dir path.

Place the EP prefix and stamp dirs under a new ${subdir}-ep folder
next to the example build dir.

Overall this places example executables where you'd usually expect
them to be, as well as shortens a bunch of build paths to circumvent
path limit issues when building on Windows.

Pick-to: 6.2 6.3
Fixes: QTBUG-94608
Task-number: QTBUG-96232
Change-Id: Ifb921c5a6397385e8a914111bf56ee59cda003fd
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-02-01 16:51:00 +01:00
Alexandru Croitor
209438c16a CMake: Split qt_internal_add_example into two functions
One for building using ExternalProject_Add and one when examples are
built in-tree by calling add_subdirectory directly.

Pick-to: 6.2 6.3
Change-Id: If4c5301163aefed9f15148a70a8f7014bc817ac0
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-02-01 16:51:00 +01:00
Allan Sandfeld Jensen
b954a79e25 CMake: Run export(EXPORT) for prefixed and top-level builds
This is necessary to be able to find Qt6 modules in CMake
ExternalProjects before Qt is installed, regardless of top-level or
per-repo builds.
One use case is examples that are built as ExternalProjects.

Pick-to: 6.2 6.3
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: Ic6a9bfd1c52a04e34b221deab40f419a6fee9463
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-02-01 16:51:00 +01:00
Alexey Edelev
f9e48854af Use IMPORTED_LOCATION of rcc target
Use IMPORTED_LOCATION of rcc target when generating Android
deployment settings, instead of the hardcoded host path.

Introduce a helper function to find the location of the imported tool
target.

Change-Id: Icfa51ee7a01b3f58fc4892da03055f9ed531cc0b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-01 15:06:46 +01:00
Marc Mutz
0d9f4e7526 Make one QT_REMOVED_SINCE/QT_BUILD_REMOVED_API per module
A single global QT_REMOVED_SINCE will start hurting us once more
modules downstream of QtCore start using the mechanism.

With every use of feature, the set of code that needs to compile under
QT_BUILD_REMOVED_API increases. Since we use QT_REMOVED_SINCE in
situations where overloading the new and the old function don't work
in general, this means all code included by any removed_api.cpp needs
to be very carefully written to ensure that any calls to the overload
set formed by the combination of old and new function(s) don't create
ambiguities.

Likewise, the set of APIs that change semantics under
QT_BUILD_REMOVED_API also increases. At some point, the combination of
removed_api.cpp including almost every module header and almost every
header exposing source-incompatibilities when included in
removed_api.cpp will make maintenance a headache.

By making QT_REMOVED_SINCE and QT_BUILD_REMOVED_API per-module
(QT_CORE_REMOVED_SINCE, ...), easy now that we generate the export
macros using CMake, we limit the scope of this problem to the module
using the feature. Downstream modules (say, QtWidgets) will now see
the QtCore API like every other user, even in the
widgets/compat/removed_api.cpp TU.

Pick-to: 6.3
Change-Id: I177bc7bd5aa8791639f97946c98e4592d2c7f9d9
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-01 11:47:58 +00:00
Thiago Macieira
05e029619f CMake: fix running of headersclean targets when CMAKE_CXX_FLAGS is set
We were passing the full option from the user as a single string in the
command-line to the compiler.

clang++ -c "-O3 -g1 -march=tigerlake -mprefer-vector-width=256 -maes" [...]
error: invalid integral value '3 -g1 -march=tigerlake -mprefer-vector-width=256 -maes' in '-O3 -g1 -march=tigerlake -mprefer-vector-width=256 -maes'

Pick-to: 6.2 6.3
Fixes: QTBUG-100315
Change-Id: I6fcda969a9e9427198bffffd16ce83150d4e4263
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-31 19:07:58 -08:00
Alexey Edelev
1d28fd7a9c Restore missing Qt definitions
Restore the 'QT_NO_JAVA_STYLE_ITERATORS' and
'QT_NO_NARROWING_CONVERSIONS_IN_CONNECT' definitions for Qt
targets.

Add the function that adds global definitions for Qt targets according
to the provided scope and the target property-based switch to disable
the definition for a specific target.

Pick-to: 6.2 6.3
Task-number: QTBUG-100295
Change-Id: I28697e81f9aabc45c48d79aae1e5caea141e04e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-31 17:40:43 +01:00
Allan Sandfeld Jensen
7e591453be Fix finding GSSAPI
The package is called mit-krb5-gssapi on Ubuntu, and the LIBDIR variable
was missing an underscore.

Pick-to: 6.3 6.2
Change-Id: I85b5603c1161f33462aa71bbd522d40dd7489405
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-29 11:46:04 +00:00
Alexandru Croitor
c8621da852 CMake: Fix host UiTools being picked up instead of target one
Pick-to: 6.2 6.3
Fixes: QTBUG-100233
Change-Id: Id4b30841ba9e499f462325f882218edf407e0a00
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-01-27 00:17:14 +01:00
Yuhang Zhao
c532a57670 Fix build with clang-cl
1. Clang-CL can't recognize "/d2FH4" and it's causing
lots of warnings when compiling. So don't apply it
when building with clang-cl.
2. The definition of "FS_INFORMATION_CLASS" need to
be visible to clang as well. Don't know why it was
excluded originally.

Pick-to: 6.3
Change-Id: I7b6e14999eea0ba1f0d73962ff03a35548f88a5a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-25 14:09:31 +08:00
Joerg Bornemann
33af62db37 CMake: Support overriding CMAKE_BUILD_TYPE per-repo or test
One might want to build qtbase in Release, but qtsvg or some test in
Debug mode. Before if qtbase was configured as Release, there was no
way to override that.

Now we try to detect whether a custom build type was specified to
qt-cmake / qt-configure-module / qt-cmake-standalone-test /
qt-internal-configure-tests

Note mixing won't work on Windows due to different C/C++ runtimes.

Also, now we don't force set a single build type when a multi config
generator is used as well as one opts out via the
QT_NO_FORCE_SET_CMAKE_BUILD_TYPE variable.

Pick-to: 6.2 6.3
Change-Id: I6dc4325087ff7f905ad677d87b0267e2f3e4693f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2022-01-21 14:24:09 +01:00
Alexandru Croitor
0d5dc56554 CMake: Display CMAKE_BUILD_TYPE when including QtSetup
This will show the CMAKE_BUILD_TYPE that was computed for a configured
repo or standalone tests, after the logic in
QtBuildInternalsExtra.cmake is executed.

Pick-to: 6.2 6.3
Change-Id: Ib8ffa2c7806a4c16385a2fcd4500f8a0f6a9aa88
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2022-01-21 14:24:09 +01:00
Ulf Hermann
6442fbafcd CMake: Add OUTPUT_TARGETS option to qt_internal_add_resource
We need it for shadertools.

Change-Id: I9e9c76e535e5cd698564b48beedb7380b08173e2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Simeon Kuran <simeon.kuran@gmx.at>
2022-01-20 19:36:00 +01:00
Alexandru Croitor
158287c726 CMake: Add support building Qt with the 'mold' linker
The mold linker is a new linker for Linux that provides faster link
times compared to BFD ld, ld.gold and lld.

It can be found at https://github.com/rui314/mold

To build Qt with mold, ensure that the binary in your PATH and then
configure Qt with with either

 cmake /path/to/qtbase -DINPUT_linker=mold

or

 /path/to/qtbase/configure --linker mold

The change was tested with gcc 9, clang 10, clang 12, mold
1.0.0. Only qtbase and qtdeclarative (and dependencies) were tested.

Pick-to: 6.2 6.3
Task-number: QTBUG-99270
Change-Id: I2e64a1f4257c37ff5b64a9326e548b9b46e07c80
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-20 19:01:27 +01:00
Edward Welbourne
fba863a87e Fix minor grammar error in configure's closing message
Minor glitch in wording, but it's been bugging me for months.

The meaning of "try to remove [a file]" implicitly says you might be
unable to do so; while the attempt might help with your situation, the
experiment might merely be a diagnostic, e.g. because if you can't
remove the file, that would imply things that would help you solve
your problem.  For contrast, "try removing [a file]" says removal
might actually solve the problem for which this action is proposed as
a fix.

Change-Id: Ic995cfdef1523094bb368dcda8bd0d2bbd2e9434
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-20 19:01:27 +01:00
Thiago Macieira
34a67431e4 CMake: Merge QCC with GCC and Clang
Because that's what it is.

Change-Id: Ib42b3adc93bf4d43bd55fffd16c144ef04d68d83
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2022-01-20 01:57:06 -03:00
Pino Toscano
099e0fff61 CMake: add support for GNU/Hurd
Add a "HURD" CMake platform specification, so it can be properly
checked in the build system.

Set QT_DEFAULT_MKSPEC to the existing hurd-g++ mkspec.

Hurd supports $ORIGIN in RPATH, so enable it.

Hurd uses X11, so add it to the X11_SUPPORTED list.

Enable few more feature checks that apply to Hurd as well: either
because they are provided by GNU libc itself, or because they are
implemented on Hurd.

Check and set the ELF interpreter, as it is a common functionality of
the GNU toolchain.

Change-Id: Id347033560bbc5a2a4e2c3abb493c948c002b40e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-19 01:53:14 +01:00
Alexandru Croitor
9198a9b8cc CMake: Fix qt_run_linker_version_script_support to use active linker
The version script compile test did not use the linker that the build
system determined to use to link Qt, but rather the system linker.

Run qt_run_linker_version_script_support only after the global qtbase
features have been evaluated and make sure to include the active
linker flags.

Pick-to: 6.2 6.3
Change-Id: I0ff82406828daaf0dc5ec25a55f53ac7d98e3347
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-01-18 14:28:57 +01:00
Alexandru Croitor
d6066d53fa CMake: Fix detection of linker availability
Previously we passed flags like -ld-fuse=lld only to compile
calls, but not to the link call of a compile test project.

Make sure to pass it to the link call instead by using
check_cxx_source_compiles + CMAKE_REQUIRED_LINK_OPTIONS
instead of
check_cxx_compiler_flag.

Note the flag that is passed is still via passed via the
compiler launcher and not directly to the linker.

Remove duplicate flag handling code.

Pick-to: 6.2 6.3
Change-Id: I1bf90573904a9df83240b6debfee3cc9e425c6bb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2022-01-18 14:28:57 +01:00
Alexandru Croitor
461f68c5c9 CMake: Fix dbus headers not being added in qt_internal_extend_target
The generated dbus headers would not appear in IDE source lists
because of incorrectly named variables.

Pick-to: 6.2 6.3
Change-Id: I276d4284eb94b98cc75f791de62ca332ad947004
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-01-18 10:18:54 +01:00
Marc Mutz
208cfad9ad Clang: don't error out on -Wdeprecated-enum-enum-conversion
Same treatment as is given to GCC further below.

Pick-to: 6.3 6.2
Change-Id: I3762c39a0b5d9add365ecf828b80d3ba432578c2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-18 04:07:14 +01:00
Joerg Bornemann
037fd545c4 CMake: Propagate qtbase's CMAKE_STAGING_PREFIX to Qt modules
When qtbase is configured with CMAKE_STAGING_PREFIX set, then Qt modules
built against this qtbase should also get CMAKE_STAGING_PREFIX by
default.  Like CMAKE_INSTALL_PREFIX in regular builds, this prefix will
be determined by the location of QtBuildInternalsExtra.cmake to support
building Qt modules against an installer-provided Qt.

CMAKE_INSTALL_PREFIX on the other hand must be exactly the value that
was provided when building qtbase.

If CMAKE_STAGING_PREFIX is specified by the user, honor it.

To opt out of automatically setting CMAKE_STAGING_PREFIX, set
QT_BUILD_INTERNALS_NO_FORCE_SET_STAGING_PREFIX to ON.

Remove the old code that was supposed to set CMAKE_STAGING_PREFIX.

Pick-to: 6.2 6.3
Fixes: QTBUG-99666
Change-Id: I20edef54c102ca9784fcdef0decf0bd83266ae11
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-18 00:20:37 +01:00
Morten Johan Sørvig
bb8c73ab9e wasm: modernize pthreads option
Use “-pthreads” instead of “-s USE_PTHREADS=1”. This
is both a compile and linker option.

Pick-to: 6.3
Change-Id: Iaf7cb4ec41577fe596c3e81fda05c03fe0074c08
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-01-17 09:01:14 +00:00
Joerg Bornemann
ae294a42f0 CMake: Add C/C++ compiler options to C/C++ sources only
When compiling CUDA sources in a user project, the Qt6::Platform target
would pull in C/C++ related compiler flags, leading to compiler errors.

Make sure that we only add those flags to C/C++ source files.

Pick-to: 6.2 6.3
Fixes: QTBUG-99548
Change-Id: Idbccd65fe8f66abd1da3fce95e563065d1ed3cc6
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-01-08 18:08:10 +01:00
Alexey Edelev
28da24a1a6 Enable -bigobj by default for Qt
Add '-bigobj' for MSVC and '-Wa,-mbig-obj' for MINGW to the
PlatformCommonInternal compiler options.

Pick-to: 6.3
Change-Id: I706b83d189a116a3ab6f93d59593e237e66b0e2e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-07 15:21:18 +01:00
Joerg Bornemann
faa26be44c CMake: Fix WrapOpenSSL package
Since f19ce3898e we link OpenSSL to
QTlsBackendOpenSSLPlugin instead of QtNetwork itself.  In dependent Qt
repositories this leads to the following situation:

QTlsBackendOpenSSLPlugin's dependencies call
find_dependency(WrapOpenSSLHeaders), and OpenSSL_FOUND is set to ON in
that scope.  Later, we call find_package(WrapOpenSSL) in a different
scope.  find_package(WrapOpenSSLHeaders) bails out early, because the
target WrapOpenSSLHeaders::WrapOpenSSLHeaders exists.
find_package(OpenSSL) is not called again.  The check for OpenSSL_FOUND
fails, because the variable is not visible in the scope of
FindWrapOpenSSL.cmake, and we don't create the WrapOpenSSL::WrapOpenSSL
target.

Fix this by checking for the existence of the target OpenSSL::SSL
instead of the OpenSSL_FOUND variable.

Pick-to: 6.2 6.3
Fixes: QTBUG-99623
Change-Id: Idd0e8a60fabd0c7772413d557442c0012b0b436c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-01-07 11:16:21 +01:00
Kai Köhne
6205cb161d Update copyright year to 2022
Pick-to: 5.15 6.2 6.3
Change-Id: If6f1d6f9f82a601f8e2b6d36650d6e737518aa60
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2022-01-04 12:44:19 +01:00
Dimitrios Apostolou
63ffae3fa3 Introduce qt-testrunner.py
Script that wraps Qt test execution in order to iron-out flakiness.

Task-number: QTBUG-96353
Change-Id: Ie8ee780e3f4f8d086c080a7784f9f68fd1867be2
Reviewed-by: Daniel Smith <Daniel.Smith@qt.io>
2022-01-03 16:32:56 +01:00
Alexey Edelev
8e2f101a6b Exclude sources from HEADER_MODULE if cmake version is less than 3.19
CMake versions less than 3.19 don't support adding the source files to
the PRIVATE scope of the INTERFACE libraries. It looks like these
PRIVATE sources are only used by IDEs to display them in a project
tree. Skip them to avoid configuring issues.

Fixes: QTBUG-99316
Pick-to: 6.3
Change-Id: Id03f540ac9c94e920adfae5de4f364bd7aba4613
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2022-01-03 14:35:13 +01:00
Alexey Edelev
f90221d8cd Replace ANDROID_ABI argument with the QT_ANDROID_ABI target property
This change tries to make the API more user friendly and prevent wrong
use of multi-abi API. ANDROID_ABI argument of qt6_add_executable was
position-depend and needed to be placed after the executable 'sources'.
Using the target property we solve this problem and provide more
consistent and common way to enable multi-abi build for the single
target.

This meanwhile also requires to execute multi-abi build configuration
in the finalizer, since the property might be set at any point.

Also the priority of the QT_ANDROID_ABI target property now is higher
than the priority of the QT_ANDROID_BUILD_ALL_ABIS variable. So target
will only build packages with the ABIs specified in QT_ANDROID_ABI
property if both are set.

Pick-to: 6.3
Task-number: QTBUG-88841
Change-Id: I3515297ed267974498913c59619433dc234ec217
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2022-01-03 14:35:13 +01:00
Ievgenii Meshcheriakov
a7b70ee55b CMake: Add CryptoTokenKit framework for macOS
Set ${FWCryptoTokenKit} when the framework has been found.
This is useful for WIP card reader support in QtConnectivity.

Task-number: QTBUG-97946
Change-Id: I0e85e0fd2e0fc45fb3069bbdaa2d8b2c927a6c2d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-23 18:11:36 +01:00
Yuhang Zhao
bdaab71c68 CMake: Remove WinRT leftovers from build system
Qt's WinRT support was removed long time ago.

Change-Id: I60b220e970072c3450e3793862d6f68801d2b5b3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-12-18 08:01:39 +08:00
Alexandru Croitor
340b2a1a47 CMake: Fix exit code to be shown properly on test failure
The result variable was expanded at configure time rather than at
script execution time due to missing escaping.

A tidbit of information, the result variable can contain not only an
exit code, but a string as well.
For example on arm macOS with a crashed test it contains
'SIGTRAP'.

Curiously if the crashing executable is executed directly without
CMake, 'Trace/BPT trap: 5' is shown instead, perhaps because of
the shell.

Amends 3ef6af024b

Pick-to: 6.2 6.3
Change-Id: I50e57922abfc6eccde205c6252eebfda510bad41
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-17 17:24:36 +01:00
Joerg Bornemann
2a013fec1c CMake: Fix errors about missing qt_setup_tool_path_command.bat.in
This amends commit 0bea727cac or rather
reverts it and applies a different fix for QTBUG-98843.

Use file(WRITE) instead of configure_file or file(CONFIGURE).  This
command doesn't have the line endings issues in CMake 3.19 (see
QTBUG-98843).  It's not problematic that the .bat file gets a new
timestamp on every configuration step, since we don't add dependencies
on it.

Fixes: QTBUG-99223
Task-number: QTBUG-98843
Change-Id: Ibdcd0e4703bf6df42c6a6d0bb2f35c5144bbe30a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-12-15 18:04:48 +01:00
Fabian Kosmale
3ef6af024b QtTestHelpers: print exit code upon failure
This might give a few insights into why the process has failed, at least
if distinct return values are used for different errors.

Change-Id: I61fe0ede812c4dda3d0cf0f2c96a479d198d340d
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-12-15 13:07:10 +01:00
Yuhang Zhao
d2a0202cda MSVC: Optimize global data to reduce binary size
Package global data in COMDAT sections for optimization.
According to the docs, this can significantly reduce the
size of the resulting binary executable.

I've tested build Qt with /Gw locally with and without
LTCG, the result shows /Gw can reduce the binary size
indeed, but not "significantly". The result also reveals
that exes can benefit much more from /Gw than dlls.
The result can be seen from the QTBUG-98894 bug report.

Microsoft Docs:
https://docs.microsoft.com/en-us/cpp/build/reference/gw-optimize-global-data?view=msvc-170

Task-number: QTBUG-98894
Change-Id: Ibce34c98e791e519d669a5fe39c0027d1459c382
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-12-15 13:02:39 +08:00
Allan Sandfeld Jensen
f370a4c49c Support configure -platform linux-clang-libc++
Detect libc++ config and add appropriate compiler and linker flags.

Pick-to: 6.3
Change-Id: I9ec91b3ace987599d4e79e43b1b75aa67cd5caeb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-12-14 20:04:43 +01:00
Alexey Edelev
2f30e9d751 Use the highest-available android SDK version as the 'target' SDK
When building Qt we want to use the highest available 'target' SDK
version. If the version of the available SDK is lower than the minimum
required 'target' SDK version, we need to throw an error.

Pick-to: 6.2 6.3
Fixes: QTBUG-99165
Task-number: QTBUG-98870
Change-Id: Ib75567a6f33ac6d23d9f79e8ed8535839c08b91d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-12-14 17:09:21 +01:00
Joerg Bornemann
0bea727cac CMake: Fix build on Windows with CMake 3.19
qt_setup_tool_path.bat did not have proper line endings on Windows with
CMake 3.19, breaking the invocation of tools that use the wrapper, for
example qmltyperegistrar.

The reason was that file(CONFIGURE) doesn't properly write line endings
with CMake 3.19.  See upstream issue #21769.

Use configure_file with a proper input file to work around this issue.

Pick-to: 6.2
Fixes: QTBUG-98843
Change-Id: I2a4da15f306dc844cf83ca9721a77196c42af2ad
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-12-13 14:41:16 +01:00
Lorn Potter
663c1b8827 wasm: remove deprecated argument for source maps
-g4 was deprecated in Emscripten 2.0.17, and since we are well past
that version we can safely use -gsource-map instead.

Change-Id: I497155619d6320661f6be0e220b52fa7d6ca0b8e
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-12-13 06:53:22 +00:00
Lorn Potter
3bbbd4ae12 wasm: update recommended emscripten to 3.0.0
[ChangeLog][wasm] Recommended emscripten version is now 3.0.0

Change-Id: I9ae082509415d8f00b8e9970b730ad4a472da310
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-12-09 03:22:36 +10:00
Yuhang Zhao
5074344c9c MSVC: Use dubbed FH4 to make C++ exception handling smaller
Visual Studio 2019 introduced the dubbed FH4 feature
which can make C++ exception handling smaller on x64.
According to the article [1], it's enabled by default
for UWP applications, and Microsoft also use it in
their own widely-known commercial products such as
Office to reduce the binary size.

So make use of this feature for Qt when possible, to
get smaller binary.

As a drive-by, add "/EHs-c-" explicitly to the flags
when we want to disable C++ exception handling.

[1] Official article that introduces dubbed FH4:
https://devblogs.microsoft.com/cppblog/making-cpp-exception-handling-smaller-x64/

Change-Id: I2e3330de477f78372cf7903d0ef7a732b09552a9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-12-04 14:15:16 +08:00
Joerg Bornemann
75eb08711e Install MSVC debug information for resource object libraries
Building against a static debug MSVC Qt produced LNK4099 warnings (PDB
was not found with object file).

This was because we did not install the .pdb files for the object
libraries that are created for Qt resources.  Now, these .pdb files are
named like the object library targets and are installed next to the
object files.

Pick-to: 6.2
Fixes: QTBUG-97699
Change-Id: I7e23f8392b7ac657be1d2fb3b33e051ae2e4d407
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-02 12:53:34 +01:00
Kai Köhne
6c10546a4b Enable warnings-are-errors for Visual Studio 2022
Change-Id: Id0b143f668f69481f6037f94aedbfd2e87331497
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-11-30 16:32:10 +01:00
Joerg Bornemann
95ccdfa432 CMake: Fix Android platform detection
...if an Android platform < 10 is installed.

The existing platform detection code preferred android-9 over
android-31, because the sorting did not use natural comparison.

Natural comparison was added to CMake in version 3.18.  We simulate this
feature for older CMake versions.

Pick-to: 6.2
Fixes: QTBUG-98726
Change-Id: Ib2eb87bd47220feb672275fa5203df4f2b6d7ca7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-29 19:55:05 +01:00
Marc Mutz
a0f9aef11b Long live Q_GADGET_EXPORT!
Like Q_NAMESPACE_EXPORT for Q_NAMESPACE, this variant of Q_GADGET
allows passing an export macro. This is useful to avoid exporting the
whole class just to get the staticMetaObject hidden therein exported.

Before anyone asks: No, we don't need Q_OBJECT_EXPORT, because QObject
subclasses, being polymorphic, always need to have a class-level
export macro (to export their vtable), but while that technique also
works for value classes (the Q_GADGET audience), it is not desirable
for them, because it makes inline functions exported in Windows debug
builds, which is not what we want, because it needlessly restricts
what you can to with the inline functions (e.g. remove).

[ChangeLog][QtCore] Added the Q_GADGET_EXPORT macro, which is like
Q_GADGET, but allows passing an export macro (like Q_NAMESPACE_EXPORT
for Q_NAMESPACE).

Fixes: QTBUG-55458
Change-Id: I546297de1e8aa45d83381991bcd3fbca61e1eef0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-27 01:25:10 +01:00
Alexey Edelev
aba1432dae Add missing dependency of ${target}_check to ${target}_make_apk
When building for and running the '_check' target in Android we need
to make sure that target apk is assembled and ready for deployment.

Pick-to: 6.2
Change-Id: Ifc63aac230f0bb8375d319ec443174c5a436485e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-26 18:28:50 +01:00
Fabian Kosmale
7e11ddc930 qt_internal_add_module: Document HEADER_MODULE and STATIC
Task-number: QTBUG-94863
Change-Id: If52ed7e17ea77d8cb6e0255e988feb0b1bd0aa76
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-11-26 13:13:09 +01:00
Yuhang Zhao
405adf3348 Win32: Enable large address aware explicitly
Large address aware is enabled by default in 64-bit
compilers, but not 32-bit compilers. But Qt users
may build 32-bit Qt themself, in this case large
address aware is disabled in fact, and it may cause
some issues. So we pass /LARGEADDRESSAWARE to the
linker unconditionally to make sure large address
aware is enabled for both 32-bit and 64-bit builds.

Microsoft Docs:
https://docs.microsoft.com/en-us/cpp/build/reference/largeaddressaware-handle-large-addresses?view=msvc-170

Change-Id: Idb2603d9ba0ba9ef4477ce1c3174b7c7e8ba76f6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-11-26 16:42:53 +08:00
Morten Johan Sørvig
471c7e722d wasm: remove duplicate “--bind” option
Not a compile option, and also added to the linker
options above.

Change-Id: Iab2107d4b5ee4bc73e85b3cd5070f1a96b3a5a3b
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-11-19 19:26:48 +01:00
Tatiana Borisova
05acb9e2b9 Delete -Wextra compilation flag for GHS compiler
- GHS compiler doesn't have -Wextra flag and it leads to huge count of warnings.

Pick-to: 6.2
Change-Id: Id2ba654a49fb163bebc75e3a22ecaa1895ecdbe8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-18 09:38:43 +00:00
Eirik Aavitsland
e8f93e38de Rename and restructure the baseline (lancelot) testing code
In preparation for addition of new baseline tests, establish a new
test category, "baseline". This is similar to the category
"benchmarks" in that it contains tests that use the QTest framework,
but conceptually are not unit tests, in contrast to those under auto/.

Move the existing QPainter baseline test, tst_lancelot, into this new
category, and rename it accordingly.

Baseline tests use the QBaselineTest extension to QTest. Move that
extension too into the tests/baseline directory, allowing the clean
out of the baselineserver directory.

Pick-to: 6.2
Change-Id: I1b527f5867c953b1d22be73798fcf7d1494712ea
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-11-16 14:01:50 +01:00
Assam Boudjelthia
e6e8c59485 Android: bump default QT_ANDROID_API_VERSION to 31
To allow using Android 12 APIs.

Pick-to: 6.2 5.15
Change-Id: I5e9da66c84457888ec723125d16876891232a99b
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-12 13:42:08 +02:00
Joerg Bornemann
a3d8a359f1 configure: Fix --foo=bar arguments
This amends commit c5409964b0.

When detecting a variable assignment, we must ignore arguments that
start with a dash.  Otherwise, arguments like --prefix=~/Qt are ignored.

Change-Id: I3b143113b94ca0d8af92679c1f567fbcec298349
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-10 19:21:40 +01:00
Juha Vuolle
605d383a70 CMake: Add CoreBluetooth framework for macOS
The Qt bluetooth module uses ${FWCoreBluetooth} when building for iOS,
but that evaluated to empty.

Pick-to: 6.2
Change-Id: I93ff2c30697a912bed454087ae260fae9cc41b0f
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-10 16:59:17 +02:00
Tor Arne Vestbø
9991ca9163 cmake: Don't notify/warn the user when Xcode is not found
We can technically build without Xcode, as long as the command line
tools are installed. We reflect that by an empty QT_MAC_XCODE_VERSION
variable.

Pick-to: 6.2
Change-Id: I40ffa28a628157e0a2c63656065ea7c41a680e01
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-10 13:47:42 +00:00
Yuhang Zhao
6652bf2353 Bump WINVER, _WIN32_WINNT and _WIN32_IE to _WIN32_WINNT_WIN10 (0x0A00)
And bump NTDDI_VERSION to 0x0A00000B (NTDDI_WIN10_CO) at the same time,
to unblock the developers from accessing the latest Windows APIs.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

qmake templates fixed in 0768a28fbf.

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

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

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

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

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

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

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

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

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

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

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

As a drive-by, clarify one comment.

Amends ca59c20939

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

Amends d2359b2d4e

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

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

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

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

Amends 93fc3afe71 and
ec90f9013b

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

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

Amends 42d3b21c92
and 5a779a4ad3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Amends 87215c70c0

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

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

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

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

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

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

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

This change is basically the CMake equivalent of
326b91ea78

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

We can do 1) without too much trouble.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Amends
6fd1216801f078f65be2cbc748cc459cb6912a4f
9fc302e6d146878103b3d105dce49c7695fcf93a
c368175a9e0a0c120b5bb8a0a02859bfc0cf42ba
in qtdeclarative.

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

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

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

Pick-to: 6.2
Fixes: QTBUG-96870
Change-Id: Icf9c40f571d9c069043604f67ffcf2762966f6d0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-10-15 15:53:23 +02:00
Alexey Edelev
61441074ef Set QT_ANDROID_ABIS when builing qtbase for Android
When building Qt we need to set QT_ANDROID_ABIS value to
CMAKE_ANDROID_ARCH_ABI explictily since the automatical detecting of
android ABI is not executed. This fixes build of the qtbase in-tree
tests.

Fixes: QTBUG-97133
Change-Id: Ica7057bcfcc8f4fe4b5a921ca7449f74cdbca0f1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-10-14 19:57:10 +02:00
Thiago Macieira
dcb281af7d CMake: Make LTO build work
We don't need to check FEATURE_ltcg, just add -fno-lto unconditionally.
That makes QtCore compile with -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

This amends commit 326b91ea78.

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

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

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

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

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

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

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

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

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

Adjust pro2cmake accordingly.

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

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

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

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

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

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

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

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

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

Enable by configuring Qt with -sse2

Pick-to: 6.2
Fixes: QTBUG-63924
Change-Id: Ifeafae20e199dee0d19689802ad20fd0bd424ca7
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-10-05 11:30:06 +10:00
Alexandru Croitor
99899dd299 Revert "CMake: Warn if cmake_minimum_required has an unsupported low version"
This reverts commit 657525965b.

The change relied on reading the last value of the
CMAKE_MINIMUM_REQUIRED_VERSION variable before one of the Qt packages
is found to use it for the version check.

Even if a user project has a cmake_minimum_required() right at
the beginning of the project with a supported version specified,
the first project() call which loads a CMake toolchain file could
contain another cmake_minimum_required() call with a lower
(unsupported) version and that version would be used for the check,
failing the project configuration.

The Android NDK ships such a toolchain file, which requires version
'3.6'.

Thus, relying on the last value of CMAKE_MINIMUM_REQUIRED_VERSION is
not robust enough.

Pick-to: 6.2
Task-number: QTBUG-95018
Task-number: QTBUG-95832
Change-Id: Iff3cb0a46e6e878569dce9c5fe915a714a034904
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-10-04 15:55:10 +02:00
Joerg Bornemann
f6cd55445d Don't export Qt6::ATSPI2_nolink target in Qt6GuiTargets.cmake
We don't have any APSPI2 includes in our public headers and should
therefore not export the target that provides ATSPI2 include paths for
consumers.

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

Pick-to: 6.2
Fixes: QTBUG-97023
Change-Id: I4b12e0c2230917feeb963c02565e6db24f757bd3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-01 18:51:07 +02:00
Alexandru Croitor
657525965b CMake: Warn if cmake_minimum_required has an unsupported low version
Qt6Config.cmake calls cmake_minimum_required to ensure a recent enough
CMake version is used in projects.

That call does not set policies in the calling subdirectory scope,
because find_package introduces a new policy scope.

If a project using Qt has a 'cmake_minimum_required(VERSION 3.1)'
call and is configured with a recent CMake, many policies will
still be set to OLD.

One such policy is CMP0071 (Run AUTOMOC on GENERATED files). The
policy value is queried at generation time rather than at target
definition time, which means we can't influence the policy value
(e.g. inside the implementation of qt_add_executable for example)

The inability to influence the policy value for targets created by our
own CMake functions is unfortunate and can lead to issues (in the case
of the above policy to compilation / linker issues).

Record the version of the last cmake_minimum_required call before
the Qt packages are found and error out if the version is lower than
the minimum supported one.

A project can reduce the error into a warning by specifying a
-DQT_FORCE_MIN_CMAKE_VERSION_FOR_USING_QT_IN_CMAKE_MIN_REQUIRED=3.xyz
option when configuring the project.
If the option is used and build issues arise, no official support is
given.

All the CMake example projects shipped with Qt specify a minimum
version of 3.16 already (which is the minimum for shared Qt builds),
so it shouldn't be an issue to require that in other user projects as
well.

Implementation wise, we follow the existing pattern to record
what the minimum and computed versions for static and shared Qt
builds are at qtbase configure time.
These are then checked before the Qt6 or QtFoo packages are
find_package'd.

Amends 6518bcc167

Pick-to: 6.2
Task-number: QTBUG-95018
Task-number: QTBUG-95832
Change-Id: I1a1d06d82f566c92192a699045127943604c8353
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-10-01 14:32:36 +02:00
Topi Reinio
725b52141d CMake: Introduce QT_BUILD_ONLINE_DOCS flag for documentation builds
QDoc modifies its linking behavior depending on whether the -installdir
command line option was set or not; Without -installdir, QDoc will
use 'https://<url>' to link to targets loaded from external
documentation modules, instead of using relative paths.

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

Pick-to: 6.2
Change-Id: Ib1bbf7b9d784e0c276d2bc520240af4a6c8ba903
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-30 15:38:07 +02:00