Commit Graph

1033 Commits

Author SHA1 Message Date
Alexandru Croitor
e0c62a48b8 CMake: Rename internal functions to contain qt_internal
Offer compatibility wrapper functions until we update all of the Qt
repos to use the new names.

Task-number: QTBUG-86815
Change-Id: I5826a4116f52a8509db32601ef7c200f9bd331de
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2020-09-23 16:59:05 +02:00
Joerg Bornemann
25cc901f04 CMake: Fix configure -redo for top-level builds
When re-doing in a top-level build, we did not read the config.opt file
from the top-level directory.

Also, the config.opt file should not contain the -top-level argument.
This is an internal option, and on Windows, it was already missing. The
information whether we're doing a top-level build is now passed in the
CMake variable TOP_LEVEL.

Change-Id: Iaecd7306a4b6d9ad494684c201cf12f8e74d684b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-22 22:20:43 +02:00
Kai Koehne
3b6ef98d7a headersclean: Fix include paths for dependent modules
Having ${QT_BUILD_DIR}/include as include path is not enough for
modules outside of qtbase. They also need to pick up headers from e.g.
Qt Core, which are available only in "${CMAKE_INSTALL_PREFIX}/include"

This amends db21bad936

Fixes: QTBUG-82615
Change-Id: Ib003a66ce039bf1ab6e21a3b1cd86923207eb3db
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-21 14:51:15 +00:00
Julien Schueller
5a8555c53f CMake: Fix FindWrapRt
We must use the LIBRT location instead of LIBRT_FOUND which is not set anywhere.
I failed to replace this one in my previous patch.

Change-Id: I6e2df82c31e29018d99afec1eecfb80a321fddd4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-18 20:25:58 +02:00
Cristian Adam
0aa4b33b92 CMake Build: Add qtnetwork docker testserver support
qt_add_test supports now QT_TEST_SERVER_LIST, which will add the test
servers as docker test fixtures.

The docker server will be started before the test is run, and stopped
after the test is run.

Running the tests in parallel is not supported.
Docker tests are currently only supported on Linux hosts.

Task-number: QTBUG-85034
Change-Id: If3cefe05c5dec19c14b05d2fa8b01a0b6d95e259
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-17 00:11:04 +00:00
Assam Boudjelthia
b9c85d6b0e CMake: build add flags for building QtAndroid.jar
Adds -source, -target, -Xlint:unchecked, -bootclasspath flags.

Setting default javac build source and target versions to 8.

Allow setting custom values for javac build versions via
-DQT_ANDROID_JAVAC_SOURCE, and -DQT_ANDROID_JAVAC_TARGET.

Task-number: QTBUG-86282
Change-Id: I98f4f193ac96016dc722d178594d7fd401202f68
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-16 20:55:16 +03:00
Julien Schueller
a16803d3e4 CMake: Fix FindWrapRt
Actually link to librt to fix detection

Change-Id: I819d9b57212fef7f539ef807846e06beb7bd617b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-16 14:49:00 +02:00
Julien Schueller
cf33d64528 CMake: Fix FindGLESv2
Avoids a linking error when the library is not found as
find_library sets GLESv2_LIBRARY to GLESv2-NOTFOUND

Change-Id: I7ddc15483276e0be0c78b67b760c4d9188758270
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-09-16 14:48:46 +02:00
Alexandru Croitor
93fc3afe71 CMake: Check that QT_HOST_PATH is set when using the Qt toolchain
If a consumer wants to cross-compile a Qt app, they need to provide
the host Qt path location.

When building Qt in the CI we embed the Qt host path into the
generated CMake toolchain file for convenient building of other Qt
modules.

But once Qt is built, packaged and installed on a user's machine, most
likely the Qt host path will not be the same. In such a case, if the
user wants to use the convenience toolchain, they should explicitly
provide the Qt host path via the QT_HOST_PATH and
QT_HOST_PATH_CMAKE_DIR variables.

Show an error message if the values are not provided or don't exist
on the file system.

It's possible that in the future the Qt installer will patch the
toolchain file, or provide additional info, to point to the host
Qt installation so that the user doesn't have to do it manually.

But until that's done, a friendly error message is a good way to
inform the user what they should do.

Task-number: QTBUG-83999
Change-Id: I26291e3c47bb77375f8a5ce7b848c0382a660ca9
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-09-15 20:05:28 +02:00
Alexandru Croitor
67567b8e0d CMake: Conditionally set compiler in generated toolchain file
Public consumers of the qt toolchain file will most likely not have
their compilers in the same location where they were on the Qt build
machine.

Only set the compiler paths if none was set already, and the paths
actually exist.

This seems to become a trend in the generated toolchain file, and is
only a stop-gap solution.

A proper solution (two different toolchain files) may follow.

Task-number: QTBUG-83999
Change-Id: I7a603af447333a45c65b98e299ee109932d16517
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-09-15 20:05:25 +02:00
Alexandru Croitor
e957e9c28f CMake: Fix incorrect host path used in generated toolchain file
A previous change accidentally broke what we we set for
QT_HOST_PATH and QT_HOST_PATH_CMAKE_DIR.

The QT_HOST_PATH variable should use an absolute path as it was
done before.

The QT_HOST_PATH_CMAKE_DIR variable incorrectly used the value of
"${QT_HOST_PATH}" instead of "${QT_HOST_PATH_CMAKE_DIR}".

Fix both of these, and change the names of intermediate variables
to be consistent.

Amends a6a3b82ffb

Task-number: QTBUG-85240
Change-Id: I328a7edee12a13ff793684e8a0a4c2e03204eca4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-09-15 15:55:47 +02:00
Joerg Bornemann
6718dea390 Revert "Revert "CMake: Add facility to mark package dependencies as optional""
This reverts commit b0c51f86f4.
The build failure caused by 58c1c6ee5c has
been fixed.

Change-Id: Ic7458d54c7a874588e8b1bfeca61df1842763656
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-14 15:03:14 +02:00
Joerg Bornemann
b96d350cff Revert "Revert "CMake: Reduce the number of find_dependency calls""
This reverts commit 6e1a570dc8.
The build failure caused by 58c1c6ee5c has
been fixed.

Change-Id: I67acaa2d1dd5fc88c205b054252be2e6e26898c7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-14 15:03:14 +02:00
Joerg Bornemann
b9c493728a Revert "Revert "CMake: Fix usage of find_dependency()""
...and fix the build errors the original change caused.
This reverts commit 127fb8bb55.

Change-Id: I4006b32734a51c5d101dd73c957f81d2a0f84ba1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-14 15:03:13 +02:00
Lars Knoll
127fb8bb55 Revert "CMake: Fix usage of find_dependency()"
This reverts commit 58c1c6ee5c.

This lead to configuration errors on some machines, blocking
development.

Change-Id: I744f6cc95fbaa273519ab8fc8fb492b87f5729b8
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-13 12:21:06 +02:00
Lars Knoll
6e1a570dc8 Revert "CMake: Reduce the number of find_dependency calls"
This reverts commit a3cb002511.

This lead to configuration errors on some machines, blocking
development.

Change-Id: Ibb785c96c7d85692a6e22a73e086119eb571df71
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-13 12:21:01 +02:00
Lars Knoll
b0c51f86f4 Revert "CMake: Add facility to mark package dependencies as optional"
This reverts commit 3685483c4b.

This lead to configuration errors on some machines, blocking
development.

Change-Id: I309cdd55a8ef64899afcbeca54458d1c6d686951
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-13 12:20:56 +02:00
Joerg Bornemann
3685483c4b CMake: Add facility to mark package dependencies as optional
Every public dependency of a Qt module results in a find_package call in
the consuming project. But not all public dependencies are mandatory.

For example, vulkan is only needed if the user project actually uses Qt
classes that pull in vulkan headers.

This patch adds the option MARK_OPTIONAL to qt_find_package.
Dependencies that are marked as optional will not produce an error on
find failure.

Task-number: QTBUG-86421
Change-Id: Ia767e7f36991e236582c7509cbd37ea3487bb695
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-12 19:26:58 +02:00
Joerg Bornemann
a3cb002511 CMake: Reduce the number of find_dependency calls
...in code. The actual number of calls at runtime does not change.
The reason for this stunt is that we want to replace find_dependency
with find_package at runtime for optional dependencies, and this will
reduce the diff size of the next commit.

Change-Id: I304fdf09c69fea7b6d4adabf515712eb097f8c86
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-12 19:26:55 +02:00
Joerg Bornemann
58c1c6ee5c CMake: Fix usage of find_dependency()
The find_dependency() macro calls return() on failure, meaning any code
after it will be ignored, thus checking any XXX_FOUND variables after
find_dependency() is pointless.

Fix the places where we use find_dependency() and set the "failed" state
before the call and the "success" state afterwards.

Change-Id: Ia5239c704f02a9bec972210374ffed7808b14055
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-12 19:26:52 +02:00
Alexandru Croitor
94c15bda6e CMake: Provide way to register extra tool package dependencies
This is needed for qtwayland, where QtWaylandCompositor package should
call find_package(QtWaylandScanner) in the 'Tools' section of the
ModuleDependencies.cmake file, rather than the regular 'Qt' section.

This takes care of handling host path prefixes, to ensure that a host
package is found even when tools have also been cross-compiled via the
QT_BUILD_TOOLS_WHEN_CROSSCOMPILING option.

Task-number: QTBUG-83968
Change-Id: I4725a630214d053105fb6d2a0f7c5ff6128d13f9
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-09-11 19:49:53 +02:00
Alexandru Croitor
9a2ee31059 CMake: Fix rpaths set for Qt internal apps like Designer
qt_apply_rpaths takes into account properties like MACOSX_BUNDLE. This
property might not yet be set when qt_internal_add_app is called, but
later.

To handle that, move the call of qt_apply_rpaths to
qt_internal_finalize_app.

As a result, the installed apps will have 2 rpaths, the $ORIGIN style
relocatable one, and an absolute path one pointing to the Qt
prefix/lib. The last one might be unnecessary.

Fixes: QTBUG-86514
Change-Id: I25e0d695c78c8b5703e94c99cc2457f772721456
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-09-11 19:49:50 +02:00
Kai Koehne
199d867820 CMake: Fix build with Clang on Windows
win32-clang-g++/qmake.conf did define

  QMAKE_CFLAGS_WARN_ON   += -Wextra -Wno-ignored-attributes

probably for the same reason.

Change-Id: I14b66f2555949c03a2ea996923e31f5ec9f7105a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-11 17:11:03 +02:00
Joerg Bornemann
87fd930fca CMake: Fix qt-configure-module for modules without qt_cmdline.cmake
Some repos/modules don't have configure.json files and thus no
qt_cmdline.cmake files. Make qt-configure-module check for the file's
existence. As drive-by fix, surround the configure.cmake's path by
double quotes.

Change-Id: If1a91a0bba0c2fd282cfa08fa6ff2bb20f0a15ba
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-09-11 17:11:03 +02:00
Joerg Bornemann
6fa33ee92c CMake: Take MODULE_INCLUDE_NAME into account when installing
For modules that have MODULE_INCLUDE_NAME set (for example ActiveQt) we
must use this name for the installation rules too.

Fixes: QTBUG-86484
Change-Id: I1b97cf534ea5e41655c7b3fdd0330b2f58356a3a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-11 17:11:02 +02:00
Joerg Bornemann
96bdcdacbc CMake: Implement configure -ltcg
This configure switch sets the CMake variable
CMAKE_INTERPROCEDURAL_OPTIMIZATION_<CONFIG> per release config to ON.

The feature 'ltcg' is enabled if any of the variables
CMAKE_INTERPROCEDURAL_OPTIMIZATION,
CMAKE_INTERPROCEDURAL_OPTIMIZATION_<CONFIG> are ON.

In order to implement the check, configurejson2cmake had to be extended
to be able to write extra CMake code before and after the feature
definition. This extra code can be added to a feature mapping below the
keys "cmakePrelude" and "cmakeEpilogue".

Task-number: QTBUG-85373
Change-Id: Ia2eb907edcf087f137977a9b090705397f83eb05
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-09-11 11:30:56 +02:00
Joerg Bornemann
7ddb4dcad5 CMake: Implement configure -qpa
Change-Id: I38a938cda91a525d2af22deec864c6a12af3e29d
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-09-11 00:41:20 +02:00
Joerg Bornemann
457cf10f7e CMake: Introduce qt-configure-module
Add a convenience script to configure a Qt module separately.
This script reads and interprets the qt_cmdline.cmake files of the
Qt module to be configured and eventually calls qt-cmake-private.

Example usage:
<install-prefix>/bin/qt-configure-module <source-root>/qtdeclarative
  -qml-network -- --trace-expand --trace-redirect=cmake.trace

