Commit Graph

13 Commits

Author SHA1 Message Date
Alexandru Croitor
5533eeeb01 CMake: Refactor parts of qt_internal_walk_libs
Refactor the function in preparation of processing rcc object files.

Introduce 2 new functions to get and set values in the memoization
dictionary used by qt_internal_walk_libs.

Modify qt_internal_add_target_aliases to assign the alias names it
creates as properties on the target.

Extract these aliases when available to assign memoized values not
only for the initial library name, but also for its aliases.

When recursively calling qt_internal_walk_libs, make sure to provide a
unique out_var name based on the outer target name, and not just
lib_libs. Otherwise the out_var values would be polluted from
previous recursion runs.

Make sure to check for -NOTFOUND in if() checks so that we reuse
memoized values that are the empty string.

Change-Id: I8fd8e2b0ae14d0ba8f502bc5a764d6e01095001a
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-11-19 06:28:41 +01:00
Li Xinwei
215400e153 CMake: Install pdb files to proper directories in multi-config build
In multi-config build, for different configs, the pdb files of EXEs
should have different installation directories.

For example, when CMAKE_CONFIGURATION_TYPES=RelWithDebInfo;Debug,
<build_dir>/bin/moc.pdb will be installed to <install_dir>/bin/moc.pdb.
<build_dir>/bin/Debug/moc.pdb should be installed to
<install_dir>/bin/Debug/moc.pdb, not <install_dir>/bin/moc.pdb.

Fixes: QTBUG-88268
Change-Id: Idc7c92ca8d44bb81d990656af2b309306a4f5c6b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-14 01:05:08 +08:00
Joerg Bornemann
80a2878e20 CMake: Fix additional target info files
...for QT_BUILD_TOOLS_WHEN_CROSSCOMPILING.

qt_internal_export_additional_targets_file now gets two lists of target
names when run from qt_export_tools:
 - TARGETS containing actually existing targets, and
 - TARGET_EXPORT_NAMES containing the target names as they appear in the
   additional target info file.

Operations that require actual targets are run on the TARGETS, in the
additional target info file only TARGET_EXPORT_NAMES are written.

This distinction is required for the case where the host Qt lacks a
tool that is built in the target Qt.

Example: host Qt is built with DEVELOPER_BUILD=OFF, target Qt is built
with DEVELOPER_BUILD=ON. Then the host Qt lacks qmljs, but it is built
in the target Qt. TARGETS contains qmljs_native, and
TARGET_EXPORT_NAMES contains qmljs.

Fixes: QTBUG-87693
Change-Id: I615aed996bfcbe654274defcda8c1cb2cc4b7b4e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-10-20 20:59:21 +02:00
Alexandru Croitor
e6fd92816d CMake: Install PDB debug info for MSVC builds
Supports installing linker generated debug info for shared libraries
and executables, as well as compiler generated debug info for static
libraries.

Works with Ninja Multi-Config as well, with the caveat that the files
are installed optionally, aka the install rule will not error out if
a pdb file is not present. This is necessary, because it's not
possible to create per-config install rules properly.

Fixes: QTBUG-87006
Change-Id: I95e91a6557eb0ee0f882103be54cd38795c349f7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-06 10:07:02 +02:00
Joerg Bornemann
c09df7b57c CMake: Implement configure -reduce-exports
This option maps to FEATURE_reduce_exports. The feature is on by
default, except for MSVC. The reduce_exports configure test is not used
in the CMake build.

The <LANG>_VISIBILITY_PRESET and VISIBILITY_INLINES_HIDDEN target
properties are now explicitly initialized in the
qt_set_common_target_properties function, because we don't have access
to the feature in QtSetup.cmake where the CMAKE_<LANG>_VISIBILITY_PRESET
variables were set before.

Task-number: QTBUG-85373
Change-Id: I378453f0e0665731970016170302871e20ceb4e2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-05 10:05:20 +02:00
Joerg Bornemann
3d54f47cea CMake: Generate *AdditionalTargetInfo.cmake for tools
This ensures that we have the configuration-independent IMPORTED_*
properties set on tools.

Fixes: QTBUG-86893
Change-Id: I2b772c21341e6e4631379d4a5a99580ec96909ed
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-28 17:29:38 +02:00
Joerg Bornemann
347d2163b2 CMake: Write proper *AdditionalTargetInfo file in debug-only build
To provide the IMPORTED_LOCATION target property we must write
the *AdditionalTargetInfo.cmake file for all debug-only builds, not only
the ones containing a release configuration.

Task-number: QTBUG-86893
Change-Id: I9ecd01483660f434a3f1ea12fa2af756cdcf9932
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-28 17:29:35 +02:00
Joerg Bornemann
893ee16352 CMake: Fix build of Release user projects against RelWithDebInfo Qt
Building a user project in Release configuration against a Qt built with
CMAKE_CONFIGURATION_TYPES=RelWithDebInfo;Debug led to the user project
being linked against the Debug Qt libraries. This is especially painful
with MSVC where debug and release runtimes are incompatible.

We now create *AdditionalTargetInfo.cmake files along the
exported *Targets.cmake files that set the IMPORT_*_<CONFIG> properties
to the values of the release config Qt was built with.

User projects built with an unknown
configuration (CMAKE_BUILD_TYPE=ArbitraryName) will link against a
release Qt. This can be controlled by setting the variable
QT_DEFAULT_IMPORT_CONFIGURATION to, for example, DEBUG in the user
project.

Fixes: QTBUG-86743
Change-Id: I12c4b065a9845c7317f6acddab46b649f2732c9e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-25 17:02:52 +02:00
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
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
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
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