Commit Graph

2019 Commits

Author SHA1 Message Date
Alexey Edelev
0b59c204a4 Add qt_configure_file_v2 function
The function does the same as the original one but respects semicolons
in CONTENT argument due to the use of the cmake_parse_arguments variant
with PARSE_ARGV.

Change-Id: I263662dc18e411a735b586995b82791fc6b888ea
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-21 14:00:37 +02:00
Ulf Hermann
00b9409843 Android: Disable androidtestrunner extra timeout
We already have:

a, a timeout as part of QtTest. By default it lets each test function
   run for 5 minutes. This timeout can be configured using
   QTEST_FUNCTION_TIMEOUT.
b, maxTimeBetweenOutput in the CI. The CI will kill the process if too
   much time passes between individual output lines of a test.
c, maxTimeInSeconds in the CI. This does exactly the same as the
   androidtestrunner timeout.

The CI timeouts can be centrally tuned per platform and Qt module. This
is preferable over a special timeout just for android.

As other people may be using androidtestrunner for unrelated projects,
don't delete the timeout, but simply disable it from CMake by setting
it to -1.

Task-number: QTBUG-106479
Task-number: QTBUG-101596
Task-number: QTBUG-100242
Change-Id: If4ce00948e204182bb12ac4859d3b0dd193de7ad
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-09-21 14:00:37 +02:00
Mikolaj Boc
a5205d983b Set NO_EXCEPTIONS on executables on wasm
This reflects the true state of exceptions on WASM, which are always
disabled (DISABLE_EXCEPTION_CATCHING is always set with 1).

Change-Id: I7b681846159caf61f291f78a7b4ddf5260dc341f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-19 12:44:21 +02:00
Mikolaj Boc
bb582f7fd5 Use the js test runner for all tests on wasm
Make cmake changes that have ctest run the emrun test runner for
all tests that are build for wasm.

Change-Id: I8c07068d79cfd0d745dbcc3d3f025c7c48fe1069
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-19 08:54:02 +02:00
Alexandru Croitor
469dbe5c6d CMake: Fix _qt_is_test_executable assignment for tests
_qt_is_test_executable can only be set on a test that is backed by a
real target. QMLTESTs might not backed by an executable target, if
they are missing cpp SOURCES.

Which led to errors like

 CMake Error at
  cmake/QtTestHelpers.cmake:510
 (set_target_properties):
  set_target_properties Can not find target to add properties to:
  textedit
 Call Stack (most recent call first):
  tests/auto/qmltest/textedit/CMakeLists.txt:10 (qt_internal_add_test)

Amends 62c681a599

Change-Id: Ie66fd3e94484562061f851c0a034629959d091da
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-09-17 00:30:39 +02:00
Alexandru Croitor
865b1721bd CMake: Fix return value of applicationName() on macOS
QCore::applicationName() is influenced by what values we insert into
the Info.plist file of an application bundle.

We accidentally inserted tokens like ${PRODUCT_NAME} that are meant to
be expanded by xcodebuild, even when using a generator like Ninja.

This caused the applicationName() to report "${PRODUCT_NAME}".

Make sure to only call relevant finalizers for macOS applications
when using a generator other than Xcode.

Amends d5580aa719

Pick-to: 6.4 6.4.0
Fixes: QTBUG-106652
Change-Id: Idbc9c84557a8f17b1302e6969f6eb317e3ef225d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-09-16 14:32:51 +00:00
Mikolaj Boc
62c681a599 Set target property _qt_is_test_executable on all tests
This is needed to later determine what kind of runner should be
selected on WASM for the executable. Tests use the test runner,
whereas other executables use qtLoader.

Change-Id: I75aa361403b72f8e82a288967b8a81b8232d68dc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-16 16:32:51 +02:00
Alexandru Croitor
59e08d2105 CMake: Add function to get tool wrapper shell script path
The _qt_internal_wrap_tool_command function has a limitation
that it is not possible to use it when a command needs to be wrapper
in a generator expression.

Provide a lower level API called
_qt_internal_get_tool_wrapper_script_path
to just get the path to the wrapper script, ensuring that the script
is created if needed.

Deprecate _qt_internal_wrap_tool_command, in favor of replacing it
with the new API.

Pick-to: 6.4
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: Ie4a4a17178bf2061ae01ee2b03b052d84560abf9
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-09-15 22:47:12 +02:00
Alexandru Croitor
74083599f8 CMake: Rework tool wrapper shell script creation
Instead of creating the tool wrapper shell script only
during a Qt build in QtBuild.cmake,
ensure it is created any time _qt_internal_wrap_tool_command is
called, regardless if we're building Qt or a user project.

As a transitional period not to break compatibility, we also need
to create the script in QtBuild.cmake, until all usages of
QT_TOOL_COMMAND_WRAPPER_PATH are replaced with function calls.
Currently such usages are present in qtdeclarative.

When considering which bin dirs to add to the script's PATH
environment variable assignment, in addition to the build
internals relative bin dir, also add QT_BUILD_DIR,
QT_ADDITIONAL_PACKAGES_PREFIX_PATH and QT6_INSTALL_PREFIX.

QT_BUILD_DIR is important so we always pick up the just-built
but not installed libraries in a prefix build when running just-built
tools.

QT_ADDITIONAL_PACKAGES_PREFIX_PATH is important when building examples
as ExternalProjects in prefix builds, to ensure that the
not-yet-installed tools and libraries are picked up from the repo
build dir, which is passed via QT_ADDITIONAL_PACKAGES_PREFIX_PATH
to the external projects.

QT6_INSTALL_PREFIX is there in case if the build internals relative
dir is located in a different places than the Qt6 package.

Pick-to: 6.4
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I4d76fbbc275ca961379971054f87991adac36539
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-09-15 22:47:12 +02:00
Alexandru Croitor
828e402a19 CMake: Move __qt_internal_prefix_paths_to_roots
Move it into QtPublicCMakeHelpers.cmake so it is available also when
configuring qtbase and the Qt6Config.cmake file is not yet loaded.

Pick-to: 6.4
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I88127fe0439ae26af1d125eb584244d315574a48
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-09-15 22:47:12 +02:00
Alexandru Croitor
59f0f25f71 CMake: Move __qt_internal_collect_additional_prefix_paths
Move it out of QtConfig.cmake.in into QtPublicCMakeHelpers.cmake
so that the Qt6Config file is less cluttered.

Pick-to: 6.4
Change-Id: I772a0cca35d5c03cd688c3f1de34984484444105
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-09-15 22:47:12 +02:00
Joerg Bornemann
c9c04291f5 CMake: Add Linux support to qt_deploy_runtime_dependencies
Before this change, qt_deploy_runtime_dependencies supported Windows and
macOS only.  We add a generic deployment method implemented in
cmake-language with file(GET_RUNTIME_DEPENDENCIES).  This deployment
method is now enabled for shared builds on Linux.

The file(GRD) command requires that the EXECUTABLE argument points to
the executable in the build directory.

Only libraries in Qt's installation directory are considered for
deployment.  This includes Qt's own libraries and also things like
libicu*.so we're shipping with the installer.

Unlike macdeployqt and windeployqt, the generic
qt_deploy_runtime_dependencies does not yet support deploying
translations.  We will catch up on this in a later commit.

Change-Id: Iea23abcdba774d4c1885c8d2c243eb3e48fb7fae
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-15 12:55:23 +02:00
David Skoland
3bd54f285d wasm: Replace QT6_INSTALL_PREFIX with WASM_BUILD_DIR in cmake helper
The change b515fa56a3
introduced checking the emsdk version of a qt installation.
However, this checked for QT6_INSTALL_PREFIX where it may not be
defined. This fails when trying to build tests because
when configuring tests, it calls into add_target_helpers which
calls into this logic, and QT6_INSTALL_PREFIX is set after
this is called into, causing the qconfig.h lookup to fail.
To fix this so it works in all conditions,
we need to check if either install prefix or
build_dir is set and use whichever is set.

Pick-to: 6.4
Change-Id: I3cf7e20d3d830f04e5b632fc51d8bf3b2758a717
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-13 18:13:00 +02:00
Alexey Edelev
ac74b60c9c Add function to add and compile executables at configure time
qt_internal_add_configure_time_executable compiles the executable
at configure time and exposes it to the CMake source tree. This is
useful when need to run a small C++ program at configure time.

Task-number: QTBUG-87480
Change-Id: I031efe797c8afa0721d75b46d4f36f67276bf46e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-13 00:50:47 +02:00
Alexey Edelev
553185e8c3 Skip AUTOGEN for config files
Amends c7d1d56b09

Task-number: QTBUG-103196
Change-Id: I319ca96bb54b9d0274270790d8c92151ea3398f0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-12 20:31:04 +02:00
Alexey Edelev
0c1368c7e4 Move the tool look-up functionality to a separate function
Change-Id: Ibe9ef9de981afac4b585068c62eef5af01989417
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-12 20:09:03 +02:00
Alexey Edelev
c7d1d56b09 Add <module>-config[-p].h files to the module sources
<module>-config[-p].h files need to be added to the CMake source tree

Amends 8539e641f6

Task-number: QTBUG-103196
Change-Id: I8baaa672ad869da8a030d890da8bdea5bd8c7794
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-09 17:04:16 +02:00
Morten Sørvig
8c959a3609 wasm: don't set GL_DEBUG
This spams the console with "writeStackCookie"/"checkStackCookie"
messages, which makes finding relevant debug output harder.