Change-Id: I026f1a050cd3f4df740611c32ba8c03161bba7a3
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-09-11 00:41:10 +02:00
Joerg Bornemann
36a5cd0ac1 Fix markdown syntax in cmake/README.md
Make this file parsable by tools that are less lenient than github.
Triple-backquotes are for fenced code blocks. Inline code uses backticks
(or double backticks if you have code with backticks).

Change-Id: Ic49d946fbcaa6f7e97702eadf4a0b0c726fc3217
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-11 00:40:53 +02:00
Joerg Bornemann
069fc33e8a Remove the -no-compile-examples configure switch
If '-make examples -no-compile-examples' was specified, sources of Qt's
examples would be installed, but the examples would not be built.

This switch has always been a source for confusion and is only
interesting for distributors, who can just package the examples
directory tree.

Change-Id: I0291d70e4951d98b553a4abf217db49d05316d3a
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2020-09-11 00:40:46 +02:00
Joerg Bornemann
8a2ca17b2d CMake: Fix generation of XXX_tracepoints.cpp
The include directive was incorrectly written.
This amends 5c092c2b40.

Change-Id: Ia72ca3a5d5e1486ade4d71a764550d36979640f6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-10 18:06:06 +02:00
Joerg Bornemann
2a9ef0ecee CMake: Fix call to tracegen when cross-compiling tools
We need to use the imported host tracegen target to generate files, not
the one we're going to cross-build.

This amends 5c092c2b40.

Change-Id: Ib74dd2d87110383c31216872eb55bebf5d90df37
Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
2020-09-10 18:05:54 +02:00
Joerg Bornemann
6b363bbde3 CMake: Document more configure argument mappings
Change-Id: I4f96fd59566d011088e426342db9cc6536d63a71
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-10 18:05:10 +02:00
Alexandru Croitor
8bc739fcc2 CMake: Register qtwaylandscanner dependency when cross-compiling
qt_record_extra_package_dependency is called by qtwayland to register a
dependency between the qtwaylandscanner tool and the waylandscanner
tool.

When cross-compiling the tools in a Yocto environment, the adjusted
target name was not taken into account.

Task-number: QTBUG-83968
Change-Id: Ibf7b94876bf29827cf0d9c9bb471f359ef6ff15f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-09-10 17:29:15 +02:00
Alexandru Croitor
abf7239541 CMake: Apply $ORIGIN style rpaths for non-prefix builds as well
This works around linking issues when doing yocto non-prefix Qt
builds, because CMake does not add -rpath-link flags even though it
probably should.

Task-number: QTBUG-86533
Change-Id: Iaaf246ac71ca05d9369ceb6eb9c4a1e206c42839
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-09-10 17:29:11 +02:00
Alexandru Croitor
3247f01c5e CMake: Fix qt_apply_rpaths not erroring out when no target is given
I accidentally noticed the message in a CI job, but it didn't fail the
build because the FATAL_ERRO was considered as another text token to
print, instead of a command keyword.

Change-Id: I0e30ebacbed32d1017f9ded681cd6b15cbc32573
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-09-09 18:53:49 +02:00
Alessandro Portale
72388f77a7 CMake: Turn off pkg_config_enabled if pkg_config is not found
The qt_build_internals_disable_pkg_config_if_needed function didn't
actually check if the pkg-config executable is available when turning
the pkg-config feature on.

This broke certain configurations like Android (on some hosts).

Try to find the executable and take that into account when computing
the value of the feature.

Task-number: QTBUG-85399
Change-Id: Ie79c637f2d2b689c392862c90075d309906fe506
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-09-09 18:53:45 +02:00
Alexandru Croitor
7b6d8261d8 CMake: Fix building of non-qtbase repos on Android with Windows host
The generated toolchain file embedded windows style paths for the
android sdk and chainloaded toolchain. This caused CMake does fail at
configure time while trying to evaluate backslashes as escape chars.

Also syncqt was searched for in libexec, which is not the right
directory on Windows. Use the host info package to get the location of
the 'libexec'.

Task-number: QTBUG-85399
Task-number: QTBUG-85911
Task-number: QTBUG-86053
Change-Id: I1b15ce84496d52c3fda2f65138e1eac43bc95c9e
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-09-09 18:52:54 +02:00
Alexandru Croitor
a6a3b82ffb CMake: Make generated Qt toolchain file a bit more relocatable
Rather than force setting the apple sysroot and Qt host paths, first
check if they are not already defined on the command line and if they
aren't, check that the paths with which Qt was configured exist.

The goal of the patch is to not set invalid paths, like when using a
Qt built in the CI, which will have a different host path / sysroot
compared to what a user has locally.

Task-number: QTBUG-85240
Change-Id: Ic37566b4fa845d8d1b4e4b5ba7fa4be769e99ca8
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-09-09 18:52:50 +02:00
Alexandru Croitor
948f2a9cac CMake: Don't hardcode Xcode SDK frameworks into public dependencies
Using find_library() to find an Xcode framework will end up embedding
the absolute path of the framework into INTERFACE_LINK_LIBRARIES.
A different machine might not have the SDK installed in the same
location, which will cause build failures. This happens in our CI
because Xcode is installed to /Applications/Xcode11.app.

To fix this, replace all system framework paths with
'-framework Foo' flags instead.
We already do this for OpenGL and OpenGL ES.

In the future we might want to convert these into full standalone
FindFoo scripts that expose proper targets.

Fixes: QTBUG-86299
Task-number: QTBUG-86422
Task-number: QTBUG-85240
Change-Id: I22b2b2d1d9e92108098d3974105e3758978cd8e2
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-09-09 18:52:46 +02:00
Thiago Macieira
3deb154d22 CMake: update ARCH_HASWELL flag
We don't support older compilers from before they accepted
the architecture codenames.

Change-Id: If13a10ed95b34007858bfffd1631a08b425fa9c3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-09-08 21:00:29 -07:00
Thiago Macieira
29ed0e3391 CMake: add missing RDSEED support
This was added for Qt 5 in 780137d585 but
apparently the change was never ported over to CMake.

Fixes: QTBUG-86452
Change-Id: If13a10ed95b34007858bfffd1631a084370a3232
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-08 21:00:29 -07:00
Marcel Krems
996e08734e Remove /INCREMENTAL:YES from linker flags
This flag doesn't exist in MSVC 2015+:
LINK : warning LNK4224: /INCREMENTAL:YES is no longer supported;  ignored
https://docs.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=vs-2015

Change-Id: I3b2aace619351e2dc9cc86e1df28facc21b7d9fe
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-05 15:12:50 +00:00
Joerg Bornemann
46f8c46bee CMake: Teach QtProcessConfigureArgs.cmake to configure other modules
Until now, QtProcessConfigureArgs.cmake could only handle qtbase and the
top-level build. Add the variable MODULE_ROOT that the user can point to
the module that is to be configured.

Example - QtDeclarative can now be configured like this:

cd qtdeclarative-build-dir
echo -qml-network > config.opt
cmake -DOPTFILE=config.opt -DMODULE_ROOT=<source-root>/qtdeclarative \
    -DCMAKE_COMMAND=<install-prefix>/bin/qt-cmake-private \
    -P <source-root>/qtbase/cmake/QtProcessConfigureArgs.cmake

A convenience script that saves the user from entering this unwieldy
incantation will be added in a subsequent commit.

Change-Id: If46103de3a8eb84b15e7600ebfec25544451e1d5
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-09-02 23:44:03 +02:00
Joerg Bornemann
e3c6e19ad0 CMake: Fix call to qt_apply_rpaths in qt_internal_add_app
We never passed a valid target name to qt_apply_rpaths.
This amends fde98f7794.

Task-number: QTBUG-85399
Change-Id: I1c023ce30a3a8b5ec43d020373960d19fe20f59a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2020-09-01 11:35:39 +00:00
Joerg Bornemann
5c092c2b40 CMake: Implement configure -trace
Task-number: QTBUG-85373
Change-Id: Ib9ac35ec98dd5b6c272f58f8a61a124d1d262ec0
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-09-01 13:35:39 +02:00
Alessandro Portale
7fe7bd326f CMake: Fix cmake wrapper creation when cross-building
Change-Id: I363ee470973df89d16314671e3c33771040061f2
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-28 12:09:53 +00:00
Joerg Bornemann
fde98f7794 CMake: Fix rpath for Qt internal applications (non-bootstrapped tools)
We need to call qt_apply_rpaths for targets that are created with
qt_internal_add_app too. This is in line with what qt_app.prf does.

Task-number: QTBUG-85399
Change-Id: If5ffb05cca191c6cae9a330e1f4556d342a68ff8
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2020-08-28 09:44:18 +00:00
Assam Boudjelthia
00a1e5da7e Android: add option to get app arguments with AndroidManifest.xml
AndroidManifest.xml file and the Android plugin already has a way
to provide commandline-arguments to app with the tag
"android.app.arguments". This change allow to set it from qmake/cmake
and allow Qt Creator to use that.

Task-number: QTCREATORBUG-23712
Change-Id: I3e680f40fd36ba6aaac7f344fb9509d2c3360e74
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2020-08-28 10:23:18 +03:00
Joerg Bornemann
de751066d6 CMake: Implement configure -force-asserts
Change-Id: Ife15b8d008c5b3f5eed61ec3bc048fda4c4b4e46
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-27 22:13:43 +02:00
Fabian Kosmale
b0e4545a4b CMake: Install QtHeadersClean.cmake
For prefix builds we need to install the file.
Amends db21bad936.

Change-Id: Ia8e859dc048cc4bd74eb95ed0d2adce9c6b11902
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-08-27 22:13:40 +02:00
Kai Koehne
639c2e7f20 cmake: Fix generation of third-party attributes
Fix name of target so that qtattributionsscanner actually generates content.

Change-Id: Ie42067928d7cd1de02fa4ae92a0f5ef54bd54a5c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-26 17:31:07 +02:00
Kai Koehne
f1b835e98f cmake: Fix building documentation on Windows
Make sure the executable path contains an .exe on Windows.

Change-Id: I972a3aaf1ad0510525ebfcc84e8c589f555c6d00
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-26 17:30:59 +02:00
Kai Koehne
146421ecaf headersclean: Check for all-W3 MSVC warnings
C4180, C4458 were disabled already in 2012, in commit 6668f5becf.
C4577 was disabled due to QtScript being compiled without exception
support in commit 97d7d80e73.

Anyhow, Qt Script is now officially gone in Qt 6, and Qt headers
do work just fine with C4180. Finally, C4458 is nowadays a W4 warning,
so not enabled in the first place.

Task-number: QTBUG-82615
Change-Id: I2f9b8e858817876b069a166129fbfac7ef3587a0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2020-08-26 17:30:40 +02:00
Kai Koehne
db21bad936 Port headersclean check to CMake
Configure Qt with -DQT_FEATURE_headersclean=ON to enable the
check. There will be separate target for each module include
(e.g. QtCore_header_check), but the check will also be done
when the module is built for the first time.

There are notable differences to the qmake version:
- the build does not pick up anymore default defines or flags from
  the module, or Qt. Instead options like -fPIC they have to be listed
  explicitly. Also for this reason, we have to skip the vulkan-related
  headers from the check, since vulkan/vulkan.h is not necessarily
  in the compiler's default search path.
- some checks for nowadays unsupported compiler versions are
  removed.
- -Wdouble-promotion -Wshorten-64-to-32 is not added for clang
  builds; the qmake code path did never enforce that on CI
  machines (it was non-Apple clang only), and the check currently
  fails on these configurations.

Fixes: QTBUG-82615
Change-Id: I1cd303677b1472116910b6c27748f96436feb35e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-25 21:13:08 +02:00
Samuli Piippo
3a4153766e CMake: use definitions when testing EGL
Use any definition from pkgconfig for the EGL compilation test.

Change-Id: I95c659b87ab7b0de81f000e3f52195161a493ef5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-25 08:04:39 +03:00
Joerg Bornemann
721812c5d2 CMake: Implement configure -gdb-index
Change-Id: Iea0fb99297751b1baf830a416ea5041d0b9a3b63
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-23 11:05:01 +02:00
Joerg Bornemann
97551b90b9 CMake: Actually evaluate AUTODETECT expressions in features
Very simple AUTODETECT expressions worked fine, but expressions with
parentheses, for example, were not correctly evaluated.

Change-Id: Ibec4fa55474e149a701f861838fdea41d31beca0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-23 11:04:51 +02:00
Joerg Bornemann
7e7c9ba455 CMake: Support configure tests of type 'linkerSupportsFlag'
Task-number: QTBUG-86155
Change-Id: I3764d99cd4ad1c432b499ec9ba7c4c48391fa421
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-23 11:04:46 +02:00
Joerg Bornemann
48cf015906 CMake: Implement configure -optimize-size
This configure switch controls the feature 'optimize_size'.

This isn't merely a mapping to CMAKE_BUILD_TYPE=MinSizeRel, because
we potentially want to combine -optimize-size with -force-debug-info,
which maps to CMAKE_BUILD_CONFIG=RelWithDebInfo.

