Commit Graph

2385 Commits (fa5cb840699b435a4e5a97fc714471b8339dbedd)

Author SHA1 Message Date
Thiago Macieira e0940081bc CMake/ELF: allow using Qt's full version number in the private tags
We added the feature to tag private symbols using the Qt major version
only, because us developers often move between versions and need to keep
compiled code working, even when using private API (we're supposed to
know what we're doing). Linux distributions, however, want to be told
that something used private API and therefore needs to be rebuilt. See
[1][2][3].

Distributors will learn about this feature when updating Qt causes the
existing patch to fail to apply.

[1] https://build.opensuse.org/projects/openSUSE:Factory/packages/qt6-base/files/0001-Tell-the-truth-about-private-API.patch?expand=1
[2] https://src.fedoraproject.org/rpms/qt6-qtbase/blob/rawhide/f/qtbase-tell-the-truth-about-private-API.patch
[3] https://github.com/clearlinux-pkgs/qtbase/blob/main/tell-the-truth-about-private-api.patch

Pick-to: 6.7
Change-Id: I5f663c2f9f4149af84fefffd17bed69026f4038d
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-21 21:13:57 -07:00
Alexandru Croitor 07e7340c0d CMake: Reconfigure whenever module EXTRA_FILES are touched
Otherwise the touched files will not be re-copied and re-installed
until an explicit rerun of cmake.

Pick-to: 6.7
Change-Id: I5abb752b45d8b33885a59363fe987225a89e713a
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-22 00:04:20 +01:00
Alexey Edelev e5bb392f72 Set the missing _qt_is_versionless_target property for versionless targets
Remove the versionless targets handling from pri helpers. This logic is
not relevant anymore since versionless targets hold all the related
properties now.

Amends 173164cd47

Change-Id: I933bf7409a3668333929387b8232d002ab6fa66b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-21 16:23:00 +01:00
Alexey Edelev 840f5c1760 Set the _qt_ module properties for interface targets
The module properties starting with _qt can be set on interface
targets. We should set them to handle _qt_config_module_name
property for Private targets correctly. Otherwise private imported
modules do not land in .pri files as dependencies.

Amends 173164cd47

Fixes: QTBUG-123410
Change-Id: I14866eb407e6ddcbd625f5546cba22ccc7b6a297
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-21 16:22:59 +01:00
Alexey Edelev dc9c67c260 Allow filtering modules that will use pre-built tools
Add the support for QT_INTERNAL_FORCE_FIND_HOST_TOOLS_MODULE_LIST
argument which allows to set the list of tool targets that should not
build their tools if QT_FORCE_FIND_TOOLS is set to ON.

This mechanism doesn't work when crosscompiling.

Change-Id: I597ed766cc741cacf9cb73dd8dd255644c4c9e66
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-20 10:07:21 +01:00
Alexandru Croitor 224b7c6b6a CMake: Allow configuring a minimal subset of examples to deploy
When building examples as part of Qt in the CI, it's best to skip
running deployment for all examples to save resources
(space and time).

Add a QT_DEPLOY_MINIMAL_EXAMPLES option similar to our
QT_BUILD_MINIMAL_STATIC_TESTS option, which will set
QT_INTERNAL_SKIP_DEPLOYMENT at the root examples directory scope, to
skip deployment for all examples.
Each example can then opt into the minimal subset by unsetting the
QT_INTERNAL_SKIP_DEPLOYMENT variable before its
qt_internal_add_example call.

Add Coin instructions to enable this option when building our examples
in the CI.

Pick-to: 6.7
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Task-number: QTBUG-102057
Change-Id: I2efcda455b400c27fe1efd1bcf81b133137fa2d1
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-19 18:22:16 +01:00
Alexandru Croitor c5d0e93199 CMake: Recompute QT_DEPLOY_PREFIX for each built example
The current deployment api implementation sets the value of
QT_DEPLOY_PREFIX based on CMAKE_INSTALL_PREFIX, if no QT_DEPLOY_PREFIX
was previously specified.

This does not work properly when multiple examples are placed in the
same subdirectory and are using deployment api.

Make sure to unset the QT_DEPLOY_PREFIX for each
qt_internal_add_example call, so that a correct prefix is computed for
each example, based on the modified CMAKE_INSTALL_PREFIX value that we
set for each example.

Pick-to: 6.7
Task-number: QTBUG-102057
Change-Id: I931e5f2d683ab94a940e20a2bdfeaa4ac5d8c5f8
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-03-19 17:20:24 +01:00
Alexandru Croitor 270315e019 CMake: Fix finding standalone parts config file for yocto
When building standalone tests of qtsvg targeting yocto, the
standalone parts config file was not found.

That's because it specifies a new CMAKE_STAGING_PREFIX for each built
repo, and the QtSvgTestsConfig.cmake file will be located there,
rather than in QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX, where
the QtBuildInternalsConfig.cmake file is.

So in this case, we always have to prefer looking into
CMAKE_STAGING_PREFIX for the file.

Amends 62905163bf

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I8902381afa4267e40dfb2ad47e44285a806a35e2
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-19 16:04:59 +01:00
Tor Arne Vestbø 5e81a17b22 cmake: Merge Apple platform auto-detect functions
Makes it easier to see the interaction between the different
parts, and extract some of them to apply to a wider set of
platforms later on.

Change-Id: I3dd71dd6ad7a5b2870ab60bfbe4cf31be418bd8a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-19 14:52:48 +01:00
Giuseppe D'Angelo 9ff1e6d80b Add hardening build options
This commit enables hardened-specific checks and codegen, inspired by
GCC 14's -fhardened command line switch and LLVM/libc++'s hardened
modes.

We enable (depending on compiler capabilities):

* -ftrivial-auto-var-init=pattern;
* -fstack-protector-strong;
* -fstack-clash-protection;
* -fcf-protection=full or /CETCOMPAT;
* -D_FORTIFY_SOURCE=3 or 2 on Glibc, depending on the Glibc version,
  provided that some optimization level is enabled (release build or
  optimized debug build);
* on libstdc++, -D_GLIBCXX_ASSERTIONS;
* on libc++, -D_LIBCPP_HARDENING_MODE set to
  _LIBCPP_HARDENING_MODE_EXTENSIVE in debug and to
  _LIBCPP_HARDENING_MODE_FAST in release (_DEBUG is too slow);
* -Wl,-z,relro,-z,now.

This aligns us 100% with -fhardened (we already pass -fPIE and -pie
anyhow). Some Linux distributions already ship GCC/Clang with some of
these options enabled by default.

The check for Intel CET has been amended to always test if the compiler
supports the corresponding flag; and, if so, enable the feature. Before,
it was behind a configure option and the test only checked if the
compiler had CET support automatically active (the test didn't pass
-fcf-protection to the compiler).

The check for -fstack-protector-strong has been made general (rather
than QNX-specific). We don't support QNX < 7 anyhow.

Finally, the qt_config_linker_supports_flag_test test has been
amended to also support MSVC.

All of the hardening options are enabled by default.

[ChangeLog][Build System] Qt builds by default in "hardened mode",
meaning that a series of security-related compiler options are
automatically enabled. In the unlikely case in which these options
constitute an unacceptable performance hit, it is possible to disable
individual hardening options when configuring Qt.

Change-Id: I2c026b0438010ad10d5e7b1136fedf4ae3af8822
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-19 02:52:43 +01:00
Alexandru Croitor 990b60120e cmake: Override generator for iOS projects to Xcode in qt-cmake.in
Instead of maintaining a separate qt-cmake.ios.in wrapper script that
can easily diverge from qt-cmake.in

Change-Id: I53f4eac02188be89a4c11b3e71cde04ac2a24b51
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-03-18 22:34:48 +01:00
Tor Arne Vestbø 7826a96652 cmake: Move iOS detection into qt_auto_detect_ios
We don't need to deal with the input arguments to configure. We
can instead look at QT_QMAKE_TARGET_MKSPEC, like we do when we
auto detect other platforms. This handles both the -xplatform
and the -platform arguments.

Change-Id: I8d987d23e16bfa106833d521f67e8b5a931d9169
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-18 19:04:14 +01:00
Tor Arne Vestbø 70e69f334e cmake: Don't set CMAKE_SYSTEM_NAME=iOS when configuring with -sdk
The -sdk argument is documented as:

  Build Qt using Apple provided SDK <sdk>. The argument should be
  one of the available SDKs as listed by 'xcodebuild -showsdks'.

[ChangeLog][configure] The -sdk argument no longer auto-enables
the macx-ios-clang makespec. Pass -xplatform macx-ios-clang to
explicitly build Qt for iOS.

Change-Id: Ia4074015aba2c8296a65534c38eb2f06db32f286
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-18 19:04:14 +01:00
Tor Arne Vestbø d04cf2c58b cmake: Rename QT_UIKIT_SDK to QT_APPLE_SDK
The SDK is relevant for all Apple systems, including macOS, iOS, tvOS,
watchOS, and visionOS.

We still pick up -DQT_UIKIT_SDK for iOS for compatibility.

[ChangeLog][CMake] The -sdk configure argument now maps
to the QT_APPLE_SDK CMake variable. QT_UIKIT_SDK is still
supported for iOS builds for compatibility.

Change-Id: I983a2f23c2414eb73cd35bb83738088defb45cbd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-18 19:04:14 +01:00
Tor Arne Vestbø 640a3f2474 cmake: Propagate Apple platform build requirements to qconfig.pri
So we don't have to maintain the requirements in two places.

None of the variables removed from the qmake configs are
referenced before we do load(qt_config), so this should
be safe.

Pick-to: 6.7
Change-Id: Iabd5884a2fd1c4b1cd7b44416bebb2624050229e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-14 14:50:36 +01:00
Alexandru Croitor d644f2e02c coin: Add instructions to build standalone examples
If a qt5.git configuration is marked with the StandaloneTests feature,
tell CMake not to build the examples in-tree, and instead use
qt-internal-configure-examples to build the examples out-of-tree.

This brings a couple of improvements:
- higher chance of building examples as ExternalProjects without
  issues
- ability to use deployment api in examples, without installing the
  examples into a main install prefix

The new coin instructions files use a copy of the standalone tests
instructions as a base.

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: If89e6da0b327a38b9c2738f58aa1b5b5fb9fda37
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-03-14 11:44:16 +01:00
Alexandru Croitor 62905163bf CMake: Allow building all examples as standalone just like tests
Introduce a new libexec/qt-internal-configure-examples script that
allows to configure and build "standalone examples" just like
"standalone tests".

This is a prerequisite for using deployment api in examples for prefix
builds, otherwise deployment api gets confused not finding various
information that it expects from an installed qt.

Because the various conditions in the build system for standalone
examples are similar to standalone tests, introduce a new
QT_BUILD_STANDALONE_PARTS variable and use that in the conditions.
The variable should not be set by the user, and is instead set by the
build system whenever QT_BUILD_STANDALONE_TESTS/EXAMPLES is set.

Unfortunately due to no common file being available before the first
project() call, in qtbase builds, per-repo builds and top-level builds,
we need to duplicate the code for setting QT_BUILD_STANDALONE_PARTS for
all three cases.

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: Ia40d03a0e8f5142abe5c7cd4ff3000df4a5f7a8a
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-03-14 11:44:16 +01:00
Alexandru Croitor d298a05ed1 CMake: Move most of CMakeLists.txt into QtBaseHelpers.cmake
Pick-to: 6.7
Change-Id: I19761dbeebdd2529ef0c493a9a61a1c6fe58667b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-03-14 11:44:16 +01:00
Alexey Edelev e7d7eded4c Fix the condition for creating of the plugin init target aliases
Make sure that plugin_init_target is not empty. It's empty when
creating qml plugins.

Amends 566b726b84

Pick-to: 6.7
Change-Id: If23998d50d8d31e20b3966730afb8b4b46b9990c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-13 19:34:22 +00:00
Alexey Edelev 8db0a12e84 Collect CMAKE_MODULE_PATH from QT_ADDITIONAL_PACKAGES_PREFIX_PATH
This is sensitive for the 'include' calls that expect cmake scripts
to be found in some staging prefixes. In yocto
QT_ADDITIONAL_PACKAGES_PREFIX_PATH points to the package image
path(installation snapshot). If repo provides bundled 3rdparties
the 'include' statement that includes 'FindWrap<3rdparty>ConfigExtra'
is unnable to locate it, since it's expected to be found in Qt
installation, but the file didn't land there at ptest stage.

Fixes: QTBUG-122205
Pick-to: 6.5 6.6 6.7
Change-Id: Idd03f44efd2e3fdaa476873068c73ac28cd0a7b5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-13 15:38:52 +01:00
Giuseppe D'Angelo 03baf08d2b QT_NO_AS_CONST: rename and add docs
Give it a name in line with the function name:
qAsConst -> QT_NO_QASCONST, as already done for qExchange.
We can do this because we never documented the macro itself.
So, while at it: also document the macro.

Change-Id: I6eb0834df438e4f4e818ef2cf8e702ed156dc253
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-03-13 13:08:29 +01:00
Alexandru Croitor 566b726b84 CMake: Create alias targets for plugin init targets
When building tests in-tree targeting iOS, we run
_qt_internal_finalize_executable via
qt_internal_add_test_finalizers.
This in turn calls __qt_internal_apply_plugin_imports_finalizer_mode
which tries to link to versioned plugin int targets.

Because the linked plugin init target is built in-tree as well, and
did not have versioned alias targets created, configuration fails
with:
 Target "tst_baseline_qsvgrenderer" links to:

    Qt6::QSvgIconPlugin_init
 but the target was not found.

Make sure to create versioned alias targets for the plugin init
targets.

Amends 6c9f4f5ebc

Pick-to: 6.7
Fixes: QTBUG-123186
Task-number: QTBUG-122181
Change-Id: I0048b724d465dc3c176d238d144feb072262d76e
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-12 21:51:42 +01:00
Alexey Edelev 173164cd47 "Simplify" versionless targets
Versionless targets in Qt6 are interface libraries that link the
versioned libraries using the INTERFACE link type. This makes the
linking chain more complicated than it can be. Also we miss some
significant interface properties in the versionless targets comparing
to the versioned targets.

The new approach manually generates the versionless targets, instead
of using CMake exports.

For CMake versions < 3.18 we now create a copy of the versioned
targets. The copy includes all the relevant INTERFACE properties from
the versioned targets and imported locations for all configs.

For CMake versions >= 3.18 we now create the versionless target ALIASes
which should behave give the transparent access to the versioned
targets.

Using the QT_USE_OLD_VERSION_LESS_TARGETS flag you may force the
behavor of the CMake versions <= 3.18

The change is partial workaround for QTBUG-86533.

Task-number: QTBUG-114706
Change-Id: Iafadf6154eb4912df0697648c031fcc1cbde04e0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-12 20:27:42 +01:00
Joerg Bornemann b481393941 CMake: Add public helper _qt_internal_add_phony_target
This function can be used to create a custom target like
update_translations or all_qmllint that should be excluded from build
and be triggered by the user.

The function works around certain peculiarities of the Visual Studio
project generators that are described at length in QTBUG-115166 and
associated patches.

Follow-up patches in qttools and qtdeclarative will use this function
and remove duplicated code.

Task-number: QTBUG-115166
Task-number: QTBUG-118980
Change-Id: I87b89a658f35a5a09e3f7b04bdd5cae2166f8d62
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-12 12:38:57 +01:00
Lucie Gérard 0886035bcd Correct license for qbatchedtestrunner.in.cpp file
File is is part of the internal test infrastructure.
According to QUIP-18 [1], all test files should be
LicenseRef-Qt-Commercial OR GPL-3.0-only

[1]: https://contribute.qt-project.org/quips/18

Pick-to: 6.7
Task-number: QTBUG-121787
Change-Id: Ia5bc4e0abeea210ee501596330b2b63216e9e9c7
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-03-12 12:38:56 +01:00
Alexandru Croitor dd052a0a01 CMake: Warn when examples are not added via qt_internal_add_example
To ensure examples can be built as ExternalProjects, the example
subdirectories need to be added via qt_internal_add_example rather
than just add_subdirectory.
qt_internal_add_example is also needed for correct installation of
example sources.

To catch examples that are still not added via
qt_internal_add_example, set a QT_WARN_ABOUT_EXAMPLE_ADD_SUBDIRECTORY
variable at the top of the examples/CMakeLists.txt directory scope
and show a warning in qt_add_executable whenever that variable is
TRUE.

Calls of qt_internal_add_example will set the variable to FALSE,
making sure the warning is not shown for properly added examples.

This is limited to developer builds and can be opted out of via the
QT_NO_WARN_ABOUT_EXAMPLE_ADD_SUBDIRECTORY_WARNING variable.

qt_add_executable is used as the 'hook' for showing the error, because
that is the most likely function to be used in examples.
We don't use qt_standard_project_setup in all projects yet, so we
don't want to use that one.

Task-number: QTBUG-90820
Task-number: QTBUG-123096
Change-Id: I7a0b0b2cc60c70903db03b56c06494c127a62420
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-03-11 13:48:23 +01:00
Alexandru Croitor 06fef6219e CMake: Adjust QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES for EP examples
Make sure to consider all qt_prefixes for adjusting
QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES with locations where qml plugin
config files might be present.

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I5a7eec434635db1953871d735e2420c331ccee48
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-03-11 13:48:08 +01:00
Alexandru Croitor 40fa36db22 CMake: Allow specifying additional glob paths for QmlPlugins.cmake
Currently we hard-code to look for qml plugin Config.cmake files
in the current list dir, whether the Qt6Qml directory is.

This is not sufficient for finding qml plugins in a prefix build of a
repo that has not been installed yet.
For example qtquick3d plugins will be in
qtquick3d_build_dir/lib/cmake/Qt6Qml/QmlPlugins, which
won't be picked up by the Qt6Qml Config file in the installed Qt
location.

Allow specifying extra qml plugin glob prefixes via a new
QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES variable.
This is similar to QT_ADDITIONAL_PACKAGES_PREFIX_PATH.

Any path specified via QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES
will have the
 QmlPlugins/${INSTALL_CMAKE_NAMESPACE}*Config.cmake
glob appended to it, and then used for globbing files in that
location, after processing the main location wherever Qt6Qml is.

This will be used by ExternalProject example machinery.

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I469863c965b8b13cf007c611976a64fbff6e9111
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-03-11 13:48:03 +01:00
Alexandru Croitor c668dd4044 CMake: Disable ExternalProject examples for -debug-and-release builds
Unfortunately when using CMake <= 3.27 together with
-debug-and-release, it's not possible to reliably build examples as
external projects due to clobbered files in the same build dir.

Disable building examples as EPs in such a case.

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: Icea9fdab47986c2608e1952a0bbae72365ac7a62
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-11 13:48:01 +01:00
Alexandru Croitor 31c5d50e84 CMake: Adjust CMAKE_MODULE_PATH for ExternalProject examples
When building EP examples for a repo that defines a bundled library,
we need to make sure the relevant FindWrapBundledFooConfigExtra.cmake
file is found when looking up dependencies.

For a prefix build, that file is placed in the build dir of the repo.
Use the list of qt_prefixes that includes the build dir of the repo,
append lib/cmake/Qt6 to it and pass that as additional values to
the CMAKE_MODULE_PATH variable of the external project.

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I85d5f360380856fcfb8be7235b8365dcf15aa0c0
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-11 13:47:59 +01:00
Alexandru Croitor cc537d927b CMake: Fix syncqt IMPORTED_LOCATION path for multi-config builds
When building examples as ExternalProjects as part of a multi-config
qtbase build, syncqt can not be located with the following error:

CMake Error at Qt6CoreToolsAdditionalTargetInfo.cmake:10 (message):
   Unable to add configure time executable Qt6::syncqt
   qtbase/libexec/syncqt doesn't exist
Call Stack (most recent call first):
  qtbase/lib/cmake/Qt6CoreTools/Qt6CoreToolsConfig.cmake:44 (include)
  qtbase/cmake/QtPublicDependencyHelpers.cmake:65 (find_package)
  qtbase/lib/cmake/Qt6Core/Qt6CoreDependencies.cmake:34
      (_qt_internal_find_tool_dependencies)
  qtbase/lib/cmake/Qt6Core/Qt6CoreConfig.cmake:42 (include)
  qtbase/lib/cmake/Qt6/Qt6Config.cmake:165 (find_package)
  CMakeLists.txt:13 (find_package)

The Qt6CoreToolsAdditionalTargetInfo.cmake file is used both for
install(EXPORT) Config files as well as export(EXPORT) Config files,
and in the latter case, the path that syncqt is looked up in is not
correct because syncqt is not yet installed.

In addition to checking whether syncqt exists in the install path,
also check if it exists in the build dir.

Ideally the additional path would be stored in a separate file that
is not installed, but the current code infrastructure does not provide
such a feature. Because we store a relative path instead of an
absolute path, the build path does not leak, so the situation is
bearable.

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I16ad5c280751e050bc9b039ebd38ec9a66a6554c
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-11 13:47:57 +01:00
Alexandru Croitor 20bd9fad1c CMake: Pass CMAKE_MODULE_PATH to external project examples
Some examples depend on FindWrapFoo.cmake scripts that are part of
a repo. An example is qtgrpc with FindWrapProtoc.cmake.

These need to be available when building external project examples in
a prefix build where the repo is not installed yet, and thus the
source dir FindWrap scripts need to be used instead.

Make sure to pass the value of CMAKE_MODULE_PATH to the external
projects to ensure these scripts are found. CMAKE_MODULE_PATH is
populated by qt_set_up_build_internals_paths as part of the
qt repo build.

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I3e977919bc137ed60e8eb9300625e5d8b87b373e
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-11 13:47:55 +01:00
Alexandru Croitor 43d0c5ed6e CMake: Allow passing extra variables to external project examples
In some repos we need to be able to pass extra cache variables to find
3rd party packages when building examples as external projects.

Introduce QT_EXAMPLE_CMAKE_VARS_TO_PASS to allow passing vars like
OpenSSL_ROOT or Protobuf_ROOT if they are set in the repo project.

It should be noted that QT_EXAMPLE_CMAKE_VARS_TO_PASS expects a
special syntax for its values, of the from VAR_NAME:CMAKE_TYPE, due
to the pre-existing implementation on how we pass variables
to ExternalProject.

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: Ie3e74d4fde106f947d12e51d27e41a310157aab6
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-11 13:47:53 +01:00
Mitch Curtis d130886997 configure-cmake-mapping.md: add -qt-host-path and -DQT_HOST_PATH
Pick-to: 6.5 6.6 6.7
Change-Id: I6deb7b648c39adb8fb2765de5be29b0743ef2836
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-08 10:30:10 +08:00
Giuseppe D'Angelo 9069b7fb20 Realign columns in the configure-cmake-mapping
Change-Id: Ie7c3c35b6e5a8d02d05650b86f6c2d47b72c3835
Pick-to: 6.7 6.6 6.5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-07 16:09:57 +01:00
Lucie Gérard bf1e76408e Change license for .in files
According to QUIP-18 [1], all build system files
should be BSD-3-Clause.
The files in this patch are part of the build system.

[1]: https://contribute.qt-project.org/quips/18

Pick-to: 6.7
Task-number: QTBUG-121787
Change-Id: Ibc6a60a9b009fab0c953e8e3269533c121e4511e
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-03-05 12:59:21 +01:00
Alexandru Croitor aacc31815d CMake: Fix assignment in internal_get_build_vars_for_external_projects
The check and variable name were incorrect after a refactoring.

Amends ba96238600

Pick-to: 6.6 6.7
Task-number: QTBUG-84884
Task-number: QTBUG-90820
Change-Id: I33b6b81695a6352c7869ef6186e00881b47bd6f3
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-03-05 12:59:21 +01:00
Alexandru Croitor 375f386930 CMake: Don't add default rpaths to qt qml plugins when requested
qt_add_qml_plugin has code to set a sensible install rpath for user
project qml plugins.

If Qt was configured without rpath support, we should not add any
rpaths to qt qml plugins:
- qt-computed rpaths added by qt_apply_rpaths
- user-project rpaths added by qt_add_qml_plugin

This is done by setting QT_NO_QML_PLUGIN_RPATH to TRUE as part of
QtSetup, effectively applying the option to any qml plugin that is
built by internal qt api.

User projects will still be able to use the default rpaths added
by qt_add_qml_plugin, even if qt itself was configured with no rpath
support.

Pick-to: 6.7
Fixes: QTBUG-122687
Change-Id: I8178b527553dd00436d0abb3b44061ea16edc121
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-03-05 12:59:21 +01:00
Joerg Bornemann 110f656da9 configure: Translate only boolean options to features
This amends commit be009c6857.

The configure option -no-opengl was mistakenly translated to the CMake
argument -DFEATURE_opengl=no. The command line option "opengl" however
is defined as
    qt_commandline_option(opengl
        TYPE optionalString
        VALUES no yes desktop es2 dynamic
    )
which is not boolean. And only boolean command-line options may
automagically control features of the same name. It just happens that
the values "no" and "yes" look boolean.

Setting FEATURE_opengl instead of INPUT_opengl broke feature conditions
that check the INPUT_opengl value.

Fix this by checking the type of the corresponding command line option
instead of guessing the type from the INPUT_* value.

An option (e.g. force-asserts) can be diverted to a differently named
input (e.g. force_asserts) with the NAME argument of
qt_commandline_option. In this case, we cannot deduce the option name
from the input's name. To handle this, we store the input's type in
commandline_input_${name}_type and read it when translating feature
values.

Fixes: QTBUG-122914
Change-Id: Ibb4b0633b6635bd2ef6f26ed8f4b19d239bf5854
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-05 12:59:21 +01:00
Samuli Piippo 762c56d65b CMake: add options to not generate target wrappers
The target wrappers for qmake and qtpaths do not work on Yocto
builds and only create confusion when they are available in target.
Add option to disable their generation.

Pick-to: 6.7
Task-number: QTBUG-122420
Change-Id: Ibb829cc846ad6c470fe29e746ade42fccaa33a6f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-05 12:30:15 +02:00
Tor Arne Vestbø 5736e0b655 cmake: Allow silencing CMake generator warning from environment
Pick-to: 6.7 6.6 6.5
Change-Id: I13d3000121be39f204b4374118690fe27702dd12
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-04 20:31:47 +01:00
Morten Sørvig 6bf3f7ebdc wasm: remove DISABLE_EXCEPTION_CATCHING workaround
Qt no longer sets DISABLE_EXCEPTION_CATCHING and can
use the common logic here.

Task-number: QTBUG-121822
Change-Id: If02feafe9eeac49fa2861d2357b358a19e756438

Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2024-02-27 14:09:32 +01:00
Morten Sørvig d795dbc643 wasm: don't set DISABLE_EXCEPTION_CATCHING
This is on by default anyway (see Emscripten settings.js),
and setting it here interferes if exceptions are enabled
by other means.

Fixes: QTBUG-121822
Change-Id: I61d3f1960208e928a4144cff56a0b03c39087a34
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2024-02-27 14:09:32 +01:00
Alexey Edelev 2c0120d35b Add the support for custom definitions to the qt_manual_moc function
The function now support two new arguments:
 - DEFINITIONS, which allows specifying the custom definitions
 - TARGETS, the list of targets thart will be used to collect
   the [INTERFACE_]INCLUDE_DIRECTORIES and COMPILE_DEFINITIONS.

Task-number: QTBUG-104898
Change-Id: I3f67537057f91a97597788f1bd4db6904bac6d9c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-02-23 20:41:30 +01:00
Alexey Edelev 7ac969e146 Wrap condition in _qt_internal_check_depfile_support with parentheses
The AND/OR combinations are not evaluated correctly. Wrap them with
parentheses explicitly to ensure the expected evaluation order.

Pick-to: 6.5 6.6 6.7
Change-Id: Ib2515ba85417b32cef3f799e0cb2c89d2c4257ab
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-02-22 16:08:32 +01:00
Joerg Bornemann b387a6cd8a CMake: Rename I18N_*LANGUAGES variables and parameters
...according to the Qt 6.7 CMake API review.

Pick-to: 6.7
Task-number: QTBUG-122396
Change-Id: I42012e346325ff05d63fa4dac44276eef15320fe
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-02-21 18:21:41 +01:00
André Klitzing f926ccbf64 Add newline after import
This avoids -Wnewline-eof for clang compilers.

error: no newline at end of file [-Werror,-Wnewline-eof]
    Q_IMPORT_PLUGIN(Governikus_AnimationsPlugin)

Pick-to: 6.7 6.6 6.5
Change-Id: I8de21f1f27cd177211ebf70fac0e01292cfa410c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-02-21 18:21:41 +01:00
Alexandru Croitor 3334a77ecf CMake: Teach qt_config_compile_test to set the build output
The qt_config_compile_test command now assigns the build output of a
config test to the TEST_${name}_OUTPUT variable in the callers scope.

We can use this to show error messages, and it can also be seen in
trace files for better troubleshooting.

It works for all project based calls with CMake 3.16, but for source
code based tests, due to the usage of check_cxx_source_compiles instead
of try_compile, it will only work for CMake 3.23+.

Pick-to: 6.5 6.6 6.7
Task-number: QTBUG-122596
Change-Id: Ib9664c158ba9a391bd17bf30a28f9a34eba991d5
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-02-21 18:21:41 +01:00
Lorn Potter 87738e8b81 wasm: update Emscripten to 3.1.50
Pick-to: 6.7
Change-Id: Id147a927420a1743ef1cfd952b36e90ac0c319dd
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2024-02-21 12:30:01 +00:00
Alexandru Croitor 573778de60 CMake: Introduce a CMake coding style document
Better to have something, than nothing at all.

Mention it in the cmake readme.

Task-number: QTBUG-120225
Change-Id: Ieffeeaac714b89d5d8b5a8b0c51abf3fe8e0a6c6
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-02-19 16:41:47 +01:00