Pick-to: 6.4
Change-Id: I352b633f02f9ecc1333d1d91f5ffc21a4a937e53
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
2022-09-08 12:15:24 +00:00
Alexey Edelev
5d38e1f295 Suppress the PUBLIC/PRIVATE_HEADER related warning
Avoid adding module header files to a PUBLIC/PRIVATE_HEADER for the
modules. All header files are installed using install(FILES call, but
not as a part of install(TARGET

Amends 8539e641f6

Task-number: QTBUG-103196
Change-Id: Ib95295112c74f74f237e3738d2532f9049d26ce6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-07 21:15:49 +02:00
Ivan Solovev
b83fc9f41a CMake: propagate deprecations definitions to tools and apps
If Qt itself is built without the deprecated APIs, so should be the
tools and apps.

This patch makes sure that the specified QT_DISABLE_DEPRECATED_UP_TO
and QT_WARN_DEPRECATED_UP_TO values are correctly used in the internal
tools and apps.

Fixes: QTBUG-105102
Change-Id: I7a51bddbd839c7b71efa0bff8ec959df64c53b82
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-07 19:51:38 +02:00
Alexey Edelev
8539e641f6 Respect CMake source tree when installing header files
Use CMake source tree when installing header files instead installing
all header files that syncqt.pl produces. This avoid adding header
files which cannot be used because of platform or feature
incompatibility with Qt version. Since syncqt.pl doesn't respect CMake
build tree when generating master header and CaMeL case header files,
these header files still will be installed regardless platform or
feature limitations. This will not be the case once we switch to
syncqt.cpp, which will install only headers that are relevant to the
selected platform and enabled features.

Task-number: QTBUG-103196
Change-Id: I7d64754648747bee700d96f2fd6228fe7248512e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-07 14:39:25 +02:00
Ivan Solovev
734e0a2fbe CMake: propagate deprecation definitions to unit-tests
If Qt itself is built without the deprecated APIs, but the tests are
not, tests will fail to compile and/or link.

This patch makes sure that the specified QT_DISABLE_DEPRECATED_UP_TO
and QT_WARN_DEPRECATED_UP_TO values are correctly used in the tests.

The definitions are propagated to tests, batched tests, manual tests
and benchmarks.

Fixes: QTBUG-104858
Change-Id: Idf15accaf96c47599084426ba625b985f507ca8b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-06 16:57:58 +02:00
Morten Sørvig
b4f31336e3 wasm: suppress pthreads-mem-growth warning
Suppress the pthreads-mem-growth warning for developer builds.
We (the Qt developers) are aware of the issue, so we don't
need the reminder.

Change-Id: Ib924a4dd87b8647d5f1052ab40c0ddf4b9f42108
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-09-06 10:48:10 +02:00
Rolf Eike Beer
60829b0b25 CMake: allow user specified boolean values to have any case
When running something like this:

    cmake -D FEATURE_xkbcommon=On qtbase

one would run into issues like:

    CMake Error at cmake/QtFeature.cmake:254 (message):
      Sanity check failed: FEATURE_xkbcommon has invalid value "On"!
    Call Stack (most recent call first):
      cmake/QtFeature.cmake:396 (qt_feature_check_and_save_user_provided_value)
      cmake/QtFeature.cmake:606 (qt_evaluate_feature)
      cmake/QtFeature.cmake:575 (qt_feature_module_end)
      src/CMakeLists.txt:12 (qt_feature_evaluate_features)

Change-Id: I33a921625b97aeb3c423cb7c1fb1bd3b05ce24a7
Pick-to: 6.4 6.3 6.2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-05 06:49:34 +02:00
Mikolaj Boc
1e00ddc2cb Do not query for the nonexistent QT_FEATURE_exceptions feature
The feature does not exist. Do not query for it and assume it's always
off for the purpose of WASM build.

Change-Id: I7e76242c9b3423bfe16872f668c60dae2e74fabe
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-02 21:02:27 +02:00
Mikolaj Boc
aeb33b7d61 Add NO_EXCEPTIONS on WASM unconditionally
DISABLE_EXCEPTION_CATCHING is added unconditionally on WASM. Add
NO_EXCEPTIONS for all WASM tests since those are never supported.

Change-Id: I2ee10779e7ae0d285494ad650be52dee3099915a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-02 21:02:27 +02:00
Mikolaj Boc
e38807996f Add wasm target helpers in a finalizer when adding executable
This way it is able to pick up all of the properties assigned to it
before finalization.

Change-Id: I9da635f8620859a669c4e4d589fff56a3ce42ab9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-02 11:35:51 +02:00
Alexey Edelev
0255cce4de Use the INSTALL_CMAKE_NAMESPACE to locate module tools target
Replace hardcoded Qt6 prefix of module tools target when setting
the name of tools package.

Change-Id: Icb6f38cce766c9d32216a65a8a5ce9552d622b72
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-01 21:37:11 +02:00
Mikolaj Boc
67deefbaaa Build in test data on WASM
Local file system files are difficult to reach on WASM. Build the test
data in so that it's reachable to WASM tests nevertheless.

Change-Id: I65022db7645248d040434759fb60c3076fd65bd8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-01 19:44:20 +02:00
Morten Sørvig
df76a0585f wasm: set ALLOW_MEMORY_GROWTH for multi-threaded builds
Unify the settings for single-threaded and multi-threaded builds;
Qt now always enables heap growth by default.

This means we don't have to reserve a large (1GB) fixed memory
size, but can instead set the smaller (50 MB) initial memory size,
like the single-threaded build does.

Enabling threads + memory growth can potentially cause
a performance regression when accessing heap memory from
JavaScript (https://github.com/WebAssembly/design/issues/1271).
We leave it for the application to decide if this applies,
and if the switch to fixed memory should be made.

Change-Id: I96988b072506456685086e55aca4007a146bd70f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-09-01 15:42:28 +02:00
Lorn Potter
b515fa56a3 wasm: add Emscripten version check for apps
This will tell developers if they are using the wrong version which may
not build or might cause other issues.

Pick-to: 6.4
Fixes: QTBUG-105922
Change-Id: Ic5c4549d5637182dce380e415f131e33a4da416f
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-09-01 11:17:30 +10:00
Mikolaj Boc
619cb795b2 Plug the WASM batched test runner into the build system
The new batched test runner is now used for running the tests instead
of the wasm shell, which runs for single test cases.

Change-Id: I7b7e6dd7993ba7937124c5843356b6891301b893
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-31 16:53:52 +02:00
Alexandru Croitor
51f8eaa328 CMake: Move Apple specific functions into a separate file
Pick-to: 6.4
Task-number: QTBUG-95838
Change-Id: Ib0ce53fe0e2068482b654921ecba3232efe656c8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-30 20:36:13 +02:00
Morten Sørvig
be44827240 wasm: add support for building Qt as shared libraries
This implements the build system bits required to build Qt
as as separate wasm modules a.k.a Emscripten side modules.

Enable by configuring with the "-shared" flag.

This is the first step towards shared library support and gets
us as far as being able to load QtCore and instantiate a
QCoreApplication.

Task-number: QTBUG-63925
Change-Id: Ib8f07f80fb5b13c8dbba65c7db735dc557b70d0e
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-08-30 22:11:01 +10:00
Lorn Potter
83b7598896 wasm: update emsdk to 3.1.14
This fixes some threading bugs

Pick-to: 6.4
Change-Id: I1a96dcc54d8338de09b551d52a166d073e85d752
Reviewed-by: Aleksandr Reviakin <aleksandr.reviakin@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-08-30 11:22:56 +10:00
Tor Arne Vestbø
30489eb661 Bump macOS and iOS deployment targets to 10.15 and 14 respectively
Change-Id: I1ffaa77f3a4194d2ab02729ff525e5f831e3b7a8
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-29 18:55:24 +02:00
Mikolaj Boc
ecbbb75585 Relay the batched test name to ctest commandline on all platforms
Extend the support of pointing at the right test from batch from WASM
to all supported platforms.

Change-Id: I9b6342ed0954f0fdc2f08c76f6b3f24f44f0388a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-29 18:55:24 +02:00
Mikolaj Boc
d7ea07c8c1 Make it possible to mark a test as non-batchable
This is useful in some cases where extra parameters have to be set on
the test target.

Change-Id: Ic727fdaf0bc9c2e1c684d1a86352d31c0f974477
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-26 14:15:24 +02:00
Mikolaj Boc
b9053b55f8 Place test helpers in batched test output directory unless overridden
Change-Id: Ica209d10773d1acc38c3bad934cb53856e6a6c2a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-26 00:23:11 +02:00
Mikolaj Boc
b134300bc4 Make qt_internal_test_batch_target_name publicly available
The batch test target name is a useful thing to obtain in various
target-generating scripts.

Change-Id: I9605cf860fe1485e48108eba7e93f9064209d8fb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-25 18:04:19 +02:00
Alexandru Croitor
c81da821c4 CMake: Remove NSHumanReadableCopyright from iOS Info.plist
The key only applies to macOS bundles. Also, qmake doesn't have it.

Pick-to: 6.4
Task-number: QTBUG-95838
Change-Id: I438f0079cc7b74672dfbe956769138a8bb006669
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-25 17:28:15 +02:00
Alexandru Croitor
f16c7e15a2 CMake: Default CFBundleDevelopmentRegion to $(DEVELOPMENT_LANGUAGE)
That's what new projects in Xcode set.

Pick-to: 6.4
Task-number: QTBUG-95838
Change-Id: Id07dca0f56c8849a93085c5d36910679e45381b4
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-25 17:28:15 +02:00
Alexandru Croitor
c0bb65ec02 CMake: Replace tabs with spaces in iOS Info.plist template
Change-Id: Ied8f31a22c14688fd250955bb54f161f07bea90b
Pick-to: 6.4
Task-number: QTBUG-95838
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-25 17:28:15 +02:00
Joerg Bornemann
a021b5e09f CMake: Don't write QMAKE_PRL_BUILD_DIR to Qt's .prl files
Having the build directory encoded in installed files impedes
reproducible builds.

QMAKE_PRL_BUILD_DIR is exclusively used by qmake if 'depend_prl' or
'fast_depend_prl' is active.  This is useful for tracking the
interdependencies of libraries within a project but not for Qt's installed
libraries.  Even the qmake-based Qt build never used this feature.

Fixes: QTBUG-97386
Change-Id: Icd0801edc1ad92a99fff3a1e92b5f660914813b2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-24 15:50:25 +00:00
Mikolaj Boc
8d728a0ed9 Implement the batch_tests feature
An approach of test batching (joining multiple tests into a single
binary) has been taken, due to long linking times/binary size on certain
platforms, including WASM. This change adds a new feature
'batch_test_support' in Qt testlib. Based on the value of the feature,
test batching may become enabled with the -batch-tests switch.

Batching works for every target added via qt_internal_add_test. When
first such target is being processed, a new combined target for all of
the future test sources is created under the name of 'test_batch'.
CMake attempts to merge the parameters of each of the tests, and some
basic checks are run for parameter differences that are impossible to
reconcile.

On the C++ level, convenience macros instantiating the tests are
redefined when batch_tests is on. The new, changed behavior triggered
by the changes in the macros registers the tests in a central test
registry, where they are available for execution based solely on their
test name. The test name is interoperable with the names CMake is aware
of, so CTest is able to run the tests one by one in the combined binary.

Task-number: QTBUG-105273
Change-Id: I2b6071d58be16979bd967eab2d405249f5a4e658
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2022-08-24 02:46:37 +02:00
Lucie Gérard
32df595275 Change the license of all CMakeLists.txt and *.cmake files to BSD
Task-number: QTBUG-105718
Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-23 23:58:42 +02:00
Alexey Edelev
f3f0d646b9 Add possibility to store source files for interface targets
Add source files to the _qt_internal_target_sources property, when
running qt_internal_extend_target on interface libraries instead of
ignoring sources for CMake versions that don't support non-interface
properties. The property is not full-functional, but still allows to
execute internal routines on target sources.

Also add qt_internal_get_target_sources_property function that helps
to destinguish which property stores target sources.

Task-number: QTBUG-103196
Change-Id: I435c558090a24a7988f1a1c49f924dc195e72480
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-19 23:53:11 +02:00
Ivan Solovev
2625a3a01a Add -disable-deprecated-up-to parameter to configure script
And also teach CMake to treat it properly instead of hardcoding the
version number.

[ChangeLog][Build System] The configure script now accepts a new
parameter -disable-deprecated-up-to which is used to remove all
deprecated code from API and ABI while building the libraries.
The version number must be specified in a hex format.
For example, it can be used like this:
 /path/to/qt/configure -disable-deprecated-up-to 0x060500
to remove all code deprecated in Qt 6.5.0 or earlier releases.

Task-number: QTBUG-101510
Change-Id: I557cf83e29b867fa1052bb097985e144b5eaf34d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-19 23:52:05 +02:00
Ivan Solovev
18f0484a0e Rename QT_DEPRECATED_WARNINGS_SINCE -> QT_WARN_DEPRECATED_UP_TO
The new name describes the behavior in a better way.

[ChangeLog][Build System] The QT_DEPRECATED_WARNINGS_SINCE macro is
renamed to QT_WARN_DEPRECATED_UP_TO. The old name is deprecated, but
is still recognized if it is defined during configuration and the
new name is not defined.

Fixes: QTBUG-104944
Change-Id: I320c033010dfab120db6922598454f95169657f7
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-19 23:52:05 +02:00
Ivan Solovev
3226c82740 Rename QT_DISABLE_DEPRECATED_BEFORE -> QT_DISABLE_DEPRECATED_UP_TO
The new name describes the behavior in a better way.

[ChangeLog][Build System] The QT_DISABLE_DEPRECATED_BEFORE macro is
renamed to QT_DISABLE_DEPRECATED_UP_TO. The old name is deprecated, but
is still recognized if it is defined during configuration and the new
name is not defined.

Task-number: QTBUG-104944
Change-Id: Ifc34323e0bbd9e3dc2f86c3e80d4d0940ebccbb8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-08-19 23:52:05 +02:00
Alexandru Croitor
459f714662 CMake: Add COMMAND_ECHO option to _qt_internal_create_command_script
Pick-to: 6.4
Change-Id: I7884855b7934c1f65d8699759408f5c89632ba11
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-17 21:21:57 +02:00
Alexandru Croitor
edb88a3b29 CMake: Move _qt_internal_create_command_script to a public file
It's needed for creating qmake build tests.

CMake / CTest has a limitation of not allowing to create single-config
tests when using a multi-config generator using the add_test(NAME)
signature.

Using add_test(NAME) forcefully creates per-config tests, which means
that it's not possible to just run ctest to execute tests, without
specifying a -C parameter, which we do in the CI.

qmake tests need to use the add_test(NAME) signature
to specify the WORKING_DIRECTORY option.

Because of the above limitation, a work around is to not use the
add_test(NAME) signature, but instead delegate the working directory
assignment to a generated cmake script, which
_qt_internal_create_command_script can already do.

Pick-to: 6.4
Task-number: QTBUG-96058
Change-Id: I6f439165994671724157f0edb7a71e351271e329
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-08-17 21:21:57 +02:00
Morten Sørvig
f347682fd5 wasm: include asyncify support unconditionally
Emscripten's option for enabling asyncify (-sASYNCIFY) is a link-time
option, which means there is no requirement to have a separate asyncify
build, at least for static builds.

Replace the current QT_HAVE_EMSCRIPTEN_ASYNCIFY compile-time option
with a run-time option which checks if the asyncify API is available.

Keep support for configuring with "-device-option QT_EMSCRIPTEN_ASYNCIFY=1"
for backwards compatibility and for the use case where want asyncify
support to be on by default for a given Qt build.

Enable asyncify for the asyncify_exec example.

Pick-to: 6.4
Change-Id: I301fd7e2d3c0367532c886f4e34b23e1093646ad
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-08-17 04:52:46 +02:00
Mikolaj Boc
644ae42e12 Make wasm finalizers work for standalone tests and other repos
The wasm helpers file is not included in QtBuild and is thus not visible
when standalone tests or other repos are being built. This fixes it.

Amends 1f9c1f032c

Pick-to: 6.4
Fixes: QTBUG-105615
Change-Id: I6c9229e1f259fa5043d7d11b8ee0293e26077f3e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-15 16:46:12 +00:00
Alexandru Croitor
6c9f4f5ebc CMake: Enable public executable finalizers for iOS tests
This ensures that tests can be executed on the simulator or device, by
doing the necessary steps like setting a bundle identifier, Info.plist
file, launch screen, etc.

This is done by calling _qt_internal_finalize_executable in the
implementation of all internal test adding functions.

The finalizers are limited only to iOS for now, as an incremental
step, and to ensure we don't accidentally break tests on other
platforms.

At least WebAssembly uses its own finalizers which would likely cause
duplicate calls if the _qt_internal_finalize_executable was
unconditional.

Pick-to: 6.4
Fixes: QTBUG-104754
Change-Id: I729d56385dd206b22c975fc2ce4e2c683e6e4e2c
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-15 10:44:54 +02:00
Alexandru Croitor
c76bf58350 CMake: Tests on iOS must be app bundles to be runnable
Pick-to: 6.4
Task-number: QTBUG-104754
Change-Id: I05053d0f242f45e56e7a95ac75f5ef63ca8a5e0e
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-15 10:44:51 +02:00
Alexandru Croitor
3608bb543d CMake: Use the Xcode generator for qt-cmake-standalone-test on iOS
Pick-to: 6.4
Task-number: QTBUG-104754
Change-Id: I43aae05f7e101a619d2c1b97d9a96c74d8498bfa
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-15 10:44:47 +02:00
Alexandru Croitor
e671b852e7 CMake: Improve tool not found error message
Pick-to: 6.4
Change-Id: I7f04e4af80c4d23b855c8c9d5f5017f8afb112ea
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-12 14:55:03 +02:00
Alexey Edelev
9029b90538 Rename arg_HEADER_MODULE variable to 'is_interface_lib'
Variables starting with 'arg_' usually are the result of the
cmake_parse_arguments call. It's better to not use them for the regular
variables for readability.

Change-Id: I4054c63d3e48b2a27d8a632cd8908a59302afa47
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-12 13:50:55 +02:00
Alexey Edelev
a3e8d28fdb Do not use the HEADER_MODULE argument in qt_generate_module_pri_file
HEADER_MODULE argument is passed to qt_generate_module_pri_file from
the qt_internal_add_module function, but the property means that the
module is an interface library. So it makes sense to replace this
argument with the reading of the target TYPE.

Change-Id: I1d8cd2ff732f526975cde6bdd4783fee44c8bd98
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-12 13:50:55 +02:00
Lorn Potter
1f9c1f032c wasm: allow apps to override EXPORT_RUNTIME_METHODS
Developers can add to Emscripten's EXPORT_RUNTIME_METHODS
by defining their own using:
QT_WASM_EXTRA_EXPORTED_METHODS

Which will add on to Qt's default exported runtime methods
of UTF16ToString,stringToUTF16

for cmake:
set_target_properties(<target> PROPERTIES QT_WASM_EXTRA_EXPORTED_METHODS "ccall,cwrap")
or
set(QT_WASM_EXTRA_EXPORTED_METHODS "ccall,cwrap")

for qmake:
QT_WASM_EXTRA_EXPORTED_METHODS = ccall,cwrap

Done-with: Mikolaj Boc
Fixes: QTBUG-104882
Pick-to: 6.4
Change-Id: I9678bdb7b077aaa8527057212ea4e161c0be0b60
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-12 10:13:51 +10:00
Joerg Bornemann
55af91f822 CMake: Put Qt-internal targets into a dedicated FOLDER
When loading a Qt CMake project in an IDE like Visual Studio, many
Qt-internal targets are visible, right next to the user's targets.  This
is inconvenient and confusing.

Use CMake's FOLDER concept, and put Qt-internal targets into a dedicated
FOLDER.

For that we introduce the new global property QT_TARGETS_FOLDER that,
analoguous to AUTOGEN_TARGETS_FOLDER, is the folder name for Qt-internal
targets.  By default, it's not set, nor is folder support enabled.

Change qt_standard_project_setup() to
- enable folder support
- initialize QT_TARGETS_FOLDER if unset
- initialize AUTOGEN_TARGETS_FOLDER to the same value if unset

Set the FOLDER property of qtbase's internal targets for user projects
to the value of QT_TARGETS_FOLDER.

Task-number: QTBUG-99808
Change-Id: I880ac7731f88faa83a384dcdec98b1b88ac6cc2e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-11 13:47:15 +02:00
Alexey Edelev
548440dd4b Remove HEADER_MODULE from qt_internal_extend_target
The current qt_internal_extend_target interface expects that the caller
will pass the HEADER_MODULE argument on each call. This is not correct,
since the argument doesn't affect the target internals, but only help to
decide how to modify the target according to its type. The target type
meanwhile can be always read from target properties. So this solution is
more consistent.

Change-Id: Ie84a2226ceb71cb5272670e5d43bdfc7a101360a
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-08-11 13:47:15 +02:00
Alexey Edelev
d2edee6152 Add the output of qlalr to the consuming target source files
The qlalr outputs need to be added to the consuming target.

Change-Id: I9600729103298cf7e0a712d5f3dc49c5f4c729f5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-10 20:00:35 +02:00
Joerg Bornemann
a29af6656f CMake: Fix detection of system double-conversion
...if the double-conversion CMake package cannot be loaded.

The find_path call must specify the header exactly as it is included.

The select_library_configurations call always failed, because the
command expects the presence of DOUBLE_CONVERSIONS_LIBRARY_DEBUG,
DOUBLE_CONVERSIONS_LIBRARY_RELEASE, or both.

Upstream double-conversion's MSVC build system does not specify a naming
scheme for the debug build, and there are no debug/release binaries to
download that suggest a naming scheme.  Therefore we assume the usual
'd' suffix for the debug library like we do everywhere else.

Lastly, we need to set DOUBLE_CONVERSION_INCLUDE_DIRS.

Fixes: QTBUG-105501
Pick-to: 6.2 6.3 6.4
Change-Id: I71ff5238f353541b8bf5ac6792b86134deba20d1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-10 19:32:06 +02:00
Alexey Edelev
5a5ad8c002 Add "content file" mode for the qt_internal_add_linker_version_script
Add the support of pre-cooked content for the LD version script. The
content can be generated without using the perl script at configure
or build time.

Change-Id: I1316e114a1d5550b2fdcf3482a51f336fb311a29
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-09 15:59:08 +02:00
Alexey Edelev
c2c4a21374 Add the common headersclean_check target
Add headersclean_check that allows to run all module-specific
'_headersclean_check' targets in single command. Also add
dependency on input header files for the headers clean custom
commands.

Also adjust the '_headersclean_check' target names to match
the naming of module targets - the 'Qt' prefix is removed.

Change-Id: I17c3442c3c51ce99cd9b38c85d606e9ababbb013
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-08-09 15:21:52 +02:00
Alexandru Croitor
0ce5c0a996 CMake: Bail when configuring multiple configurations and plain Ninja
Previously configuration would not error out if you configured Qt
with -DCMAKE_CONFIGURATION_TYPES=RelWithDebInfo;Debug -GNinja
instead you would get an error like

 CMake Error at cmake/QtBaseConfigureTests.cmake:51 (message):
 Failed to find compiled architecture detection executable at
 qtbase/build/config.tests/arch/RelWithDebInfo/architecture_test.exe

Note that Qt code tries to find the arch test in a RelWithDebInfo
directory but due to using single-config Ninja,
CMAKE_CONFIGURATION_TYPES is ignored, and the executable is placed
in a non-config specific folder.

Error out early in such a case, and mention that for multi-config
builds, the Ninja Multi-Config generator should be used.

Pick-to: 6.4
Change-Id: I0192185123be563671cbe154f968a03b7458e327
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-08-09 14:20:08 +02:00
Joerg Bornemann
d405713647 Remove cmake/FindCups.cmake
All supported CMake versions provide this file, and we did not modify
it.

Pick-to: 6.4
Change-Id: I4b21a99159ba8315491dc64ab737b7e5a28a6966
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-09 12:57:12 +02:00
Tor Arne Vestbø
8008fd3b75 cmake: Allow adding extra content to plugin pri file
Just like for module pri files.

Change-Id: Ie209784f1dbc5db5dcfdef2520bac178734d4894
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-08 16:30:36 +02:00
Tor Arne Vestbø
fb807f436d cmake: Use file instead of qt_configure_file for generating plugin pri
Matches qt_generate_module_pri_file and allows using genexes in the
content of the file.

Change-Id: I5ee7a973d3e27a721e31315d3ebe2c88ffa1db42
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-08 16:30:36 +02:00
Tor Arne Vestbø
ca2979cc16 cmake: Move qt_install call into qt_generate_plugin_pri_file
The same way qt_generate_module_pri_file does it.

Change-Id: I42047ce7d23e8a289535041ccace8b0f0140ea12
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-08 16:30:35 +02:00
Tor Arne Vestbø
02a5b34c07 cmake: Defer generating plugin .pri file until finalizer
Allows adding additional properties to the target after the initial
call to qt_internal_add_plugin.

Change-Id: I7998c906e53699ec41b44b51aabbe480ae698b21
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-08 16:30:35 +02:00
Alexey Edelev
60e46790dc Allow specifying multiple header types in qt_copy_framework_headers
qt_copy_framework_headers now can accept all the headers in one call.
This is useful for upcoming changes when it will accept generator
expressions as the input instead of actual files.

Change-Id: I110b6d9e6de976b2a7581902e051e38571716c5f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-05 16:45:02 +02:00
Alexandru Croitor
7fb25609a4 CMake: Fix examples to build as external projects when cross-compiling
We forwarded the compiler path to the EP but not the flags that might
have been set via the CXX environment variable.

Make sure to also forward the flags.

Pick-to: 6.2 6.3 6.4
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I0fbf9b595f7885014b1f09d158db52e56a3d5243
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-05 16:41:04 +02:00
Alexandru Croitor
0e2f218ee7 CMake: Fix Ninja Multi-Config dependency issues for top-level targets
When building qtsvg examples as external projects on Windows
with Ninja Multi-Config in a prefix build on the CI, the build would
fail with an error message like:

 ninja: error:
'C:/Users/qt/work/qt/qtsvg/lib/Qt6SvgWidgets.lib', needed by
'RelWithDebInfo/svgviewer.exe', missing and no known rule to make it

This can be reproduced locally on Windows if one calls
'ninja svgviewer' instead of just 'ninja'. I wasn't able to reproduce
it on macOS, although I have seen some peculiarities in the
dependencies there as well.

External project examples depend on the ${repo_name}_src custom
target to ensure all Qt modules are built, so one would expect that
dependency to be sufficient.

While trying to figure out what's going wrong, I noticed that running
'ninja -t query qtsvg_src:Debug' showed dependencies on Release
libraries, which should not happen. The :Release target looked fine
though.

I'm still not quite sure why the Release libraries are not built
on the first ninja run, despite the example having a proper dependency
on qtsvg:Release.

Running 'ninja svgviewer' a few more times ends up succeeding at one
point, because the SvgWidgets Release library does get built in
parallel with the failing example, and the next rebuild would
succeed.

While trying to fix the :Debug target to have proper dependencies, I
noticed that we add dependencies to the ${repo_name}_src custom target
via the DEPENDS option of add_custom_target(). That is incorrect,
that option should only be used for file level dependencies.

For target dependencies, add_dependencies should be used.

Doing that fixed both the :Debug dependencies as well as the Windows
issue, which is good enough for me.

Amends 08f46bb400

Pick-to: 6.2 6.3 6.4
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I1888681e2e9362d3237acbdacc83222d6a60b48e
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-05 16:41:04 +02:00
Tor Arne Vestbø
6ec21881dd CMake: Override simulator architecture to x86_64 for Xcode generator
The simulator build of Qt for iOS is currently x86_64 only, instead
of universal builds with an arm64 slice as well, since we don't
support xcframeworks. This means we can't rely on Xcode's default
simulator arch settings, which on an Apple Silicon Mac will be
arm64.

Instead we override the simulator arch, like we do for qmake.

Pick-to: 6.4 6.3 6.2
Change-Id: I8b52389db1b83f4f9679c724bcde53b44dbc76f1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-08-03 21:40:08 +02:00
Alexandru Croitor
effd6f63f1 CMake: Fix single standalone tests to use same Qt C++ language std
When using qt-cmake-standalone-test, we didn't tell CMake to use the
same C++ language standard that Qt used when it was configured.

We did tell CMake to do that when configuring tests with
qt-internal-configure-tests via the qt_build_tests macro.

To ensure the proper standard is set, we also need to
find_package(Qt6Core), because the std flag is derived from the
QT_FEATURE_cxxyz flag which is set by Core.

Change-Id: Ia41f2a24983ddab0107a6446743f7b054df8c033
Pick-to: 6.2 6.3 6.4
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-03 18:38:52 +02:00
Lucie Gérard
fb1b20eab3 Add license headers to cmake files
CMakeLists.txt and .cmake files of significant size
(more than 2 lines according to our check in tst_license.pl)
now have the copyright and license header.

Existing copyright statements remain intact

Task-number: QTBUG-88621
Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-03 17:14:55 +02:00
Alexandru Croitor
15117f84bb CMake: Relax constraint on not having feature values change
Previously if qtbase was built with feature A set to ON, then building
qtsvg, then rebuilding qtbase with feature A set to OFF, trying to
build qtsvg would fail with an error message at configure time saying
that the feature value has changed.

This check was added quite early in the Qt CMake port, presumably to
catch accidental reconfigures that might cause long rebuilds.

This has dubious benefit though. We constantly had people telling us
they get the error without knowing what to do. The usual advice was to
remove CMakeCache.txt and reconfigure.

Instead of forcing people to suffer this dance, relax the constraint
by issuing a warning instead of an error, and make it more clear why
a rebuild might happen (a changed feature value might change
the generated module C++ header file which in turn might be included
by various project sources).

Amends 20633d97ab

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-95834
Change-Id: I992bd61024958869f3b995471b4c7ff75e3a33a0
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-03 17:14:55 +02:00
Joerg Bornemann
626c3f56cf CMake: Remove internal __qt_add_plugin_*_args variables
All references to these variables have been removed from Qt
repositories.

Change-Id: Icca4668ec183ff543d04097600f8a8869066f8cc
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-08-03 08:02:37 +02:00
Alexey Edelev
5fc8a377ce Build minimal subset of tests for Android multi-ABI Qt builds
Add an option to limit the number of tests for building and testing
Android multi-ABI configurations in CI. Currently only Core tests
supposed to run.

Change-Id: Ibb8a41d60d108259ef2675ec54bde2482f87c8b2
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-02 21:18:50 +02:00
Alexandru Croitor
ea8645d846 CMake: Deprecate _add_app/executable/test/tool PUBLIC_LIBRARIES option
Warn projects not to use it because PUBLIC_LIBRARIES don't make
sense for executable targets and it also led to some issues in the
internal functions where some of them did not expect to receive
PUBLIC_LIBRARIES.

To ensure builds don't needlessly break, treat PUBLIC_LIBRARIES values
as regular LIBRARIES. In the future we might add an error instead.

Using PUBLIC_LIBRARIES in qt_internal_add_app, etc, accidentally
worked because the option name and the values following it were
parsed as values of the "previous" option, like SOURCES or
INCLUDE_DIRECTORIES or LIBRARIES, and when those got
passed through to qt_internal_extend_target, things magically worked.

We have a lot of projects using PUBLIC_LIBRARIES, mostly due to the
way qmake pro files were written and how pro2cmake converted them.
We'll have to clean up each repo.

Change-Id: I69e09d34afdf98f0d47c08d324643fc986f8131c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-29 18:33:00 +02:00
Robert Griebl
f7d42e6b0c cmake: add support for EXCEPTIONS to qt_internal_add_app
Change-Id: I79088f6647496ed455573cab9d403bd8a3f26c76
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-28 20:50:18 +02:00
Alexandru Croitor
ea668ff163 CMake: Export package name and 3rdparty flag for 3rd party libraries
Needed to get rid of warnings like

 CMake Warning at cmake/QtFindPackageHelpers.cmake:406
 (message): Could not find target Qt6::BundledLibYaml to query
 its package name. Defaulting to package name Qt6BundledLibYaml.
 Consider re-arranging the project structure to ensure
 the target exists by this point.

which were introduced with the integration
of dffcc2370e in qtbase.

This happened because we never set and exported the package names
for 3rd party bundled libs.
So export the package name as well as "is 3rd party lib" value.

Amends 6235f7fa62

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: I25fc1ffef766198974025e0097bced1cca4dd28d
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-28 15:11:54 +02:00
Alexandru Croitor
22c3b87b14 CMake: Mark PlatformCommonInternal as a Qt6 package
Add PlatformCommonInternal to the list of packages
compared in qt_internal_is_lib_part_of_qt6_package

It gets rid of the following warnings when configuring
standalone tests

 CMake Warning at cmake/QtFindPackageHelpers.cmake:406 (message):
 Could not find target Qt6::PlatformCommonInternal to query its
 package name. Defaulting to package name Qt6PlatformCommonInternal.
 Consider re-arranging the project structure to ensure the target
 exists by this point.

 CMake Warning at cmake/QtFindPackageHelpers.cmake:374 (message):
 Could not determine package version of target
 PlatformCommonInternal. Defaulting to project version 6.5.0.

Amends 606124c5cc
Amends dd1030a450
Amends dffcc2370e

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: I65c23c20b3c1b70dbfd54edd4f5b83c6781f5e6f
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-27 16:24:10 +02:00
Alexandru Croitor
0e0352ab4d CMake: Fix install destination of in-tree examples
Previously we called _qt_internal_override_example_install_dir_to_dot
in Qt6CoreConfigExtras.cmake as part of a
find_package(Qt6 COMPONENTS Core) call, and we assumed that the
Extras file would always be included in each example project.

But our package dependencies handling code skips calling
find_package(Qt6Core) if Qt6Core_FOUND is already set to TRUE,
which will definitely happen due to root-scope find_package
calls when configuring other repos.
That means we wouldn't override INSTALL_EXAMPLEDIR to "."
and the install destination would end up being something like
${CMAKE_INSTALL_PREFIX}/example_relative_path/example_relative_path
aka a double nested path.

Make sure we call the
_qt_internal_override_example_install_dir_to_dot function
in Qt6ConfigConfig.cmake in addition to Qt6CoreConfig.cmake.

That way, even if Qt6Core is skipped during dependency resolution,
it's still handled by the Qt6 package itself.

Because the function is defined in the Core package, guard the call
with an if(COMMAND) and only call the function if it wasn't previously
called within the current or ancestor scopes.

Amends ac4a913f33

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-102879
Change-Id: Id47e3ce06faec6d156ae1473942dae0f9b90cb46
Reviewed-by: Christophe Giboudeaux <christophe@krop.fr>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-27 16:24:10 +02:00
Alexandru Croitor
578f4ba00c CMake: Add per-target support for iOS launch screens
To support per-target iOS launch screens we need a way to specify
custom Info.plist entries without using cache variables, which we were
forced to use due to the implicit configure_file done for
MACOSX_BUNDLE_INFO_PLIST.

We now introduce an extra configure_file call done in a finalizer,
before we hand off the Info.plist file to MACOSX_BUNDLE_INFO_PLIST.

This extra configure_file call allows us to insert / substitute
additional Info.plist entries that CMake does not allow setting.

If a custom Info.plist file is provided, the finalizer will simply
skip the logic for creating a new one.

Amends e5b3436255

Pick-to: 6.4
Fixes: QTBUG-101064
Change-Id: I65496da146c9430a949a8163817021d54da28386
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-27 16:24:10 +02:00
Alexandru Croitor
f62412e6ec CMake: Add shared library plugin names to the QT_PLUGINS property
Otherwise we don't create a Qt6FooPlugins.cmake file in shared Qt
builds.

Adjust comment.

Amends f68e2c92cc
Related to 7d6f1ee5a7

Change-Id: I9c66d81197a4867039d5c53daf1b7edf0391c701
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-07-27 15:43:18 +02:00
Eli Schwartz
d8f9ac784e CMake: include the libexecdir in generated pkg-config files
In Qt6, the installed tools can be in one of two different locations,
depending on whether it is considered a helper or not. This means that
when migrating from Qt5 to Qt6, the pkg-config files no longer reliably
described where to find tools such as moc, uic, and rcc, which
third-party projects need to know about in their build systems.

Add this information in, to match qmake -query and Qt6CoreConfigExtras.cmake

Task-number: QTBUG-105051
Pick-to: 6.2 6.3 6.4
Change-Id: I6692a76e0491a1c5e28982aa5fbe8b8aec8dec56
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-26 10:18:01 -04:00
Alexandru Croitor
12629c6b80 CMake: Ensure build instructions are always shown the first time
Regardless of the current log level.

Somewhat similar to dd5c860a7b

Amends e2a0ddbb69

Pick-to: 6.2 6.3 6.4
Change-Id: Ib7bc87f07e195125c858dcece2df6e82303dd01c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-26 11:10:28 +02:00
Alexandru Croitor
4720735103 CMake: Change __qt_internal_include_plugin_packages to be a macro
The __qt_internal_include_plugin_packages function includes
PluginConfig.cmake files which in turn might look for dependencies
with find_dependency. The dependencies that were found not have their
_FOUND variables set in the calling scope, which could cause multiple
lookups of the same dependency packages.

Change the function to be macro, so that all relevant _FOUND variables
are set and no unnecessary package lookups are done.

As a result, no need to set the QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE
variable using set(PARENT_SCOPE)

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: Iba0fc83d9e58651f095e7b70d1ed19f064c4e577
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-25 19:52:54 +02:00
Alexandru Croitor
63db26a47e CMake: Don't look for Qt6 components that are already found
This matches what we do in Dependencies.cmake files, except this time
for COMPONENTS passed to the Qt6 package.

For example if a project does
 find_package(Qt6 COMPONENTS Widgets Core)
we'd end up looking for Core twice. Once as a dependency of Widgets
and once as a standalone request of the project.
Make sure to skip the second lookup if it was already found.

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: I61db7fbb99818b4b70a0bfe3e167b6f14732292e
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-25 19:52:51 +02:00
Alexandru Croitor
3892e86d6e CMake: Don't unset Qt6Qml_FOUND when including Qml plugins
Removing the variable would cause nested find_dependency calls of
FooQmlPluginDependencies.cmake files to look for the Qml package
again and again.

If we got to the point of including QmlPlugins.cmake, we already know
that the Qml package was found.

Set it to TRUE after every inclusion to avoid repeated Qml package
loading.

The second inclusion pass will ensure to set the found variable to
FALSE in case if some dependency is actually missing.

Amends aad4158959

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: I562a1c2ea0abac61453a743ab2e7d2f228de7ff0
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-25 19:52:48 +02:00
Alexandru Croitor
dffcc2370e CMake: Record the precise package name where Private modules live
Previously if a target depended on CorePrivate, we would write a
_qt_internal_find_qt_dependencies(... Qt6CorePrivate) call into a
FooDependencies.cmake file.
That find_qt_deps call would remove the 'Private' suffix and would run
find_dependency with NAMES set to both the altered and non-altered
names.
This would find the relevant package but it would set the wrong
_FOUND variable name, e.g it would set Qt6CorePrivate_FOUND instead
of Qt6Core_FOUND.
This in turn could cause multiple lookups of the Qt6Core package
during dependency handling because the correct _FOUND var would not be
set.

Instead of always looking for the Qt6CorePrivate package, make sure
we look for an appropriately named package for all Privates modules,
because we have the necessary info to determine the correct name.

Note that INTERNAL modules will still be looked up via a Private
suffixed package name because that's how the package name is chosen
for them.

Remove the code that accounted for Private modules in
qt_internal_remove_qt_dependency_duplicates because it's not needed
anymore.

Warn when a package name can't be queried from a target's property
because the target might not exist yet.

Add a TODO comment for the code that searches with two NAMES.
We can't remove it right now, because it might break user projects
that use stale Dependencies.cmake files.

The dbus subdirectory is added before the tools subdirectory
to ensure that the new package name extraction does not error out, due
to trying to access a target that does not yet exist.

Amends 425ff34aa1

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: Ib34ae5ed92f68b4265518c2b8802daeb1a3a04d6
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-25 19:52:45 +02:00
Alexandru Croitor
976539b4af CMake: Create aliases for Internal targets using common function
Previously we did not create Qt6:: namespaced aliases.
This is needed as a workaround preparation for getting the package name
of a module target from one of it's properties.

Before it would fail in qtinterfaceframework because
ifvehiclefunctions-simulation-server uses PUBLIC_LIBRARIES
in its qt_internal_add_app call, and because _add_app does not handle
such an option, some weirdness in qtbase's _add_app -> _add_executable
-> _extend_executable -> _register_target_dependencies ended up trying
to register PlatformAppInternal as package dependency.
That issue will be handled in separate changes.

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: Ifd03528c95b08cb6837a6aaa26cbf97c0cbabbb4
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-25 19:52:34 +02:00
Alexandru Croitor
6235f7fa62 CMake: Export a few useful Qt module target properties
These include:
 _qt_package_name
 _qt_is_public_module
 _qt_is_private_module
 _qt_public_module_target_name
 _qt_private_module_target_name

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: I012463944de8fc333f477a7880f9d27a69d6ef47
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-25 19:52:31 +02:00
Alexandru Croitor
8dac271889 CMake: Don't repeatedly look for the Qt6 dependency
When loading Qt packages, don't look for the Qt6 dependency if it was
already found in the given subdirectory scope.

This reduces the amount of find_dependency(Qt6) calls.

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: I737c4433daf30eed51a058b45cd539dff7657ca4
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-25 19:52:28 +02:00
Alexandru Croitor
0f8017efb6 CMake: Move QT_HOST_PATH check and computation into Qt6 package
Instead of trying to compute and validate the QT_HOST_PATH and
QT_HOST_PATH_CMAKE_DIR variables in the generated toolchain file,
do it in the Qt6 package.

This provides better error messages when a project is configured
without using the Qt generated toolchain file.
Because it's not done in the toolchain anymore, remove the various
host variables from __qt_toolchain_used_variables.

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: I1ca239ff83b8f783897e171fee352fc43e8ad7a8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-25 19:52:25 +02:00
Alexandru Croitor
7b24ffa936 CMake: Improve Qt6HostInfo package lookup condition
Instead of checking if QT_HOST_PATH is set during user project
configuration to find out if Qt6HostInfo should be looked up,
record if QT_HOST_PATH was provided during Qt configuration
into Qt6Dependencies.cmake and look up the package in a user
project based on that information.

This improves handling of the case where cmake is directly used
to configure a Qt project (instead of qt-cmake), which means no
QT_HOST_PATH might be set by the user, and then cmake would error out
saying that e.g. Qt6CoreTools is not found, instead of saying that
Qt6HostInfo is not found.

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: I0377d5440e4b5b295af73cfd4b5188f61d48e440
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-25 19:52:22 +02:00
Alexandru Croitor
a41bef8ede CMake: Move Qt6HostInfo lookup into a function
Also replace the duplicate call in QtSetup using the
new function.
To do that, we have to actually the call it in QtBuild
after QtPublicDependencyHelpers.cmake is available.

That call is needed so that Qt6_HOST_INFO_foo variables
are available in qt_generate_qmake_and_qtpaths_wrapper_for_target.

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: Ic5776c214bee6bedcea714b213b0e5a42c1bae06
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-25 19:52:18 +02:00
Tor Arne Vestbø
bee6f47d22 cmake: Teach qt_internal_extend_target about PLUGIN_TYPES
Change-Id: I2e8a3faa6ada66a644dceeb98f9ba8e994db4192
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-25 19:47:13 +02:00
Tor Arne Vestbø
f3cd571687 qmake: Link static plugins even in shared Qt builds
It's perfectly possible to create static plugins in an otherwise shared
Qt build, but the logic to import these plugins into applications was
assuming a fully static Qt build. We now handle this more granularly.

Change-Id: Iacfa72f04c7918613b50ca87cf123e7f4c0841d5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-25 18:02:37 +02:00
Tor Arne Vestbø
2b9b5d43f4 cmake: Generate prl and pri files for static plugins in shared Qt builds
The CMake build system files are properly generated, but the qmake parts
were missing.

Change-Id: Icbcce3143db976c536c802ea2314bc3f2595da51
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-25 18:02:37 +02:00
Tor Arne Vestbø
f68e2c92cc cmake: Link static plugins even in shared Qt builds
It's perfectly possible to create static plugins in an otherwise shared
Qt build, but the logic to import these plugins into applications was
assuming a fully static Qt build. We now handle this more granularly.

This works for in-source tools and tests as well, which don't go through
the same CMake machinery for plugins as user projects do. The only case
that does not currently work is in-source examples, as they don't share
any of the plugin machinery with neither Qt internal tools/tests or user
project, but that's a bigger architectural issue that goes beyond this
change.

Change-Id: Ie00a97b02ac38ec4affadc447a3bfd0ec7d9c69a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-25 18:02:37 +02:00
Ivan Solovev
5a5bc86028 QT_INLINE_SINCE: take version into account
This patch improves the QT_INLINE_SINCE(maj, min) macro to take
deprecation version into account.
If the specified (maj, min) version is less than or equal to the
version defined by QT_DISABLE_DEPRECATED_BEFORE, the macro will expand
to "inline", and the out-of-line fallback will be removed from the
library.

This is achieved by introducing the helper
QT_IF_DEPRECATED_SINCE(major, minor, whenTrue, whenFalse) macro.

Fixes: QTBUG-104131
Pick-to: 6.4
Change-Id: I285029dad7b71126072b024a3be6d7b11341996d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-07-22 20:26:56 +02:00
Tor Arne Vestbø
030923c0de Add -Wshorten-64-to-32 to headersclean
Fix existing warnings by casting to the appropriate type.

Change-Id: Ic44d2a71e1a2e508199dbb46bea7a19e183ec42c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-07-21 17:14:08 +02:00
Samuli Piippo
18ed6a8979 CMake: prepend build dir for examples build
In cross-compilation, the CMAKE_FIND_ROOT_PATH will have path to the
host Qt and examples build will pick up wrong Qt6Config.cmake unless
the build dir path is prepended.

Pick-to: 6.4 6.3 6.2
Fixes: QTBUG-104270
Change-Id: I7fc7499369a2e5446e1c5257155f81c72716fef7
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-21 11:54:47 +02:00
Thiago Macieira
396170d07b CMake: fix the word order in "no_direct_extern_access"
And take the opportunity to remove the "m" in the qmake feature name and
.prf file.

Pick-to: 6.4
Change-Id: I36b24183fbd041179f2ffffd170224ab75cdd968
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-20 14:54:20 -07:00
Thiago Macieira
78ef9e9d14 Fix attempt to use -mno-direct-extern-access with Clang
Clang has the option, but spells it differently.

Fixes: QTBUG-105002
Pick-to: 6.4
Change-Id: I36b24183fbd041179f2ffffd170217e82ff6d14d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-20 14:54:19 -07:00
Yuhang Zhao
ce9799e4c4 MSVC: Fix the CET parameters
To enable CET for MSVC, only passing "/CETCOMPAT" to
the linker should be sufficient.

Enabling generation of EH Continuation (EHCONT) metadata
is additional protection and should not be necessary.
It also requires all the dependencies to be re-compiled
with EHCONT enabled, otherwise the linker will refuse
to link the obj files. However, this is rather hard
to achieve if your application depends on many 3rd-party
libraries, so to let people enable CET more freely,
we don't enable EHCONT guard by default.

Pick-to: 6.4
Change-Id: Iba08a5ec56c474d291991fb751a0de764719bd85
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-20 19:16:00 +08:00
Alexandru Croitor
0d91f85f6c CMake: Introduce QT_DEBUG_FIND_PACKAGE for troubleshooting
When a Qt component or dependency is not found, we will now show a
message that the user can reconfigure the project with
-DQT_DEBUG_FIND_PACKAGE=ON.

If the option is enabled, various variables that find_package uses to
find packages (like CMAKE_PREFIX_PATH, CMAKE_FIND_ROOT_PATH) will be
recorded before each find_package / find_dependency call that is
executed in any of the Qt package files.

If any find_package call fails (a package has its _FOUND variable set
to 0), the values of all those recorded variables will be shown.

This is useful to troubleshoot issues, especially when
cross-compiling, without having to manually modify the various
Config files.

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: I3654960597911bd704fbe3c419bcae347ab739a9
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-18 16:21:19 +02:00
Alexandru Croitor
50d0296ed4 CMake: Suggest hints on how to debug missing packages
Depending on CMake version suggest usage of either
--debug-find-pkg or CMAKE_FIND_DEBUG_MODE to help troubleshoot
why dependent packages are not found.

To achieve that, append the hint message to the _NOT_FOUND_MESSAGE.

To ensure it works for qt dependencies, and not only tool and 3rd
party dependencies, _qt_internal_find_qt_dependencies
is modified to set variable names infixed by the target name, so the
name is consistent with the other dependency lookup functions.

The check and message are also added when a Qt6 component is not
found.

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: I4ef23d1c53ac8e04eb72c260d6860c1eeec8d7a3
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-18 16:21:19 +02:00
Alexandru Croitor
0e2b385c5b CMake: Allow setting Qt6_DIR to find packages when not cross-compiling
So far we always recommended that developers set CMAKE_PREFIX_PATH to
point to the location of the Qt installation so that Qt packages are
found by CMake.

In Qt5 one could also set the Qt5_DIR variable to $qt/lib/cmake/Qt5
to allow the following signature to work:
 find_package(Qt5 COMPONENTS Core)

This was not sufficient in Qt6 because the CoreTools dependency would
not be found.

Fix this by also looking into the parent folder of
CMAKE_CURRENT_LIST_DIR as well as _qt_cmake_dir, like we already do
for regular non-Tools packages in _qt_internal_find_dependencies.

Note that setting Qt6_DIR is not sufficient for cross-compilation if
the qt.toolchain.cmake file is not used.
Aside from platform specific options that would have to be passed
manually to CMake (like -DCMAKE_SYSTEM_NAME=iOS for iOS) and
passing a QT_HOST_PATH value, the code would also need to be
adapted to do the necessary CMAKE_FIND_ROOT_PATH manipulations
to ensure that dependent packages are found.

Pick-to: 6.4
Task-number: QTBUG-97615
Change-Id: I10c419632d43bb929e184bab3b9d3d27a35ea87a
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-18 16:21:19 +02:00
Alexandru Croitor
f0c3cfb067 CMake: Display reason when a Qt*Tools package is not found
When a package's tools dependency is not found (e.g. Core's CoreTools)
set the _NOT_FOUND_MESSAGE variable the same way that find_dependency
does.
We can't use find_dependency directly because that returns immediately
without allowing us to reset the prefix paths vars.

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: I81e9817de8f30214fafbefe3d98ef7bc8848e715
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-18 16:21:19 +02:00
Alexandru Croitor
db07310c51 CMake: Don't propagate REQUIRED to find_dependency / find_package
If find_package(Qt6 REQUIRED COMPONENTS Core) is called, don't
propagate the REQUIRED option to all the dependencies of Core,
regardless if it's a 3rd party library, tool or another Qt package
dependency.

Propagating REQUIRED causes the find_dependency -> find_package call
to exit the calling file immediately when the package is not found,
not giving an opportunity for find_dependency to set the
_NOT_FOUND_MESSAGE variable.

Instead force all find_dependency / find_package calls
to be optional, set the calling _FOUND variable to FALSE if the
dependency is not found, also set the _NOT_FOUND_MESSAGE variable.
Then the find_package call that loaded FooModuleConfig.cmake file
will show that message as the reason for the package not being
found.

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: Idcf0b6ed6f6bb38dc082110bbd817b05e287c052
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-18 16:21:19 +02:00
Alexandru Croitor
8152053a0b CMake: Clarify if an optional or required Qt component is not found
Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: Id35f128404eb49a655d52ef130f8acb02f8ed33a
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-18 16:21:19 +02:00
Alexandru Croitor
ecfc0df9b2 CMake: Don't search for next Qt component if a required one is missing
If a project calls find_package(Qt6 COMPONENTS Gui Network) and Gui is
not found, there's no reason to look for Network, because the
COMPONENTS option implies that it is a required component. Failing to
find a component sets Qt6_FOUND to false, so we can break early.

If a project calls find_package(Qt6 OPTIONAL_COMPONENTS Gui Network)
then Network will still be looked for if Gui is not found.

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: I5c5edd27729635e6b7ade059656b49320364ad13
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-18 16:21:19 +02:00
Alexandru Croitor
6a2358e20f CMake: Remove custom Qt6 3rd party dependency implementation
Use _qt_internal_find_third_party_dependencies instead.
We rely on the inner find_dependency call to set the
Qt6_NOT_FOUND_MESSAGE message when a dependency is not found.
This implies removing the custom FATAL_ERROR handling
and relying on the parent find_package to display the
Qt6_NOT_FOUND_MESSAGE message.

We also clear Qt6_FIND_COMPONENTS if a dependency is not found.
No need to look for Qt packages if the Qt6 dependency was not met.
This reduces the amount of recursive error messages.

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: I5c611aaededfa63eb507ec5385b37a2fb6fcc698
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-18 16:21:18 +02:00
Alexandru Croitor
4c0578253d CMake: Rename _qt_internal_find_dependencies to something less generic
Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: I99b69865f711ff57511f32df2f345cebb7445d44
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-18 16:21:18 +02:00
Alexandru Croitor
7853f80e39 CMake: Extract package dependency finding into functions
Aside from moving the code to reduce duplication, the only changes in
the code are the replacement of @target@ to ${target}, using IN LISTS
with variable names to avoid macro expansion issues and replacing
the if(var) conditions with double variable evaluation
+ NOT STREQUAL "".

The function implementations are now in the same order as they
are used in the Dependencies.cmake files.

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: Iaae926414fd2a7cc09c2f5716376caaa0aade74b
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-18 16:21:18 +02:00
Alexandru Croitor
2d2cf95fe1 CMake: Remove dead code
It was accidentally left when changes were made from patchset 1
to patchset 2 in 825cb50c27

Amends 825cb50c27

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: I04dd50cfb93655f0c224bb226695e7771e9bc5d1
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-18 16:21:18 +02:00
Alexey Edelev
babb4ec4a6 Rename the <module>_timestamp target to <module>_pri_dep_timestamp
Make the target purpose more understandable from its name.

Change-Id: I4f4a56fd3ef338b728d4a81edc2df32cada97f6c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-15 19:27:08 +02:00
Tor Arne Vestbø
3ad0f755f5 cmake: Don't reference global data in qt_internal_get_title_case
The only place the function was used was to generate the title case of
a target, so the issue wasn't spotted until now.

Pick-to: 6.2 6.3 6.4
Change-Id: Iee66ecea569e7411c6b5a5e5312cde910a48fa01
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-14 14:09:33 +02:00
Joerg Bornemann
8b5cce6911 CMake: Fix prefix propagation for relocated Qt installations
Consider qtbase built with CMAKE_STAGING_PREFIX=/foo on Windows.
If /foo was moved to /bar, non-qtbase repositories did get a staging
prefix with drive letter assigned.  This is undesirable when DESTDIR is
used on installation.

Change the implementation of qt_internal_new_prefix to remove the drive
letter from the "new prefix" if the "old prefix" did not have a drive
letter.

Change-Id: I6fb17e690b264920b0dd4204e3b3c30794c7e76e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-13 12:52:00 +02:00
Alexandru Croitor
3d1464fc15 CMake: Process extra dependencies for plugin targets as well
We started recording extra dependencies for the QtNetwork TLS plugin,
but we never actually processed them to write out the necessary
find_package calls.
This broke static builds of qtopcua, because the OpenSSL::SSL target was
no longer created in the root scope, but only in some child ones like
src/opcua, whereas the target was referenced in generator expressions
in a different sibling scope src/declarative_opcua, leading to errors like

 CMake Error at lib/cmake/Qt6/QtPrlHelpers.cmake:116
  (file): Error evaluating generator expression:
    $<TARGET_LINKER_FILE:OpenSSL::SSL>
  No target "OpenSSL::SSL"
 Call Stack (most recent call first):
  lib/cmake/Qt6/QtModuleHelpers.cmake:837 (qt_generate_prl_file)
  lib/cmake/Qt6/QtScopeFinalizerHelpers.cmake:21:EVAL:1
     (qt_finalize_module)
  src/declarative_opcua/CMakeLists.txt:DEFERRED

Make sure to process the extra deps for plugins as well.

Amends d754e43721
Amends 3c23317552

Pick-to: 6.4
Task-number: QTBUG-96283
Change-Id: I11876e0844198b3a794bc06b6691ee694fd3b1c2
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-11 22:23:09 +02:00
Alexandru Croitor
0d1c16861a CMake: Clarify qt_record_extra_third_party_dependency docs
Pick-to: 6.4
Change-Id: I458a5b488741c639650c8b3b6668c82c80b5e93f
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-11 22:23:09 +02:00
Joerg Bornemann
8cc58fbbc7 CMake: Propagate qtbase's original staging prefix to other Qt repos
If qtbase was configured with CMAKE_STAGING_PREFIX set to a path without
drive letter on Windows, we must ensure that this exact staging prefix
is propagated to non-qtbase repos.

We already had code that does this for CMAKE_INSTALL_PREFIX.  But since
9a74d94ff5 we build our cross-built
packages with CMAKE_STAGING_PREFIX instead of CMAKE_INSTALL_PREFIX.

Move said code into a function and use it for CMAKE_STAGING_PREFIX too.

This fixes Android non-qtbase release libraries not being stripped in
our Windows Android packages.

This amends commit 037fd545c4.

Fixes: QTBUG-104827
Pick-to: 6.2 6.3 6.4
Change-Id: I909f7f39bd0ef7b559619b69f756c042d6c528b0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-11 19:43:41 +02:00
Alexandru Croitor
bea66711d8 CMake: Don't create duplicate plugin targets in shared builds
when building Qt repositories.

When building for example qtquick3d, the Qt6QmlPlugins.cmake
file should not load the qtquick3d specific plugin config files
because the targets will be created as part of the build and cause
duplicate errors.

We already did it for static builds, but now we also do it for shared
builds.

Amends 7d6f1ee5a7
Amends 98e8180e56

Pick-to: 6.4
Task-number: QTBUG-94066
Change-Id: I66ca71dfa6485eded94c1ecb5eb3b23daf908b39
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-08 15:07:38 +02:00
Tor Arne Vestbø
e27a0d5a0f Disable bitcode for iOS
It's deprecated as of Xcode 14, and generates a warning message if a
project explicitly enables bitcode. The App Store no longer accepts
bitcode submissions from Xcode 14.

Pick-to: 6.2 6.3 6.4 5.15
Change-Id: Ib1f9d5114ca4d8b1845ecc7a9de0473ee015db33
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-07 17:02:37 +02:00
Morten Sørvig
5b23f08b81 wasm: use simpler syntax for EXPORTED_RUNTIME_METHODS
Recents emsdk versions support specifying the method list without
using brackets. Switch to this syntax since that avoids any quoting issues.

Pick-to: 6.4
Change-Id: Ib7bf8ec3f0d2ef67e8222a23e7af9b368ee99a00
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-07-06 17:56:58 +02:00
Joerg Bornemann
df764df3ea Fix potentially wrong version in Windows resources of Qt plugins
qt_internal_add_plugin calls qt_set_target_info_properties with the
TARGET_VERSION argument and passes arg_VERSION.  However, the function
qt_internal_add_plugin does not have a VERSION argument.

If arg_VERSION is set before calling qt_internal_add_plugin, that value
will be used, and that could be wrong for the plugin.

Remove the TARGET_VERSION argument from the
qt_set_target_info_properties call.

Pick-to: 6.4
Change-Id: I0ae9e0e6636d74fdc20e6ab9ca525c5a9126000c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-06 12:20:40 +02:00
Yuhang Zhao
6af63c8256 CMake: Update description of the Intel CET feature
Use a more detailed description instead.

Also adds the missing part of the GCC parameter.

Amends commit qtbase/42287255d38bf493b5731396b99bc9cd7b1baba4

References:
https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gcc/Instrumentation-Options.html#Instrumentation-Options

Change-Id: I94a22ac7dfa80644e92fe01021f7868dfa02dd69
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-06 00:31:47 +08:00
Joerg Bornemann
fc3e0885a6 CMake: Fix missing include directories from qmake support files
The include paths in QMAKE_INCDIR_FOO entries in qt_lib_XXX.pri files
are filtered to not contain implicit include directories.

We must enclose the regular expression with ^...$ to avoid catching too
many paths like any subdirectory of /usr/include.

Fixes: QTBUG-104736
Change-Id: I2d40e6ec6d3f3421d591fed90b4dd9ebbbeb59f4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-05 13:55:19 +02:00
Alexandru Croitor
7d6f1ee5a7 CMake: Create and include plugin packages in shared builds
Previously QtModulePlugins.cmake files were only created and
included in static library Qt builds.

Having the targets available in shared library builds would be
useful for custom project deployment purposes. One could query
the location of the plugins or use various generator expressions
referencing their location.

Ensure we always generate and include the QtModulePlugins.cmake files
regardless of the build type.

Allow opting out of including the files by setting
QT_SKIP_AUTO_PLUGIN_INCLUSION to ON, just like we allow for Qml
plugins with QT_SKIP_AUTO_QML_PLUGIN_INCLUSION.

Pick-to: 6.4
Fixes: QTBUG-94066
Change-Id: I69a5dc17762a8e43265578fc33b82b5c4b7a1f5c
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-05 13:04:09 +02:00
Alexandru Croitor
ff4be4cf30 CMake: Move plugin package inclusion logic into a common function
Don't duplicate the logic of plugin package inclusion for each Qt
module. Instead move it into QtPublicPluginHelpers.cmake.

Pick-to: 6.4
Task-number: QTBUG-94066
Change-Id: I5e1f5176a0e754ed56a792c97865752529462617
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-05 13:04:09 +02:00
Alexandru Croitor
eb8da02d05 CMake: Improve 'Generating Plugins' message
Use message(STATUS) for the 'Generating Plugins' message.

This way it will go to stdout instead of stderr, which follows the
convention we have for most of our other messages.

Also list only the modules that actually have plugins, rather than all
known modules.

Pick-to: 6.2 6.3 6.4
Change-Id: I1ea0ed71418ede54790cabd32e03e82fc69f2858
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-05 13:04:09 +02:00
Alexandru Croitor
9ea2f7f4b1 CMake: Fix qml plugin prl files not to have hardcoded paths
The previous fix 754512a64d
did not handle qml plugins, which meant that they would still have
hardcoded paths and see warnings like the one below when generating
the prl files

 CMake Warning (dev) at
 cmake/QtFinishPrlFile.cmake:103 (message):
  Could not determine relative path for library
  qml/QtQml/WorkerScript/libworkerscriptplugin_debug.a
  when generating prl file contents.  An absolute path will be
  embedded, which will cause issues if the Qt installation is
  relocated.

Handle qml plugins as well.

Amends 754512a64d
Amends f4e9981259

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-104708
Task-number: QTBUG-104396
Change-Id: Icfb1069d1cb0a39a35004b20e58ee6e386d14f3b
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
d59628881e CMake: Fix confusing FPHSA zstd version warning message
Previously if zstd was not found, one would see such a warning message

 Could NOT find WrapZSTD: Found unsuitable version "", but required is
 at least "1.3" (found ZSTD_LIBRARY-NOTFOUND)

This is because PC_ZSTD_VERSION was a defined variable with an empty
value, which makes FPHSA believe that a version was extracted from
somewhere.

Avoid passing that value directly.

Now the warning message is

 Could NOT find WrapZSTD (missing: ZSTD_LIBRARIES ZSTD_INCLUDE_DIRS)
 (Required is at least version "1.3")

Pick-to: 6.2 6.3 6.4
Change-Id: I88760d94db0d869d328085996298f4aaa88bc6c2
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
a310319a04 CMake: Rewrite double-conversion find module
Rename FindWrapDoubleConversion.cmake into
FindWrapSystemDoubleConversion.cmake.
Merge contents of Finddouble-conversion.cmake into the one above.
This allows users to provide their own Finddouble-conversion.cmake
file (Conan can do it).
Don't mark the system package as required, because we have a bundled
one too.
Add link to upstream.
Make sure to show either Config file or library path when one is
found.

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-104541
Change-Id: I9ea2330697c6fc280328849ca11522291c4073d8
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
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