Task-number: QTBUG-85373
Change-Id: I1a9343ebc54816f52e90e9d33ea3df4c99b1ec9f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-23 11:04:42 +02:00
Joerg Bornemann
c8fda317ea CMake: Fix configure setting superfluous features
Command line options like -debug result in setting the variable
INPUT_debug. INPUT_debug is mapped to the CMake argument
-DCMAKE_BUILD_TYPE=Debug. INPUT_debug also matches the feature
'debug', and the CMake argument -DFEATURE_debug=ON was passed.

Do not pass -DFEATURE_xxx CMake arguments for inputs that are already
handled.

Change-Id: If096dff1c6dd694545c6f671f5f3512a43c3ec50
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-23 11:04:38 +02:00
Joerg Bornemann
e66f5e491e CMake: Document more configure argument mappings
Change-Id: Icda71c14cde638e874cc2e6406527b9c98535165
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-23 11:04:32 +02:00
Alexandru Croitor
bf3d834ab4 CMake: Fix creation of host-qmake wrapper when cross-compiling
The -host prefix was added to the 'preliminary' directory rather than
the actual wrapper shell script. This caused it to be overwritten
every time by the cross-compiled qmake binary.

Change-Id: I103811c6aa9181fa701e3e7ecaf828ecdd1e3c90
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-23 11:04:07 +02:00
Joerg Bornemann
729d102b1c CMake: Implement configure -optimize-debug
Task-number: QTBUG-85373
Change-Id: I3aba1fcf96e36544dd75a5e6adc5f770a9a45726
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-20 17:07:53 +02:00
Joerg Bornemann
2f1a55c0b1 CMake: Implement configure -linker [bfd,gold,lld]
Fixes: QTBUG-86155
Change-Id: I5ba2d3b52d9ca240b48904c492f7902a056c0292
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-20 17:07:49 +02:00
Joerg Bornemann
df28355981 CMake: Support configure tests of type 'compilerSupportsFlag'
Task-number: QTBUG-86155
Change-Id: Iaa5c48b6508870a0f6afdf9df66cd2e634fe19b3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-20 17:07:46 +02:00
Cristian Adam
c4d3e5d7d3 CMake Build: Use EGL library as dependency for GLESv2
On QNX the feature detection of GLESv2 is failing due to missing
symbols which are part of EGL library.

Add EGL library as a dependency if it's found on the system.

This allows OpenGL ES feature detection to work on QNX.

Task-number: QTBUG-83202
Change-Id: I90531d925fadce5d893ea9244793fc02a4595ed1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-20 14:41:49 +02:00
Cristian Adam
73277763c1 CMake Build: Add QNX 7.1 build support
This commit allows building Qt6's QtBase using QNX 7.1 and a toolchain
file which is almost identical to what CMake has in its documentation:
https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-qnx

set(CMAKE_SYSTEM_NAME QNX)

set(arch gcc_ntoarmv7le)

set(CMAKE_C_COMPILER qcc)
set(CMAKE_C_COMPILER_TARGET ${arch})
set(CMAKE_CXX_COMPILER q++)
set(CMAKE_CXX_COMPILER_TARGET ${arch})

set(CMAKE_SYSROOT $ENV{QNX_TARGET})

The only difference is the usage of q++ instead of QCC, which is no
longer present in QNX 7.1 SDK.

Task-number: QTBUG-83202
Change-Id: I51031540721275f2ee83cee9e7df4994a65db0e2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-20 14:41:36 +02:00
Cristian Adam
12e4b63d28 CMake Build: Fix libdrm detection and compilation on QNX
On QNX 7.1 x86drm.h is located under <...>/usr/include/libdrm, unlike
linux where it's present under /usr/include.

find_path would not find it on QNX, and instead get /usr/include from
host, which resulted in a failure to compile.

Task-number: QTBUG-83202
Change-Id: I03d6c2d4dfbe91bb70df0a322e84890bd7c8548a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-19 18:43:37 +02:00
Alexandru Croitor
41800c3c31 CMake: Add /OPT:REF flag when building Qt on Windows
In qmake it's done for all qmake projects, in CMake we lean on the
safe side and apply it to building Qt itself. User CMake projects can
then choose to add it themselves.

Task-number: QTBUG-85992
Change-Id: I51919f947d43ffd9925e3d2837dcad17e480367d
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-08-19 18:26:00 +02:00
Alexandru Croitor
cb1600145b CMake: Adjust compiler flag optimizations to qmake mkspec ones
There are inconsistencies in the default optimization flags added by
CMake across configurations like Release and RelWithDebInfo.
In particular Release uses -O3, whereas RelWithDebInfo uses -O2,
as well as usage of /INCREMENTAL in release configs with MSVC, etc.

To make sure that the Qt 6 binaries built with CMake are consistent
across configs, as well as consistent with the flags we used when
building Qt 5 with qmake, add a horrible search and replace mechanism
to replaces the CMake flags with what our mkspecs indicate to use.

Ideally this would be done by providing custom CMake toolchain files
for each platform we support, and we might revisit that later if the
need really arises.

To implement the replacing, we first need the flags that should be
added. Port the QMAKE_CFLAGS_OPTIMIZE variables to CMake, which is
done in QtCompilerOptimization.cmake.

Then a new function called
qt_internal_set_up_config_optimizations_like_in_qmake will look for
any kind of optimization flags set in the
CMAKE_<LANG>_FLAGS_<CONFIG> style variables, remove them, and add
the appropriate flags that qmake mkspecs provide.

On some platforms (like Windows MSVC) the function also alters the
linker CMAKE_${TYPE}_LINKER_FLAGS_<CONFIG> style variables.

The mechanism allows opting out of this replacing by
setting the QT_USE_DEFAULT_CMAKE_OPTIMIZATION_FLAGS value.

It also allows opting into removal of flags for custom configs by
providing QT_ADDITIONAL_OPTIMIZATION_FLAG_CONFIGS. It's only removal,
because we wouldn't know what kind of config it is, and thus what
flags to add.

The currently modified configs are: Release, RelWithDebInfo,
MinSizeRel, Debug aka the usual default CMake provided ones.

The mechanism is only applied to C-like languages.
ASM is not handled to be on the safe side due to not knowing what kind
of compiler flags the platform assembler might take.
It's also important to skip RC on MSVC platforms.

Task-number: QTBUG-85992
Change-Id: I3712d5cd5a34fceab54f56a6fa46b4e678952362
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-08-19 18:25:59 +02:00
Cristian Adam
7e10dcb1d4 CMake Build: Add include guards for FindPPS.cmake and FindSlog2.cmake
The CMake configure process fails without include guards for these
two find modules on QNX.

Task-number: QTBUG-83202
Change-Id: I3cc589f98bc3b6b22c401421927ee6dab2663fb7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-19 12:46:10 +02:00
Cristian Adam
1b802c41eb CMake Build: Disable pkg-config for QNX
QNX doesn't come with pkg-config support.

Task-number: QTBUG-83202
Change-Id: I2ac0c014a071b83ef9a2d8114bae0e9ff9b3b422
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-19 12:46:10 +02:00
Kai Koehne
bfd4b958b5 CMake Port: Remove outdated information in README.md
Change-Id: Iefc1e13f5882ca69a2583f2454d00d9dfb42640d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-19 12:46:09 +02:00
Joerg Bornemann
5f729da74a CMake: Implement configure -qreal <type>
The configure argument -qreal <type> maps to the CMake argument
-DQT_COORD_TYPE=<type>.

Fixes: QTBUG-83325
Change-Id: I94970f31ccfb241b1dd4f1d9b6cef25d6684dc05
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-19 08:28:50 +02:00
Alexandru Croitor
f8af82e3b3 CMake: Fix usage of ccache when no executable was found
Change-Id: Ia9a44234cb074fa5ba2b1dc9ca22a676d1b2d4ce
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-18 10:40:26 +02:00
Joerg Bornemann
d6e41abd62 CMake: Handle -D, -I, -F and -L configure arguments
Introduce new CMake variables and map
-D to QT_EXTRA_DEFINES,
-I to QT_EXTRA_INCLUDEPATHS,
-L to QT_EXTRA_LIBDIRS,
and -F to QT_EXTRA_FRAMEWORKPATHS.

Those variables only affect the Qt build, not user projects.

Fixes: QTBUG-85878
Change-Id: I229df2eed1505a2619068d0d32975962b052569a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-17 18:19:24 +02:00
Alexandru Croitor
96dd73c5fe CMake: Fix typo in README about how to build Android for arm64
Task-number: QTBUG-85399
Change-Id: I764f5d5155d6548ca61d3217fb5bb10f5b15908f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-17 18:19:21 +02:00
Joerg Bornemann
f107713452 CMake: De-duplicate list input handling code in QtProcessConfigureArgs
Change-Id: I9fd77dd81f67fcc9a0306ab0d627257f209cdb08
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-17 08:08:26 +02:00
Joerg Bornemann
584d4be174 CMake: Re-implement configure/qmake's command line handling in CMake
We extend configurejson2cmake to read the "commandline"
information from configure.json. This data is then translated to CMake function
calls and written it into commandline.cmake files.

We extend QtProcessConfigureArgs.cmake to pick up those commandline.cmake
files to feed our command line handling code, which is a
re-implementation of the command line handling in qt_configure.prf.

The command line handler sets INPUT_xxx variables, similar to
configure/qmake's config.input.xxx variables. The INPUT_xxx values are
translated
- to -DFEATURE_xxx=ON/OFF arguments if the input represents a feature,
- to corresponding CMake variables if such a variable is known,
- or to -DINPUT_xxx=yyy CMake arguments.

Configure arguments that have an entry in
cmake/configure-cmake-mapping.md are actually implemented. Other
arguments are likely to need more work.

Task-number: QTBUG-85373
Change-Id: Ia96baa673fc1fb88e73ba05a1afb473aa074b37d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-17 08:08:20 +02:00
Alexandru Croitor
32121e9882 CMake: Split out some Android functions into a public API file
To fix CMake Qt For Android projects to configure, we need to move
some functions from a private CMake API file only, to a public one.

Add Qt6AndroidMacros.cmake which will be loaded by Qt6Core package.

We'll have to decide how we proceed with Qt5AndroidSupport.cmake,
because that file automatically runs code when included in Qt5, and we
usually don't want to do it.

We'll also have to decide how to handle the define_property() calls
that are still left in the private QtPlatformAndroid.cmake file.

With this fix, Qt example CMake projects that use
add_qt_gui_executable should now be buildable. An APK can be created
with 'ninja apk'.

Unfortunately Qt Creator 4.13 does not currently seem to support
opening and building CMake Qt For Android projects properly.
While the build succeeds after fiddling with the Kit settings, the APK
deploy step fails to run (at least on my machine).

So the simplest way to run the built APK is to open the android-build
dir with Android Studio and launch the example application from there.

Task-number: QTBUG-85399
Change-Id: I77f246331de7a6e9e6d4ba7d973730190138f136
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-08-14 21:40:28 +02:00
Alexandru Croitor
c1038019fc CMake: Fix various issues with building CMake Android projects
Fix detection of qt android platform plugin by globbing inside
the install qt6 prefix location. This is just a sanity check.

Fix platform plugin detection for CMake standalone tests configured
using qt-cmake-standalone-test, which used to look into the fake
standalone prefix location instead of the real Qt location.

Fix detection of stdlib path using CMAKE_SYSROOT.

Add a global apk target that allows easier building of all apk targets
defined in the project. Creation of this target can be opted out by
setting QT_NO_GLOBAL_APK_TARGET to TRUE.

Amends b1f8ca8032.

Task-number: QTBUG-85399
Change-Id: Ic9c1646b4f00e0084fe3f4397df471b8f925afd8
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-08-14 21:40:28 +02:00
Alexandru Croitor
3b3029f959 CMake: Move QtPostProcess functions into QtPostProcessHelpers.cmake
The helpers can now be included manually in a project to call any
required function. There was a use case for that in qttools, which was
not possible because including QtPostProcess early would produce side
effects.

Task-number: QTBUG-86035
Change-Id: I05d5576bbac45d4b9e298b23aa2a33088d64968e
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-08-14 21:40:28 +02:00
Alexandru Croitor
44cce1a2ea CMake: Split QtBuild.cmake into smaller files
QtBuild.cmake is huge. Split it.

Move module, plugin, tools, executables and test related functions out
of QtBuild.cmake into separate files.
Do the same for many other things too.

An additional requirement is that all the new Helpers files only
define functions and macros.
No global variable definitions are allowed, nor execution of commands
with side effects.

Some notes:
qt_install_qml_files is removed because it's dead code.

Some functions still need to be figured out, because they are
interspersed and depend on various global state assignments.

Task-number: QTBUG-86035
Change-Id: I21d79ff02eef923c202eb1000422888727cb0e2c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-14 13:17:11 +02:00
Alexandru Croitor
57b94b58df CMake: Allow opting out of global target promotion
The endless saga of fighting with qt_find_package and global target
promotion. In certain scenarios we want to opt out of target promotion
to global scope.

One such case is in qttools with WrapLibClang and Threads::Threads.
Threads::Threads will be found in the top-level scope via
Qt6Dependencies.
WrapLibClang is declared in src/ directory scope, and
then we try to promote it ands its dependencies to the global scope,
via qt_find_package() ->
qt_find_package_promote_targets_to_global_scope().

This fails because we can't promote Threads::Threads due to it being
added in a different subdirectory scope.

Introduce 2 new functions.
qt_internal_should_not_promote_package_target_to_global and
qt_internal_disable_find_package_global_promotion.

The first one is used to disable promotion of targets to global scope
in qt_find_package.

To mark a target not to be promoted, the second function is used.
It will be used by qttools for the WrapLibClang case.

Task-number: QTBUG-85877
Change-Id: If6caf10a94999402026517a623ae29e3ab1eeb7f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-13 21:36:37 +02:00
Joerg Bornemann
8a0ca71c4a CMake: Extend configure-cmake-mapping.md
Change-Id: Ie54b131c9a7b0f560fa735562fc4cbae4df35a49
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-13 20:07:54 +02:00
Alexandru Croitor
48dbcefe57 CMake: Allow specifying a sysconfdir that's outside the prefix
Also use the value to actually write it into qconfig.cpp so that qmake
reports the right information.

Change-Id: Icc4bf36b0dc6ad75d93ac16f39e5b361c0ce52b4
Fixes: QTBUG-81289
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-13 19:45:33 +02:00
Alexandru Croitor
9e044765ec CMake: Fix empty value of CMAKE_SIZEOF_VOID_P when looking for tools
Our initial approach to looking for host Qt tools when cross-compiling
to a platform with a different architecture bitness compared to the
host one was to unset CMAKE_SIZEOF_VOID_P before calling
find_package(Qt6FooTools) and then restoring the value.

That works to bypass the architecture bitness test in the
ConfigVersion files, but it also influences the paths that
find_package() searches in, specifically the lib<arch> paths like
/usr/lib64 will not be searched in.

Fortunately since CMake 3.14, write_basic_package_version_file() can
take an additional ARCH_INDEPENDENT parameter. This disables the
architecture bitness test when looking for the package, while allowing
to still search in the /usr/lib64 like paths.

Use it when creating the QtFooToolConfigVersion.cmake files.

One could argue we should actually check if the tool executables could
run on the host system where find_package is called for
cross-compilation.
We could do that in another change if the problem ever arises.

Amends 03aa74e40d
Amends 914b367c7f

Change-Id: I1181ff637ac80064a6a8538170b28a41743fc90c
Fixes: QTBUG-81672
Reviewed-by: Christophe Giboudeaux <christophe@krop.fr>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-13 19:45:29 +02:00
Joerg Bornemann
fdd61b3a7b CMake: Introduce QtFeatureCommon.cmake
This file provides common feature-functionality is supposed to be
included by QtFeature.cmake and QtProcessConfigureArgs.cmake.

Change-Id: Ifb483c2a9c4014d240c2a4d6ff07b5c0ceee9c3a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-13 19:31:59 +02:00
Joerg Bornemann
fb8aea60bd CMake: Write QMAKE_MACOSX_DEPLOYMENT_TARGET to qconfig.pri
If the user specified CMAKE_OSX_DEPLOYMENT_TARGET=10.15 for the Qt
build then building projects with qmake failed, because the mkspec
hard-codes QMAKE_MACOSX_DEPLOYMENT_TARGET to 10.14.

We now write QMAKE_MACOSX_DEPLOYMENT_TARGET to qconfig.pri to override
the mkspecs' default.

Fixes: QTBUG-85923
Change-Id: I6a39cfe047ac0f99e1da0ca0728d63c741bd4fed
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-13 19:31:59 +02:00
Joerg Bornemann
edc8c1ee9d CMake: Add missing newline at the end of qconfig.pri
Change-Id: I929d74234b685bf0684d3067f7f958d474df20ff
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-13 19:31:59 +02:00
Kai Koehne
ff6a3a80dd cmake: Suggest qt-cmake-private script for building other Qt modules
This automatically sets the CMake Generator to be the same as the one
used for qtbase.

Change-Id: If9e1a6942520417393055c572f0d892efca43d2e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-12 16:37:51 +02:00
Alexandru Croitor
52fdb9dc93 CMake: Fix Threads::Threads dependency handling with CMake < 3.18
Apparently CMake encods targets from different scopes with a different
encoding scheme for earlier CMake versions.

CMake 3.16.3: Threads::Threads::@<0x5604cb3f6b50>
CMake 3.18.0: ::@(0x5604cb3f6b50);Threads::Threads;::@

Handle the earlier version approach as well. It needs to be done both
when writing out 3rd party dependencies, as well as for lib prl files.
Possibly in more places as well, but I didn't detect additional
places yet.

Amends 92ee9bd6b8

Task-number: QTBUG-85801
Task-number: QTBUG-85877
Change-Id: Ib348b51b2d623fb50d9080dba2beeb931d47a69c
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-08-12 16:29:35 +02:00
Richard Moe Gustavsen
1d4457da13 cmake, README: clearify the usage of '-' in feature names
It's not immediately obvious that you need to use
all underscores for the feature name, so add a
line that explaines it.

Change-Id: I508eaf909c808fb0a93442f6e71428c18559b965
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-12 14:51:18 +02:00
Alexandru Croitor
bc0f5f5d1a CMake: Expose public info about whether Qt is a shared lib build
We expose it in the private QtBuildInternals package, but we need it
also as public information for consumption in qt_import_qml_plugins()
to decide whether it should do anything.

Change-Id: If135ae596b4edaf8e2c458f6a2518b968c6d01c4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-12 14:20:44 +02:00
Alexandru Croitor
81ea5f1906 CMake: Prepare ground work for static Qml plugins importing
For qt_import_qml_plugins to work, it needs to have access to the Qml
plugin targets by the time find_package(Qt6Qml) is called.

To do that, we modify the generation of Qml plugin Config, Targets and
Dependencies files to go into a special 'QmlPlugins' subfolder of the
Qml package.

The Qml package will then GLOB include all the Config files in that
folder, to make them available whenever find_package(Qt6Qml) is
called.

This is similar to how the Qt plugins were glob included in the CMake
integration of Qt 5.15. In fact that glob including is missing in Qt 6
for regular Qt plugins, and should be implemented in a following
change. Currently the Qt Plugins config files that are included are
hardcoded to the list of known plugins at Qt configuration time.

As a drive-by to make this all work, the naming of the various Config
and Dependencies files has been normalized to include the Qt6 prefix.
This is done for both regular Qt plugins and Qml plugins.

Task-number: QTBUG-85961
Change-Id: Id20da72337ca2945fa330ea6fb43535e44a83292
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-12 14:20:40 +02:00
Alexandru Croitor
ecc72bc63d CMake: pro2cmake: Specify library versions for 3rd party libs part 2
Embed package versions into the qt_find_package calls for various
Linux specific packages.

Task-number: QTBUG-82917
Change-Id: I5d1cb623f81932dfae4658b8a3a89eedb71ea3af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-10 11:56:54 +02:00
Alexandru Croitor
3c52f8af9d CMake: pro2cmake: Specify library versions for 3rd party libraries
If certain 3rd party libraries have a version that's not suitable for
Qt, the configure summary should say so, rather than use them and fail
at build time.

With the current situation, we have to duplicate the version
information from the configure.json files in helper.py, by assigning
the version number as an extra find_package variable.

Rerunning configurejson2cmake then embeds this version info into the
qt_find_package calls in configure.cmake.

Some of the Find modules are rewritten to take the  specified version
into account when looking for the libraries.
This involves moving around the code for creating a target, after
calling find_package_handle_standard_args() so we know if a good
enough version was found.

Task-number: QTBUG-82917
Change-Id: I139748d8090e0630cda413362760034dc3483e11
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-10 11:56:54 +02:00
Robert Loehning
7d7e62967f configure: Explicitly enable float-divide-by-zero with ubsan
Before clang 9, it was enabled by default
when -fsanitize=undefined was set.

Pick-to: 5.15
Change-Id: I0faf3ae1901d4badc6d265fa8081185be4360636
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-07 01:21:07 +02:00
Mårten Nordheim
ad1a5bf63f QDecompressHelper: Add brotli support
Task-number: QTBUG-83269
Change-Id: If23b098ee76a4892e4c2c6ce5c635688d8d9138d
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-08-06 20:56:42 +02:00
Alexandru Croitor
f32a38b6c6 CMake: Don't use lld linker for Android with a Windows host
Most of the time lld just gets stuck (deadlock) waiting on some
mutex, thus failing integrations.

Amends 64c111e10f

Task-number: QTBUG-85911
Change-Id: Id73bf967a7aeb0e0cbccfaafe056b325c8711f82
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-08-06 19:20:04 +02:00
Alexandru Croitor
d50a7d635c CMake: Fix prl files of static Qt builds
Static Qt plugins should not be included in the list of libraries of
a prl file. They end up being there due to our circular dependency
trick where the plugins depend on the module they belong
to.

This in turn causes the giant static plugin generator expressions to
be processed in qt_collect_libs(), and the generated prl file ends up
having target names like Qt6::QJpegPlugin which are obviously not
linker flags.

To eliminate the static plugins from prl files, add an additional
dummy boolean generator expression '$<BOOL:QT_IS_PLUGIN_GENEX>'
that always evaluates to true. We can string match on this expression
in qt_collect_libs, and thus remove the whole static plugin genex
entry.

This should fix linking of apps with qmake that use a CMake-built
static Qt.

Task-number: QTBUG-85865
Task-number: QTBUG-85240
Task-number: QTBUG-85801
Change-Id: I949dc5edb10d94c4ab84ed430af7c164d8efaaa6
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-08-06 19:19:46 +02:00
Alexandru Croitor
92ee9bd6b8 CMake: Properly handle CONFIG += thread aka Threads::Threads
mkspecs/features/qt.prf adds a dependency on the system threading
library if the Qt Core thread feature is enabled. Because qt.prf is
loaded by any public or internal Qt project, it's essentially a public
dependency for any Qt consumer.

To mimic that in CMake, we check if the thread feature is enabled, and
and set the Threads::Threads library as a dependency of Qt6::Platform,
which is a public target used by all Qt modules and plugins and Qt
consumers.

We also need to create a Qt6Dependencies.cmake file so we
find_package(Threads) every time find_package(Qt6) is called.

For the .prl files to be usable, we have to filter out some
CMake implementation specific directory separator tokens
'CMAKE_DIRECTORY_ID_SEP' aka '::@', which are added because we call
target_link_libraries() with a target created in a different scope
(I think).

As a result of this change, we shouldn't have to hardcode
Threads::Threads in other projects, because it's now a global public
dependency.

Task-number: QTBUG-85801
Task-number: QTBUG-85877
Change-Id: Ib5d662c43b28e63f7da49d3bd77d0ad751220b31
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-08-06 19:15:39 +02:00
Joerg Bornemann
6c07e9f3bb CMake: Fix build with custom INSTALL_INCLUDEDIR
The include directory in Qt's build directory is always named
"include", no matter what the value of INSTALL_INCLUDEDIR is. The main
reason is that the name "include" is hard-coded in syncqt.

The INSTALL_INCLUDEDIR variable must only affect the installation
location of headers.

Fixes: QTBUG-85893
Change-Id: I5367bc589cba129eb41817e2b58d470f730bb5ac
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-06 13:17:02 +02:00
Joerg Bornemann
7ec0786d78 CMake: Don't build debug tools by default in debug_and_release builds
Fixes: QTBUG-85411
Change-Id: Idd9664d1a9143c31f28549a72823a82df1cff7ec
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-05 14:34:12 +02:00
Alexandru Croitor
f69dbb0b41 CMake: Don't use std=gnu++11 when building Qt internal targets
The logic is a bit involved in qmake.

The Qt internal qt_common.prf adds CONFIG += strict_c++ which applies
to qt modules, qt plugins, qml plugins, qt helper libs, winmain and
qt_apps, qt_tools, but NOT tests (which is important because the tests
on Windows MinGW fail to build without the GNU extensions).

Then default_post.prf checks for the strict_c++ value and either uses
the strict or non-strict C++ standard flags. default_post.prf is
loaded for all qmake projects, not just the Qt internal ones.

Now CMake doesn't provide a transitive based option to disable C++
GNU extensions with a mechanism similar to target_compile_features.

It only provides the CXX_EXTENSIONS property and it's associated
CMAKE_CXX_EXTENSIONS variable. We can't set the variable at a
directory scope, because that is too coarse grained.

So we rely on setting the property via a function in every relevant
qt_add_<target> function.

Now the naming of the function is weird.
We name the function as qt_internal_<...>, because it's not meant to be
used by Qt users.

We prepend an underscore to the name because we need to place it in
Qt6CoreMacros, so that the function can be called by
qt_add_qml_module which IS a public function.
That's because in Qt5 load(qml_plugin) was private API, but in Qt 6 +
CMake we decided to make qt_add_qml_module() as public API.

Change-Id: Id014626b087d590e25cb46843f93d0c67fc36e44
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-05 09:03:15 +00:00
Alexandru Croitor
0125e48ce0 CMake: Don't generate prl libs for Windows shared libs
Windows shared library prl files should not have a
QMAKE_PRL_LIBS section. Such information is not useful because it's
not used by the linker as per 523c7e3fd5

Amends 46d7abc9172f82756ccd3641a314dcc066353c3f

Task-number: QTBUG-85240
Task-number: QTBUG-85801
Change-Id: Ic40491a568f72c507a16322f6f0c61f98d3a5913
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-04 19:40:51 +02:00
Linus Jahn
c19bafc60c QtCore: Use system-wide libb2 if present
This adds the option to build Qt with libb2, which is especially
recommended, if you care about the performance of the BLAKE2 hashing
algorithms. The bundled version is the pure reference C implementation
of BLAKE2, while libb2 has many additional hardware optimizations.
However, the API of both is the same, so no changes to the code were
necessary here.

Change-Id: I3563982f4e07be300291fe103c38b16a404b3ebb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-31 15:05:24 +02:00
Alexandru Croitor
9c0f448f5a CMake: Fix generated content of prl files (again)
Apply the same kind of transformations to the contents of the prl
files as we do for pri files. Mainly, transform system library paths
that are absolute, into link flags to make them relocatable across
systems.

Also change the Qt frameworks to be linked via the -framework flags
instead of via absolute paths.

Implementation notes

Move the common required functions for both QtFinishPrlFile and
QtGenerateLibPri into a common QtGenerateLibHelpers.cmake file.

Make sure it's listed as a dependency for the custom commands.
Also make sure to pass the necessary input values like possible
library prefixes and suffixes, as well as the link flag.

Task-number: QTBUG-85240
Task-number: QTBUG-85801
Change-Id: I36f24207f92a1d2ed3ed2d81bb96e4e62d927b6e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-07-31 14:29:45 +02:00
Alexandru Croitor
b3b1e47378 CMake: Introduce qt_internal_add_app
This new function is meant to be used where load(qt_app) is used.

It delegates functionality to qt_add_executable, while handling
some additional behavior via a finalization function (mostly handling
of macOS Info.plist files and icons, as well as Windows icons and
resource files)

It uses a new PlatformAppInternal interface target.

Task-number: QTBUG-85757
Change-Id: I1a2d5851b137fcd4a6323e0e06fb154f91619800
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-07-31 12:55:32 +02:00
Alexandru Croitor
9d55d6b45b CMake: Fix building debug apps with qmake on Windows
Our CMake build system only generated working .prl files for
the Release configuration in debug_and_release.

This caused a linking failure when building a Widgets example that
links against qtmain, specifically

qtmaind.lib(qtmain_win.cpp.obj) : error LNK2019: unresolved external
symbol __imp_CommandLineToArgvW referenced in function WinMain

The symbol is located in shell32.dll, which was not linked in, because
there was no qtmaind.prl file.

The fix to generate per config prl files is a bit complicated, because
add_custom_command does not support generator expressions in OUTPUT
and DEPENDS.

Instead we pre-generate 2 files per config, one with the preliminary
prl file content and another file that contains the final prl file
path (via generator expression).

Then we iterate over all configurations and create custom commands
with well known paths, and the final prl file is created by the script
called by the command.

Amends 06557312d2

Task-number: QTBUG-85240
Change-Id: I413b705bc69732b0cbe1ee8cd089a1aef19365db
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-07-29 17:33:15 +02:00
Alexandru Croitor
7b9904849f CMake: Fix _nolink targets to be optional on the consumer side
On Windows, if Qt is built with Vulkan support but the user's machine
does not have Vulkan, it should still be possible to configure and
build an application (if the application does not use Vulkan of
course).

When Qt is built with qmake, the special windows_vulkan_sdk.prf file
makes sure not to export build time Vulkan include headers into the
generated .pri files. The same file also tries to find the include
headers via an environment variable. If it isn't set, it just adds a
bogus "/include" include path, which doesn't fail a user's application
build.

This wasn't the case for an application built with CMake, because the
exported Vulkan_nolink target uncodinitionally referenced Vulkan's
target properties. Which means that if the Vulkan package was not
found, the application failed to configure.

To mimic qmake's behavior, make sure to query the target properties
only if the Vulkan target exists, via the TARGET_EXISTS generator
expression.

Apply the same logic to all _nolink targets. This might not be
entirely correct in all cases, but we can revise this behavior later
after more feedback. At the very least it allows building non-Vulkan
based applications.

Task-number: QTBUG-85240
Change-Id: Iffbb03a84e8637ed54d0811433e66fe6de43d71f
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-07-29 17:33:14 +02:00
Tor Arne Vestbø
3251adb919 cmake: Add some air to configure summary
Change-Id: I3408957d8a81ac3080eac28e48dbafe9059e22f5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-26 20:12:48 +02:00
Alex Richardson
99ebbaead7 Make missing XCode a warning instead of an error
This fixes the macOS build when you only have the CommandLineTools installed.

Change-Id: I620bc535b508b604a875f53dec8c57af23efeac1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-07-26 16:13:29 +01:00
Tor Arne Vestbø
5f05b9880e cmake: Add LOWDPI option to match CONFIG+=testcase_lowdpi
Change-Id: I8bcabf41ed353ec4e940a8fcea5b698e0ddf278f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-24 18:08:04 +02:00
Alexandru Croitor
ec90f9013b CMake: Fix handling of CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH
While trying to implement the 'host artifact reuse' Coin instructions
change, a bug surfaced where the qemu configurations didn't find
the host tools and instead tried to use the cross-compiled tools
while building qtbase, which failed due to not finding the
runtime linker (another unsolved issue).
Before the host artifact reuse change, the host tools were found
successfully.

The difference that caused the issue is that the target install prefix
was a direct subfolder of the host prefix.
host - /home/qt/work/qt/install
target - /home/qt/work/qt/install/target

Before the host reuse change the install prefixes were as follows
host - /home/qt/work/qt/install/host
target - /home/qt/work/qt/install/target

While looking for the Qt6CoreTools package, we temporarily set
CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH to contain first
'/home/qt/work/qt/install' and then '/home/qt/work/qt/install/target'.
CMake then reroots the CMAKE_PREFIX_PATH values onto values in
CMAKE_FIND_ROOT_PATH, making an MxN list of prefixes to search.
Rerooting essentially means concatenating 2 paths, unless the
considered prefix is a subfolder of the root path.

What happened was that the first considered value was
'/home/qt/work/qt/install/home/qt/work/qt/install', a non-existent
location that gets discarded.

The second considered value was '/home/qt/work/qt/install/target.
The second value is the result of seeing that
'/home/qt/work/qt/install/target' is a subfolder of
'/home/qt/work/qt/install' and thus the root path is stripped.

All of this is done in cmFindPackageCommand::FindConfig() ->
cmFindCommon::RerootPaths.

The behavior above caused the target tools be found instead of the
host ones.

Before the host reuse change, both of the initial constructed prefixes
were discared due to them not existing, e.g.
'/home/qt/work/qt/install/target/home/qt/work/qt/install/target'
and '/home/qt/work/qt/install/host/home/qt/work/qt/install/host'

One of the later prefixes combined CMAKE_FIND_ROOT_PATH ==
'/home/qt/work/qt/install/host' + CMAKE_PREFIX_PATH == '/' resulting
in '/home/qt/work/qt/install/host/' and this accidentally found the
host tools package.

We actually stumbled upon this issue a while ago when implementing Qt
5.14 Android CMake support in 52c799ed44
That commit message mentions the fix is to add a "lib/cmake"
suffix to the PATHS option of find_package().
This would cause the subfolder => strip root behavior mentioned
above.

So finally the fix.

First, make sure not to append QT_HOST_PATH in the toolchain file,
there shouldn't be any need to do that, give that we temporarily set
it when looking for Tools packages.

Second, recreate the subdir scenario in the Qt toolchain file by
setting CMAKE_FIND_ROOT_PATH to the current (relocated) install
prefix as usual, but also setting CMAKE_PREFIX_PATH to a new value
poining to the CMake directory.
Aka '/home/alex/qt' and '/home/alex/qt/lib/cmake'.

Third, when a QT_HOST_PATH is given, save 2 paths in the generated Qt
toolchain: QT_HOST_PATH and QT_HOST_PATH_CMAKE_DIR. There are the host
equivalents of the target ones above. Use these values when looking
for host tools in Qt6CoreModuleDependencies.cmake, again facilitaing
the subdir behavior.
Note these are currently absolute paths and are not relocatable.
We'll have to figure out if it's even possible to make the host path
relocatable.

Finally as a cleanup, look for the Qt6HostInfo package in QtSetup
strictly in the given QT_HOST_PATH, so CMake doesn't accidentally find
a system Qt package.

Change-Id: Iefbcfbbcedd35f1c33417ab7e9f44eaf35ff6337
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-07-24 17:33:21 +02:00
Alexander Volkov
865582bd7f Add -Wsuggest-override for gcc >= 9.2
gcc doesn't report warnings for final methods since version 9.2:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010

Change-Id: I7152351aac0e3bad86d777e119f25137ef97ec6f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2020-07-24 13:10:51 +03:00
Alexander Volkov
ff04c65083 Avoid enabling of "warnings_are_errors" flags for tests
Change added dep in qt_add_cmake_library():
PlarformModuleInternal -> PlatformCommonInternal.

Change-Id: I303a6a520f0dda7260b12cb21673b8f1a23d536b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-23 15:37:48 +03:00
Tor Arne Vestbø
e85c531c51 testlib selftest: Don't pass TESTARGS to Catch2
It doesn't understand the arguments we usually pass to testlib.

Change-Id: Iea83d1d8c31a510b2bc442cbfc810eac631322e7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-23 11:08:15 +02:00
Alexandru Croitor
cdecf0edb2 CMake: Print various CMake and Qt CMake information variables
Sometimes the info we show in the configure summary might differ from
the information that CMake computes.
To more easily debug and fix such cases, print out various CMake info
variables like host and target info, compiler versions, sdk versions,
etc.

Change-Id: I37a11dfabe5369236af78684a09bd3cec3fdd398
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-07-20 18:12:29 +02:00
Alexandru Croitor
bd4726fa5d CMake: Pass CMAKE_OSX_ARCHITECTURES to try_compile on macOS
There was an inconsistency where configuring qtbase on Apple Silicon
with the following command line produced different results rom the
second variant.

$ cmake ../qtbase -DCMAKE_OSX_ARCHITECTURES=arm64
vs
$ CMAKE_OSX_ARCHITECTURES=arm64 cmake ../qtbase

That happened because the CMAKE_OSX_ARCHITECTURES variables was not
passed to project-based try_compile calls. This resulted in compile
tests like SIMD avx to succeeded on Apple silicon, which shouldn't.

To address that, always pass the architecture on macOS if it's
specified.

Change-Id: Ia12e86230cc6e5e11f387e3cbb273d90646ef2e3
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-07-20 18:12:26 +02:00
Alexandru Croitor
5e0129f63c CMake: Fix configuration of CMake tests in-build-tree
Qt6 package was not found the tests were configured in-tree as opposed
to standalone tests.
Use the same trick we do for building examples in-tree.
Specify the path to the build tree packages, and don't create targets.

Amends 96e3ee0659

Change-Id: Ia60de416ce0afff5bd40be8c0c6e3c7898fd7ebf
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-07-20 18:12:23 +02:00
Alexandru Croitor
054b66a657 CMake: Provide old style CMake variables for target info
This change provides the following per-module variables
Qt6Widgets_LIBRARIES, Qt6Widgets_INCLUDE_DIRS, Qt6Widgets_DEFINITIONS,
Qt6Widgets_COMPILE_DEFINITIONS, Qt6Widgets_PRIVATE_INCLUDE_DIRS.

These are deprecated and are only intended for easier porting from
Qt5 to Qt6. Qt consumers should instead rely on the Qt module targets
e.g target_link_libraries(app PRIVATE Qt6::Widgets)

Note that the variable contents includes transitive values for
everything except the _LIBRARIES variant. So Qt6Widgets_INCLUDE_DIRS
will contain values for Widgets, Gui and Core.

Qt6Widgets_LIBRARIES only contains a value like Qt6::Widgets, and when
that is used in target_link_libraries(), CMake will take care of the
transitivity.

Change-Id: I625e25aab7ba5eaf14de1dc76ba2a1a0c85e6226
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-07-17 09:43:00 +02:00
Alexandru Croitor
bc29555e6e CMake: Fix old style find_package(Qt6Foo) to work
Each module package needs to first find the Qt6 package to ensure
that all the necessary info is setup for further depedencies to be
found.

Task-number: QTBUG-81672
Change-Id: I3ee608d24c1efbb63a063261fb36341bf52fb78d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-07-17 09:42:56 +02:00
Jonas Karlsson
a99bc30e1e Add OS-specific prelude to qt-cmake-standalone-test
This makes sure the executable is run as a shell script
with the proper interpreter on Unix systems.
Otherwise it will fail in some shells, like fish.

On windows, it prevents all commands in the batch file
from displaying on the screen.

Change-Id: If554262f172b035b9661b3e2ff26a96789fa707b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-15 15:13:05 +00:00
Joerg Bornemann
ce9efcf4a9 CMake: Fix QT_STAGING_PREFIX for repos other than qtbase
For repositories other than qtbase the QT_STAGING_PREFIX was empty,
because it was only determined in qtbase.

Also, we save the CMAKE_STAGING_PREFIX in the Qt6BuildInternals package
and set this variable if it's not explicitly set by the user.
As with CMAKE_INSTALL_PREFIX this behavior can be prevented by defining
QT_BUILD_INTERNALS_NO_FORCE_SET_STAGING_PREFIX=ON.

Change-Id: I73100abbef24f5d3fb8f82029d0374176edc8048
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-13 14:56:49 +02:00
Joerg Bornemann
004d3fab49 CMake: Fix CMAKE_INSTALL_PREFIX assignment in QtBuildInternalsExtra
The prefix value must be surrounded by double quotes in case it
contains whitespace.

Change-Id: I393c57368d7a255f5042e363405071ef042afc18
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-13 14:56:44 +02:00
Allan Sandfeld Jensen
60d72b7ab6 CMake: Fix incorrect SIMD arch_haswell and avx profile conditions
Fix the conditions in qt_add_simd_part for arch_haswell and the
avx512 profiles to mimic what simd.prf does.

Add missing SIMD flags in QtCompilerOptimization for arch_haswell.

Compute the compile flags for the avx512 profiles from the
profile dependencies.

Remove the special case in Gui that hardcoded the compilation of
qdrawhelper_avx2.cpp to be conditional on avx2 being enabled
instead of arch_haswell. The Gui project already has another
qt_add_simd_part that is enabled if arch_haswell is enabled, which
will now work correctly due to the fixes in qt_add_simd_part.

Change-Id: I7a61a03b5565d4fa438f22b329e0d9dd7acd9273
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-07-09 23:02:39 +02:00
Alexandru Croitor
b1f8ca8032 CMake: Fix various issues with the Android build
Certain resources and compiled jar files have to be copied into the
non-prefix build dir location. They were previously only installed,
which doesn't do anything in a non-prefix build.

Change pro2cmake to generate code that places the compiled java
jars into QT_BUILD_DIR, so that non-prefix builds work.

Place the module dependencies xml files into lib folder in non-prefix
builds.

Don't special case the output and install location of the Android QPA
plugin.

Task-number: QTBUG-85399
Change-Id: I4ac9d3929ea8ecc95ec99a77e621ad2121b68832
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-07-09 11:56:31 +02:00
Alexandru Croitor
d5e8a5d9cb CMake: Fix missing qdevice.pri values and qt.conf info for Android
qdevice.pri should embed info about the Android SDK, NDK, host,
platform api level and ABI.

The machine tuple test should not be run for uikit and Android
platforms.

Sysroot should also not be prepended for uikit and Android
platforms, otherwise it breaks Qt module include paths.

Task-number: QTBUG-85399
Task-number: QTBUG-82581
Change-Id: Ic48c88f6ab15d75c2ebc323c8d7a3b7e5596f3c1
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-07-09 11:56:26 +02:00
Joerg Bornemann
d98a6d0463 CMake: Fix path to qt-cmake in configure summary
The path was wrong if CMAKE_STAGING_PREFIX was set.

Change-Id: Iec90c7a5edf0da80a0ac108fe3411c340c01e9a9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-09 08:55:38 +02:00
Joerg Bornemann
84dcbe4d5d CMake: Fix qt-cmake-standalone-test when CMAKE_STAGING_PREFIX is set
The qt-cmake-standalone-test script is kind of a "host tool" and
contained paths to CMAKE_INSTALL_PREFIX, which is wrong if
CMAKE_STAGING_PREFIX points to somewhere else.

Fixes: QTBUG-85336
Change-Id: I4828dc6868d55cfc60f3ad2199185230d5cc9028
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-09 08:55:32 +02:00
Joerg Bornemann
acf6ef536f CMake: Introduce QT_STAGING_PREFIX
Add the cache variable QT_STAGING_PREFIX that is the same as
CMAKE_STAGING_PREFIX - if it's set, or CMAKE_INSTALL_PREFIX otherwise.

Use the variable in the places where we check for the emptiness of
CMAKE_STAGING_PREFIX to use CMAKE_INSTALL_PREFIX.

Change-Id: I372d57dfa41818c1965b824c59ab3cac80b38f60
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-09 08:55:27 +02:00
Joerg Bornemann
22b663f55d CMake: Fix -pch configure option
This amends dbd3c75965.

Change-Id: Ia87d60f1da65624bc5c6ffb915eecf99a2d8bdc0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-08 07:09:18 +02:00
Joerg Bornemann
544b08f664 CMake: Support the -rpath configure argument
Task-number: QTBUG-85373
Change-Id: I04bdf307556aeab607a95d153cbe19254044c1f4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-08 07:09:14 +02:00
Joerg Bornemann
619ec7bc15 CMake: Support the -c++std configure argument
Task-number: QTBUG-85373
Change-Id: I071c1d0c8bf96b34c5733d039b8a61e54e416800
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-08 07:09:10 +02:00
Joerg Bornemann
23216a6193 CMake: Support the -qtnamespace configure argument
Task-number: QTBUG-85373
Change-Id: I3f995b31339a3c2b0c97ca806c652bc67846fc69
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-08 07:09:05 +02:00
Joerg Bornemann
63e90281b2 CMake: Support mkspec-related configure arguments
Task-number: QTBUG-85373
Change-Id: I44ae15b4c05f23442ac6b9d69d31f22f01d0a48c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-08 07:09:00 +02:00
Joerg Bornemann
fe5fa1d974 CMake: Support -static, -shared and -framework configure arguments
Task-number: QTBUG-85373
Change-Id: I0a1db7dcb4cb1738fa1ba0a687d41c5f5a613364
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-08 07:08:56 +02:00
Joerg Bornemann
a02d2d3f22 CMake: Write EXTRA_RPATHS to qmodule.pri if QT_EXTRA_RPATHS is set
Change-Id: Icd13cc047a9ca33f2ec9b6c2ce8216cbc4ae378b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-07 07:16:38 +02:00
Joerg Bornemann
26fbf8082c CMake: Support configure -force_debug_info
Task-number: QTBUG-85373
Change-Id: Ia798fc2cf715aed9157e1d9e2f64187c16e38bcf
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-06 17:44:01 +02:00
Joerg Bornemann
dd77597252 CMake: Support build config-related configure options
This add support for the following options: -debug, -release,
-debug-and-release. For the latter, the "Ninja Multi-Config" generator
is auto-detected, if ninja is available.

Task-number: QTBUG-85373
Change-Id: Ide0ca44e5f4c74657147e89d71e8d71c4f6a4c45
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-06 17:43:52 +02:00
Joerg Bornemann
ab559e25af CMake: Support -bindir, -libdir, -*dir configure arguments
Task-number: QTBUG-85373
Change-Id: I0df181cb017561c3f0af5ab3fecb76008b89c0d2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-06 17:43:42 +02:00
Joerg Bornemann
3ac054d6a8 CMake: Re-work configure flags for CMake generators
Remove the -cmake-makefiles configure argument as its meaning was in
essence "do not pass a -G argument to CMake".
Instead, we add the following arguments:
    -cmake-generator <name> to pass -G <name> to CMake
    -cmake-use-default-generator to pass no -G argument to CMake

If none of those arguments is given, we try to autodetect the
generator. If a ninja executable is found, we prefer the Ninja
generator. On Unix we fall back to "Unix Makefiles".
On Windows, we do a poor man's compiler detection and select one of
"NMake Makefiles", "NMake Makefiles JOM" and "MinGW Makefiles".

Change-Id: Ic36669bd50956d15fbc71cee73720732cd4bfab8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-06 17:43:35 +02:00
Joerg Bornemann
dbd3c75965 CMake: Teach configure.bat the -cmake argument
The configure scripts need to translate configure options to CMake
arguments. It is not sensible to implement this translation twice, in
sh and Windows batch language, so we're doing this once, in CMake
language.

The configure scripts write their options into config.opt and call a
CMake script that reads config.opt, does the translation to CMake
arguments and calls CMake to generate the build system.

While we're at it, implement some more translations than the sh
configure provided, like -extprefix, -top-level and -skip.

Fixes: QTBUG-85349
Fixes: QTBUG-85350
Task-number: QTBUG-85373
Change-Id: Ida5d8b2a3c178b9349d41ec76d190c69a9456e74
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-07-06 17:43:28 +02:00
Alexandru Croitor
7067b2ca6e CMake: Don't propagate private defines for Qt header modules
Interface libraries like our Qt header modules should not propagated
private defines which are meant only for building a specific Qt
module, and in the case of a header module there is nothing to build.

Exclude the usual private defines we set in qt_add_module for header
modules. This also fixes the content of header module .pri files.

Change-Id: I0791ebdb73e8b020ddb8116433ed36c7b3d71303
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-07-05 13:54:02 +02:00
Alexandru Croitor
1b7a0bcbb5 CMake: Fix non-prefix builds
QT_WILL_INSTALL was set to ON, because an incorrect comparison was
done.

Amends 062318feb2

Change-Id: I201aa2a183563ce05077c36ac2ba3bd61cc827c0
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-07-02 20:40:33 +02:00
Joerg Bornemann
f6a07dfcb7 CMake: Write QT_CPU_FEATURES to qmodule.pri
To achieve this, we save the result of the subarch test in the cache
variable TEST_subarch_result and use this value as the right hand side
of the QT_CPU_FEATURES.xxx assignment. The Qt6HostInfo package now
sets the variable QT6_HOST_INFO_SUBARCHS which will be used for the
host_build scope in qmodule.pri when cross-building.

Change-Id: I2c25f205bfc0692aef0d6f43ff4e542d27e1b948
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-02 15:35:17 +02:00
Tor Arne Vestbø
1048d83fc2 Limit OpenGL deprecation silencing on Apple platform to Qt itself
Apple deprecated the entire OpenGL API in favor of Metal, which
we are aware of, so we don't need to see the warnings when building
Qt.

Instead of applying the silencing globally for all Qt consumers,
both internal and external, we now limit the silencing to Qt itself.
That means user code that explicitly uses any of the deprecated APIs
will see the warnings. Note that this does not apply to merely using
any of the Qt OpenGL APIs. The user has to explicitly use the platform
APIs that have been deprecated.

The warnings need to be disabled on a build system level, so that
that they are passed as -D flags on the command line. If the defines
were done in Qt headers (qguiglobal.h e.g.), they would require the
user to always include this header before any of the Apple headers.

Change-Id: I3f2a2a5211332a059ad4416394251772c677fdcb
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-07-02 10:27:58 +02:00
Joerg Bornemann
ea8ba787ab CMake: Document the mapping of configure options to CMake arguments
Add internal documentation how to map configure options to CMake
arguments. This patch adds a markdown file with a giant table, and
cmake/README.md links to it.

Change-Id: I94a6a4ee24ed0114ccb3095d2c13cf5d84e2de72
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-02 09:00:08 +02:00
Joerg Bornemann
062318feb2 CMake: Fix non-prefix build detection when CMAKE_STAGING_PREFIX is set
It wasn't possible to create a cross, non-prefix build with
CMAKE_INSTALL_PREFIX set to something else but the qtbase build dir
and CMAKE_STAGING_PREFIX set to the qtbase build dir.
This would be equivalent to
    configure -prefix /usr \
              -extprefix ~/my/qtbase/build/dir

Fix this by comparing the qtbase build dir against
CMAKE_STAGING_PREFIX if it is set. We also have to adjust the
QT_BUILD_DIR variable in a similar way.

Change-Id: Iaba5cf0f6954ae4b15d8af1fc62634f5d7f68835
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-01 18:09:03 +02:00
Joerg Bornemann
389c772fd4 CMake: Fix qconfig.cpp for cross-builds
This patch modifies the two preprocessor definitions
QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH and
QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH which are exclusively used
by qmake (and not QtCore's QLibraryInfo) to determine the ext prefix
and the host prefix.

In the qmake build of Qt, qmake considers the host prefix as "location
where qmake is installed". This is usually the same as the ext prefix
but can be modified by the user at configure time.

In the CMake build, we don't build tools for the host but always for
the target platform. The QT_HOST_PATH is an external prefix we never
install to. That means, the qmake we build is always installed into
the ext prefix (CMAKE_STAGING_PREFIX or CMAKE_INSTALL_PREFIX).
Therefore, we can calculate the path of <ext_prefix>/bin relative to
<ext_prefix> and use this value for both,
QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH and
QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH.

The "path of <ext_prefix>/bin relative to <ext_prefix>" is equivalent to
just the "path <prefix>/bin relative to <prefix>", meaning we can
safely use <prefix>, which is just CMAKE_INSTALL_PREFIX.

Task-number: QTBUG-84886
Change-Id: Ie1d4628a7049ddfd0d0a56dfe4ee2f2bb4952277
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-01 17:47:58 +02:00
Alexandru Croitor
a046833176 CMake: Enable bitcode when targeting UIKIT aka iOS
Building an iOS app with qmake failed because Qt itself was not built
with bitcode enabled.

Enable building with bitcode.
Make sure qrc resource files and bundled 3rd party libraries also
build with the regular Qt module flags and thus with bitcode enabled.
As a consequence gc_sections has to be disabled for UIKIT platforms.

Task-number: QTBUG-82581
Task-number: QTBUG-84781
Task-number: QTBUG-85240
Change-Id: I15fe668725a139c02f2a32a5db849b46d4ce325c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-07-01 10:03:54 +02:00
Alexandru Croitor
e9200ce4b0 CMake: Use non-sanitized plugin type names in .pri files
This is required for qmake to correctly pick up and use plugins that
have strange characters in the types (slashes for platforms/darwin
type and dashes for wayland plugin types).

This fixes some issues with trying to build an iOS application
using qmake due to the qiosnsphotolibrarysupport plugin.

Task-number: QTBUG-85240
Task-number: QTBUG-84781
Task-number: QTBUG-82581
Change-Id: I94faf2d3dbbdeb22dbd96dfb11c7bff00645b524
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-07-01 10:03:47 +02:00
Alexandru Croitor
3ac50d2f71 CMake: Specify Prefix in target_qt.conf for non-prefix builds
The EffectivePaths section does not inherit the Prefix value from
the Paths section.

Specfiy it explicitly, otherwise the paths reported by qmake -query
for /get variants ended up containing an extra "./bin/" part, which
ended up breaking building iOS apps with qmake.

Amends d7fd684861

Task-number: QTBUG-85240
Task-number: QTBUG-84781
Task-number: QTBUG-82581
Change-Id: I288a6e76a21d779a7e03443777f8a4ce28df9974
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-07-01 10:03:43 +02:00
Alexandru Croitor
868c7016e0 CMake: Use correct framework link flags in scripts and .pri files
target_link_libraries expects a quoted string like
"-framework CoreFoundation" when linking frameworks and not 2
different arguments like "-framework" "CoreFoundation".

Fix that in the FindWrapOpenGL and FindGLESv2 find modules.

Make sure to not quote the framework link flags when generating
.pri files even if there are spaces, otherwise building apps
with qmake fails.

Amends 7fcc9cf055
Amends 2ed63e587e
Amends 55a15a1c1b
Amends 2a767ab4bb

Task-number: QTBUG-85240
Change-Id: I66ba36760ad704d65e712072a528d9e25c336dfa
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-07-01 10:03:38 +02:00
Alexandru Croitor
1685b0540d CMake: Fix top-level .prl file generation
Promotes qt_find_package()'d targets and their transitive dependency
targets to global scope. This will allow .prl file generation to
access targets in a sibling repo scope.

Retrofits qt_collect_libs() to be a bit more general, so it can be
reused both for prl lib collection, and traversing of dependencies
of qt_find_package() provided targets.

Removes the bail out checks for top-level static builds.

Amends 8c8c0f65e3
Amends dde11715d3

Task-number: QTBUG-84874
Fixes: QTBUG-84917
Change-Id: Id95b4cb7a0887c52f35c40bfdb96ad4a68dd6794
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-07-01 10:03:32 +02:00
Alexandru Croitor
e932a898a5 CMake: Adjust some status messages about syncqt and file generation
Show a status message when we run syncqt for a module (gives a bit
more insight into why the configuration seems to stall for a moment).

Remove some uninformative messages about generating config.h files
and Depends headers, etc.

Change-Id: I5ff2774b9cf5d92ddde564dc09f4197c2835ee4a
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-30 13:15:14 +02:00
Alexandru Croitor
f3c7d22dd0 CMake: Don't use libraries in /usr/local by default on macOS
qmake builds of Qt don't use libraries in /usr/local because the
path is not considered a system path. Only the SDK path should be
used as a source of system libraries.

We should do the same for the CMake builds, which involves a couple of
things.

Tell CMake not to consider /usr/local (and a bunch of other
paths) as system prefix paths.

Disable pkg-config usage which by default is not used in qmake
Windows and macOS builds.

If a user wishes to use libraries located in /usr/local on macOS, they
can explicitly enable the behavior via -DFEATURE_pkg_config=ON.

In addition to enabling pkg-config, that will also disable the system
prefix modification described above.

Implementation notes

To disable pkg-config usage, we set an empty path for
PKG_CONFIG_EXECUTABLE, because there is no other good way. The
downside to this is that a lot of warning messages will be printed
that the pkg-config package can not be found.

The pkg-config feature needs to be computed in QtBuildInternals before
qtbase/src/configure.cmake, because it's too late to do it in that
file where a few qt_find_package calls already exist.
The feature value is also saved to QtBuildInternalsExtra, to make sure
that pkg-config is disabled whenever building another repo.

System prefix adjustment is done by removing paths from
CMAKE_SYSTEM_PREFIX_PATH.
Ideally we would remove also /usr as a path, to match what qmake does,
but that breaks find_program() calls for perl, python, etc.

We have to make sure that qt_find_package does not look in
PATH when looking for packages, which is the default behavior, because
PATH on macOS most likely contains /usr/local.

One last curiosity for future generations is that CMake 3.18+ has
merged a change to prioritise SDK locations over regular /usr/lib.

Fixes: QTBUG-85261
Change-Id: I28fe5bae7997507a83b37b4eb1e0188e64062c57
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-06-29 17:34:22 +02:00
Joerg Bornemann
943340222e CMake: Generate qdevice.pri when cross-building
This adds the CMake equivalent to the classical -device-option key=value
configure argument:
-DQT_QMAKE_DEVICE_OPTIONS=key1=value1[;keyN=valueN]
The keys and values get dumped verbatim into qdevice.pri.

This patch also ports the machineTuple configure test. Its result is
written into qdevice.pri as value for the GCC_MACHINE_DUMP variable.

Change-Id: I29f2323fd87639fafaed99ec7446c7ee75504705
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-29 12:47:59 +02:00
Joerg Bornemann
8df4caf554 CMake: Allow to pass a custom target mkspec name
It's now possible to pass -DQT_QMAKE_TARGET_MKSPEC=foo to cmake. If the
value is not passed, then we will guess the mkspec like we did before.

Change-Id: If6e8324654cb8bd83d3cba9eb6ee1e4ad2692a2c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-29 12:47:53 +02:00
Joerg Bornemann
5ccecd3a89 CMake: Write host architecture and ABI to qconfig.pri
...when cross-building Qt.

Change-Id: I7d2fe83167fc278fde9f0c0fd70f5fa42fa62862
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-29 12:47:44 +02:00
Joerg Bornemann
2299b61d0c CMake: Write gcc sysroot flags to qconfig.pri
For a cross-built, gcc-built Qt, the qmake build writes code into
qconfig.pri that adds the --sysroot flag to compiler and linker flags.
Follow suit in the CMake build.

To keep the diff small between the qmake-generated and CMake-generated
qconfig.pri files, the sysroot code is added at the top of
qconfig.pri, which is the reason for the new 'content' string variable.

Change-Id: I50649100e4368be64bf98ca19e46312e3ebf619d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-29 12:47:39 +02:00
Joerg Bornemann
d7fd684861 CMake: Support cross-compilation with qmake
When cross-compiling, we now create a target_qt.conf file that's to be
used with the host Qt's qmake. With "qmake -qtconf .../target_qt.conf"
projects can be cross-built against the cross-built Qt.

We also create wrapper scripts for the host qmake to save the user from
passing the -qtconf argument.

Fixes: QTBUG-82581
Change-Id: Ib5866e7e820369efea9eb3171e3e3e3ca5c0c3c1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-29 12:47:34 +02:00
Joerg Bornemann
1f3af0f35c CMake: Fix double-negation of feature CONFIG values
The plugin-manifests feature has the "negative" CONFIG value
"no_plugin_manifest". On negation, we're supposed to strip off the
leading "no_" instead of adding another one.

Change-Id: Id2c66da41f22881272d5b923f12b85d9fcc2c9d0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-29 12:24:40 +02:00
Alexandru Croitor
375831a3dc CMake: Mark all find_package(PkgConfig) to be quiet
This reduces the amount of warning messages when the pkg-config
feature is disabled.

Task-number: QTBUG-85276
Change-Id: I11a6dfb6273a1e48c47d1ef5c1a5f70ba990fbc0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-06-29 12:23:10 +02:00
Alexandru Croitor
63f09a94db CMake: Transform absolute library paths into link flags in .pri files
Before this change, the qt_lib_foo_private .pri files contained
absolute paths to libraries, e.g.
  /usr/lib/x86_64-linux-gnu/libcups.so

Whereas the qmake build instead embeds link flags like -lcups.

Detect absolute library file paths, and transform them into link
flags. This should make the .pri files relocatable.

Fix the add_custom_commands to have the scripts as dependencies.
Make sure to pass the suffix, prefix and other options to the
qconfig.pri generation command as well.

Also reverse the order of the link flags, to mirror the order
that qmake generates for .pri files.

Task-number: QTBUG-84781
Task-number: QTBUG-85240
Change-Id: I7bc3b234d9c86c785b169b11f3042450aa225c1f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-29 12:23:05 +02:00
Alexandru Croitor
2ed63e587e CMake: WrapOpenGL target should also link AGL on macOS
This is consistent with the qmake mkspec in common/mac.conf

Task-number: QTBUG-85240
Task-number: QTBUG-84781
Change-Id: I99df365a3be541356482d29eda806020f4e298d9
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-06-29 12:23:00 +02:00
Alexandru Croitor
7fcc9cf055 CMake: Create a Find module wrapper for OpenGL
Our .prl files embedded an absolute path to the OpenGL.tbd file. This
obviously breaks their usage when used on another machine when no SDK
exists.

To fix that we need to use a "-framework OpenGL" linker flag instead
of linking against the absolute path library.
To convince CMake to do that, we have to create a wrapping
OpenGL target which sets an appropriate INTERFACE_LINK_LIBRARIES
property.

So create a FindWrapOpenGL find module to do that on darwin platforms.
Adjust helper.py and our build system to use it.

This tangentially amends 38cd18384f
because it recreates the FindWrapOpenGL module, but for a different
purpose.

Task-number: QTBUG-85240
Task-number: QTBUG-84781
Change-Id: I3498c19157ae31db5099e6edfb9d71490187f1d3
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-29 12:22:49 +02:00
Joerg Bornemann
95244af2f9 CMake: Let qt_copy_or_install set the executable bit for PROGRAMS
In a prefix build, this function uses install(PROGRAMS) which correctly
sets the executable bit. In a non-prefix build, we did file(COPY)
without explicitly setting executable permissions.

Now, we're also setting the executable bit for
qt_copy_or_install(PROGRAMS) calls in non-prefix builds.

Change-Id: I283e9aeed2a23016ee196d83d584a7eaaa5edd66
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-28 17:16:29 +02:00
Joerg Bornemann
a4f11fa99d CMake: Create Qt6HostInfo package
This package is supposed to be loaded when cross-building Qt from the
host Qt installation prefix. It provides information about the host Qt
by setting various variables. The information reflects what "qmake
-query" of the host Qt would return.

All provided variable names begin with "QT6_HOST_INFO_".

Change-Id: Id568923a318d6e3b48c450663519a3727f615a8f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-28 17:15:30 +02:00
Alexandru Croitor
b0772b41c2 CMake: Display found information in some of the Find modules
Change-Id: I5d92f2f1a552888361a2939577c2b0177c62b596
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-26 22:14:48 +02:00
Alexandru Croitor
fb5cf5be15 CMake: Fix some incorrectly included FindPkgConfig modules
This gets rid of a few warnings during configuration.

Task-number: QTBUG-85276
Change-Id: I07d2fdfd8d3f81f1d780528ee6350e1a3ded9523
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-26 22:14:43 +02:00
Alexandru Croitor
cf3cef1ef5 CMake: Make more inner find_package calls quiet
Task-number: QTBUG-85276
Change-Id: I8ed84e2f2cdaf90224452a5e5a549791574edc15
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-26 22:14:38 +02:00
Alexandru Croitor
2efd0fbc32 CMake: Add meta-target host_tools to easily build just the tools
A developer could write 'ninja host_tools' to build the qtbase tools
and their dependencies, and then configure another cross-compiling
build dir pointing to the previous host build. This shortens the
workflow for cross-building when working in qtbase.

Change-Id: I69e70d23ce9df8669bcadf326d0586f097e5cb21
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-26 22:14:29 +02:00
Alexandru Croitor
3ef14c8943 CMake: Fix framework handling for .pri files
Rather than embedding the full absolute path to the framework, we
should instead write a -framework Foo flag.

qmake seems to do this by specifying QMAKE_LIBS_FOO in the mkspec.
We'll try to get away with just deriving the name of the framework
from the path, to avoid having to introduce a mkspec equivalent
mapping for CMake.

This doesn't currently handle framework include paths, which qmake
also handled by harcoding QMAKE_INCDIR_FOO in the mkspec, and then
sysrootifying it via mkspecs/common/mac/sdk.prf.
Hopefully that's not really needed, given that -framework flag
should imply include paths as well.

Somewhat partially amends c254254c55

Task-number: QTBUG-85240
Task-number: QTBUG-84781
Change-Id: I70ea5021422d7b1f5afa9c4a595d1a9b8a8217d3
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-26 22:14:24 +02:00
Tor Arne Vestbø
cbd2973a19 cmake: Pick up custom Info.plist in user projects
We can't rely on the MACOS define as that's set by our private
QtPlatformSupport.cmake that's not shipped.

Change-Id: I86c578a282a0833408a06d923954510a3579bdaa
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-26 14:58:42 +02:00
Tor Arne Vestbø
c644dc9700 cmake: Match tense of other log output
Change-Id: Ied164c97bd54f6b37450d7a2cf8225ee5190ce17
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-26 14:41:42 +02:00
Tor Arne Vestbø
6d376ea5f4 cmake: Apply symbol visibility settings to Objective-C/C++ sources
Otherwise the Objective-C++ sources will be built with the default
compiler visibility (visible), and then linked with moc-generated
C++ sources that have the Qt overridden hidden visibility, resulting
in linker warnings such as:

  ld: warning: direct access in function 'X' from file 'moc_foo.cpp.o'
  to global weak symbol 'Y' from file 'bar.mm.o' means the weak symbol
  cannot be overridden at runtime. This was likely caused by different
  translation units being compiled with different visibility setting

Change-Id: I22e15e7e181a74de8c0a22c73d06e600e582d7fd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-25 10:45:34 +02:00
Alexandru Croitor
3cd614644a CMake: Place framework .prl files under Resources
Adapts to qmake's 74abe98320 change

Change-Id: If1d6ce063d53dda4835a224661a16219cf9a9476
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-25 09:07:39 +02:00
Alex Blasche
21b5c7875c Raise the Android SDK build requirement to lvl 28 - compile fix
First of all cmake and qmake used a different standard.

Secondly, the qmake logic enforced lvl 23 (if it was installed which
is the case on the failing machine). When this is combined with
f71a400bf6 which requires lvl 28 API to build, the android build fails to compile.
cmake logic was even worse as it enforced lvl 21 API to be used if installed.

This change requires pick to 5.15 as f71a400bf6 was picked as well.

Pick-to: 5.15
Change-Id: I89a7193b711b8bf927d02907343a49d6f27082ce
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-06-23 16:39:04 +02:00
Alexandru Croitor
878551a146 CMake: Allow specifying custom configure.cmake file for module
This is required for qttools, where the configure.cmake file lives in
the top-level source dir, but the module is in src/global.

The new CONFIGURE_FILE_PATH option allows specifying a different
location for the configure.cmake instead of the default value.

Change-Id: I260d7c93dd49337ebe07ae4cc871394da9e9c2c6
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-23 14:11:53 +02:00
Alexandru Croitor
d7efb2a419 CMake: Fix include paths for AUTOMOC when using frameworks
The qml app was crashing when used by qtdeclarative auto tests. It
complained about unregistered QML types. qmltyperegistrar didn't
create registration info for these types. moc didn't output class info
about these types because the build system didn't provide the proper
include paths.

In qmake land, moc was given 2 sets of paths when building a module:
the non-installed framework dirs as -F flags, and also the
$repo_build_dir/include paths as regular -I flags.

In CMake land we only gave include paths to the non-installed
framework dirs as -I flags, not -F flags.
That's because AUTOMOC checks for a specific pattern in the include
paths to transform them into framework include paths
(existence of Foo.Framework/Headers symlink),
and we didn't pass such an include path.

Make sure to mimic what qmake does, and pass -I flags to
$repo_build_dir/include as public include paths, but only via
BUILD_INTERFACE aka when building Qt itself.

Also pass -F flags by specifying framework include paths in the
pattern that AUTOMOC expects.

Fixes the following qtdeclarative tests
 tst_qdebugmessageservice
 tst_qqmlinspector
 tst_qqmlenginedebuginspectorintegration
 tst_qqmlpreview

Task-number: QTBUG-84886
Change-Id: Iab9693d9889bf6d2c40fed067ab9b9da8683a053
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-23 14:01:11 +02:00
Karsten Heimrich
18ec53156e Move QTextCodec support out of QtCore
* Assume UTF-8 on all Unix like systems
* Export some functions to be able to compile QTextCodec once
  moved to Qt5Compat.

Task-number: QTBUG-75665
Change-Id: I52ec47a848bc0ba72e9c7689668b1bcc5d736c29
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-20 02:04:38 +02:00
Joerg Bornemann
7f2ff4ffce CMake: Do not file(GENERATE) illegal genexes in .pri file generation
We must filter out expressions of the form $<TARGET_PROPERTY:name>, because
1. They cannot be used in file(GENERATE) content.
2. They refer to the consuming target we have no access to here.

The CMake error
  Error evaluating generator expression:

    $<TARGET_PROPERTY:QT_PLUGIN_CLASS_NAME>
was triggered when building the UiPlugin module of qttools.

Change-Id: Idf639be50120b94d68a70965604e6f1ef72edc9b
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-19 18:41:23 +02:00
Alexandru Croitor
e2b2cd9397 CMake: Improve automatic compiler embedding into the Qt toolchain
Embedding the initial CMAKE_CXX_COMPILER into qt.toolchain.cmake
breaks Boot2Qt builds, because the CXX environment variable is not
used anymore when building qtsvg or other projects.

Disable automatic embedding when cross-compiling, while keeping it
enabled for non-cross-compiling cases (to keep Windows and
and ICC configurations working).

Allow opting in or out of the embedding in case if the default is
wrong, via QT_EMBED_TOOLCHAIN_COMPILER.

Task-number: QTBUG-85067
Change-Id: I1d8f9f580bc379b77c34eefb5728bb49f93cc81a
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-18 19:13:11 +02:00
Alexandru Croitor
87c4812b6c CMake: Query public target defines when generating module .pri files
Assuage the fears in the previous commit, by actually querying and
using the public defines set on a target, rather than hardcoding one
single QT_FOO_LIB define + the extra namespace define.

This should future-proof .pri file generation for qmake mixing.

Amends 3452b08df6

Task-number: QTBUG-84781
Task-number: QTBUG-84881
Change-Id: Ide68ecf3f89be6d5462cfe43706c27f9cb53394f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-18 12:58:02 +02:00
Alexandru Croitor
ed20023760 CMake: Fix namespace builds for qmake mixing
While we recorded the namespace define in the CMake generated Targets
file, we also have to record it in qt_lib_core.pri, so that qmake
knows to use the define when building other modules / apps.

It does scare me what other MODULE_DEFINES we might be missing, and
that we should perhaps put all public modules defines into the
generated module .pri files.

Amends 3452b08df6

Task-number: QTBUG-84781
Task-number: QTBUG-84881
Change-Id: I3175aa9991a06a4541eb0dd153ba2e6e58c019ce
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-18 12:58:00 +02:00
Alexandru Croitor
976fa5134a CMake: Use intelcet flags for bootstrap and qmake
This should fix build failures on Ubuntu 20.04.

Amends fa98adbd04

Change-Id: Iff399faff0cf06f5b88d756b1f632b8798069578
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-18 11:51:41 +02:00
Alexandru Croitor
8b701f9bd9 CMake: Don't use a lib prefix for MinGW prl files
This is to be consistent with qmake.

Change-Id: I17b8a3e4649d035d1d871e4f124952cded7f6664
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-18 11:51:41 +02:00
Alexandru Croitor
06557312d2 CMake: Improve .prl dependency tracking
Previously .prl files were created via add_custom_command with a
POST_BUILD command. This means they were only created after linking
the libraries, and that whenever a relinking happened, dependees had
to rebuild many parts of their target.

Ideally we would use generator expressions in the OUTPUT argument, but
versions up-to CMake 3.18 don't support doing that.

A workaround is to create and depend on a .prl file name without
generator expressions, and as a side effect also create a .prl file
that does use generator expressions, but don't specify it as an
OUTPUT.

This seems to work well, and improves the dependency tracking issue,
at the cost of one more file copy per .prl file whenever it changes.

Change-Id: I7dd99777fec5a08552503bdbafb6116f93ebe66b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-18 11:51:41 +02:00
Joerg Bornemann
3b75024a94 CMake: Simplify the qt_path_join function
Use ARGN that already has the out_var parameter removed.

Change-Id: I79438caa4333a11493456fa219448ad500518880
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-17 18:05:46 +02:00
Joerg Bornemann
d2a04cf165 CMake: Fix .prl generation and installation for plugins
The referenced Qt libraries had paths to the build directory, instead
of the $$[QT_INSTALL_LIBS]/ prefix. The reason was two-fold:

1. QT_BUILD_LIBDIR had the wrong value, namely
"${QT_BUILD_DIR}/platforms/qfoo".

2. The QtFinishPrlFile.cmake script was called with a wrong OUT_FILE
parameter, placing the final .prl file in the build lib dir.

As drive-by change, surround arguments for QtFinishPrlFile.cmake that
can contain spaces with double quotes.
This amends 8c8c0f65e3.

Task-number: QTBUG-84781
Change-Id: I7188b799716576b3296ee7b2d460489867b9967a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-17 15:13:44 +02:00
Alexandru Croitor
e67829e655 CMake: Fix MinGW prefixes / suffixes again
Document what qmake expects and what CMake creates by default.
This change should fix qmake mixing for MinGW, where the WinMain
library was called qtmain.a instead of libqtmain.a.

Amends f626c73b28
and 9b0e23ef8a

Task-number: QTBUG-84781
Change-Id: I059db13f8d8a0aab8bd3fc69d4537a2b63687394
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-17 15:13:44 +02:00
Alexandru Croitor
9862cb4532 CMake: Write QT_MAC_SDK_VERSION into qconfig.pri
Task-number: QTBUG-84781
Change-Id: I9f4e979a7404dd45286e0a85a6f3772e53a2fd0b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-17 15:13:44 +02:00
Alexandru Croitor
435fe4b13d CMake: Add additional info which was missing in qconfig.pri
Mostly compiler version numbers.

Task-number: QTBUG-84781
Change-Id: I10e92fdfd4e603c9b763a51a0e09b6c4a2c75ac7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-17 15:13:43 +02:00
Alexandru Croitor
3452b08df6 CMake: Record info about namespaced build for qmake
To make sure qmake generates appropriate rules when building other
applications.

Task-number: QTBUG-84781
Change-Id: I75618575602be820bf20a8067e3a6ee3ff7e7950
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-17 15:13:43 +02:00
Alexandru Croitor
17d8b54cbc CMake: Fix usage of qt_process_qlalr when cross compiling
qtremoteobjects has a tool that uses qt_process_qlalr. The function
doesn't have a check to see if the consuming target is an imported
target, to skip doing any work when corss compiling.

Fix it, like we do in qt_extend_target.

Change-Id: Ide389a371aa07225f08689d15125c04d8b0e3916
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-17 15:13:43 +02:00
Joerg Bornemann
4ab5432081 CMake: Write object libs of Qt resources to .prl files
Since commit e343affd63 we're creating object libraries for Qt
resources in static libraries. Those must be reflected in the
generated .prl files for static builds of Qt.

In qt_add_resource, we now calculate the install locations of the
object files of rcc-generated C++ files and save them in the target
property QT_RCC_OBJECTS. This property is then passed to
QtFinishPrlFile to write the object file paths to the .prl file.

Change-Id: Ic383892d723d02fc91f712bc2dbcbc90babad074
Reviewed-by: Simon Hausmann <hausmann@gmail.com>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-16 17:56:35 +02:00
Joerg Bornemann
bd2a14ff98 CMake: Do not use $$[QT_INSTALL_LIBS/get] in generated .prl files
We do not support building with qmake from the build directory in prefix
builds. Therefore we can just use the standard QT_INSTALL_LIBS property
instead of the /get variant.

Change-Id: I82ccaf1894fb1dccc9ec18b4984b582b555ce0f8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-16 17:56:21 +02:00