Commit Graph

92 Commits

Author SHA1 Message Date
Alexandru Croitor
eaa29378b9 CMake: Fix c++ standard config tests with MSVC
Need to pass additional -Zc:__cplusplus flag when using
MSVC, so that the __cplusplus define has correct values.

Additionally make the option be propagated to consumers of Qt
via the public Platform target, which QtCore links against.

Change-Id: Ie1283c25334b93f993529beb7fb32bdb001627f5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-02-18 14:44:57 +01:00
Alexandru Croitor
461020a86a Export non-private and non-public features and CONFIG values
Before we only exported features that had outputType PUBLIC or PRIVATE
on the various "QT_ENABLED_PUBLIC_FEATURES" target properties.

Now we also export features that have output type privateConfig,
publicConfig and publicQtConfig.

The new properties names are:
- QT_QMAKE_PUBLIC_CONFIG    for outputType == publicConfig
- QT_QMAKE_PRIVATE_CONFIG   for outputType == privateConfig
- QT_QMAKE_PUBLIC_QT_CONFIG for outputType == publicQtConfig

These need to be exported for 2 reasons:
- other modules that need to check the config values
- in preparation for generating proper qmake .prl and .pri
  information for each module

Note that the config values are now considered actual features
when doing condition evaluation. So if there exists a feature "ssse3"
with outputType privateConfig, its enabled state can be checked via
QT_FEATURE_ssse3 in consuming modules (but not in the declaring
module).

These config values are also placed in the respective
QT_ENABLED_PUBLIC_FEATURES, QT_ENABLED_PRIVATE_FEATURES properties
when exporting a target, so the properties will now contain both
features and config values.

In order to make this work, feature name normalization has to happen
at CMake time, rather than done by the python script.

This means that features like "developer-build" need to retain the
dash in the qt_feature(), qt_feature_definition() and
qt_feature_config() calls, rather than generating "developer_build"
as the script did before.

The normalization is done at CMake time. Feature conditions,
CMake code, and -DFEATURE_foo=bar options passed on the command line
should still use the underscore version, but the original name is used
for the QT_QMAKE_PUBLIC_CONFIG properties.

Note that "c++11" like features are normalized to "cxx11".

Implementation wise, the configurejson2cmake script is adjusted to
parse these new output types.

Also QtBuild and QtFeature are adjusted to save the config values
in properties, and re-export them from GlobalConfig to Core.

Task-number: QTBUG-75666
Task-number: QTBUG-78178
Change-Id: Ibd4b152e372bdf2d09ed117644f2f2ac53ec5e75
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-03 13:37:56 +00:00
Alexandru Croitor
55a15a1c1b Add initial support for cross-building to iOS
Tested locally with the following configurations:
- iOS device builds (arm64)
- iOS simulator builds (x86_64)
- iOS simulator_and_device builds (fat arm64 and x86_64 archives)

All iOS builds currently require a custom vcpkg fork which contains
fixes for building the required 3rd party libraries.

qtsvg, qtdeclarative, qtgraphicaleffects and qtquickcontrols2
have also been tested to build successfully.

simulator_and_device builds are also supported, but require an umerged
patch in upstream CMake as well as further patches to vcpkg.

Task-number: QTBUG-75576
Change-Id: Icd29913fbbd52a60e07ea5253fd9c7af7f8ce44c
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2019-12-03 13:35:59 +00:00
Alexandru Croitor
c800a62403 Cache qt_config_compile_test results
Inside qt_config_compile_test we use two different calls:
check_cxx_source_compiles when given code, and try_compile when
given a project.

The former caches its results, while the latter does not, which means
that the try_compile calls are re-executed on each reconfigure.

Do what check_cxx_source_compiles does internally, and don't rerun
the try_compile calls if the results were computed once.

Change-Id: I2691ff08b7bb46c3fa60bbf5ed6278731c9b8e21
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-02 12:27:33 +00:00
Jean-Michaël Celerier
1962a86b20 Fix an incorrect regex range
Change-Id: I1b8b72cb4adcd872a3e4c245e58d4e302bf00c86
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-22 12:55:10 +00:00
Simon Hausmann
2fa23e46c0 Fix C++ standard detection
We cannot use a generator expression in an if statement, it does not
work. Instead, we could inspect the CMAKE_C/CXX_COMPILE_FEATURES list,
but unfortunately that's not reliable. For example it detects that ICPC
supports C++17 when in fact that depends on the installed libstdc++.
Therefore this patch revives our own configure tests.

Change-Id: Ic3bc5762fbe81837722523e3881ac16e84628519
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-17 16:57:25 +00:00
Joerg Bornemann
992fe06b30 cmake: Support CMake-typical booly values for -DFEATURE_*
Allow setting feature defines to ON, YES, TRUE, Y, OFF, NO, FALSE, N and
non-negative numbers like it's possible for other defines.

We'll not allow IGNORE and NOTFOUND, because they're a bit strange in
the context of features.

Change-Id: I7f6cd6dff4c68972921b499b28916c9ad789d510
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-26 14:30:14 +00:00
Alexandru Croitor
6470c3e770 Print status messages when doing out-of-line config.tests
As well as SIMD tests.

Change-Id: I43318418f90a6b9736eb89f008459c7d6adac8f9
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-24 09:56:59 +00:00
Alexandru Croitor
f35cc5090a configurejson2cmake: handle out-of-line config tests
Generate appropriate qt_config_compile_test() calls for config tests
that have CMake projects. These are protected by an if(EXISTS) check
so that configuration doesn't fail for repos where the config tests
have not been ported yet.

Adjust the qt_config_compile_test() function to use try_compile for
projects specified via new PROJECT_PATH argument.

Change-Id: I83c061e384f68688a654b782fd7a9bede282d1e3
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-22 10:27:22 +00:00
Alexandru Croitor
c40cc543d0 Display message when trying out SIMD tests
This clarifies the weird pause when configuring, right after
the HAVE_reduce_relocations test.

Change-Id: I0edcbbd085286c20c4eaea8d8e15a509ec93d85f
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-19 21:43:01 +00:00
Alexandru Croitor
2401435d89 Map module.gui to if TARGET Qt::Gui in configure.cmake
Some features check for module / target existence. Adapt conversion
script to handle that.

Reland after fixing it.

Change-Id: If4fb942c2e0d16e76a0b9b767bf478527851b0f7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-06-05 09:15:04 +00:00
Jean-Michaël Celerier
fecd9d90da Fix static usage requirements for XcbQpa
In particular, Qt targets extended with other qt targets
(eg. Qt::VulkanSupport or Qt::LinuxAccessibilitySupport)
after the first add_qt_module were not taken into account when generating
Depends files.

Note that this patch updates the minimum required version
to CMake 3.15

Change-Id: I747deedd4d59e385876bc1a834ef9bdb6078911b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-06-05 08:53:34 +00:00
Alexandru Croitor
38b7ee3533 Revert "Map module.gui to if TARGET Qt::Gui in configure.cmake"
It breaks some conditions, and then the build fails not finding
some private header files in qpa, etc.

This reverts commit 35dc8f496d.

Change-Id: I1b51eac06fe9186181d3f0a7c78f22da7be534e2
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-06-05 08:33:21 +00:00
Alexandru Croitor
35dc8f496d Map module.gui to if TARGET Qt::Gui in configure.cmake
Some features check for module existence. Adapt conversion script
and QtBuild feature condition parser to handle that.

Change-Id: I063e49a6fe9f8e9cf3aec985fd78ed4430398586
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-06-05 08:13:42 +00:00
Jean-Michaël Celerier
0900298d46 cmake: register plug-ins, create dependencies file
This commit introduces infrastructure work to allow static builds of Qt
to handle importing of plug-ins.

Change-Id: Ife0ca3ca7276ea8ec96fe0eb6adf934fad7620ec
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-06-04 10:08:07 +00:00
Alexandru Croitor
85b038a0a2 Copy feature properties from GlobalConfig to Core target
Current lates CMake has a limitation that it does not allow exporting
custom properties from INTERFACE libraries. GlobalConfig is such a
library, which means that so far all the global features were not
actually exported.

Copy the feature property values from GlobalConfig to Core. Because
Core is an actual shared library, it keeps the custom properties
when exported, and thus Core feature properties will contain the sum
of Core and GlobalConfig feature values.

Change-Id: Idde305cbaf9ab85ecfbe29522dcbac1c44022b17
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-17 11:10:31 +00:00
Alexandru Croitor
9fade925e3 Stop trying to create config forwarding headers for NO_MODULE targets
The GlobalConfig target is not an actual module, so there's no point
in trying to create forwarding headers for GlobalConfig's qconfig.h
within qt_feature_module_end.

qconfig.h's forwarding header will be created implicitly while
processing QtCore target's SYNCQT.INJECTIONS value, which is read
from the headers.pri file generated by syncqt.

This also fixes trying to create forwarding headers when processing
the sqldrivers project.

Amends 02a015375a.

Change-Id: Ifd70d8c3ebf881ffdcf90db8d5d3b23309bc8fed
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-16 09:04:00 +00:00
Alexandru Croitor
02a015375a Implement developer / non-prefix builds
A non-prefix build is a build where you don't have to run
make install.

To do a non-prefix build, pass -DFEATURE_developer_build=ON when
invoking CMake on qtbase. Note that this of course also enables
developer build features (private tests, etc).

When doing a non-prefix build, the CMAKE_INSTALL_PREFIX cache variable
will point to the qtbase build directory.

Tests can be run without installing Qt (QPA plugins are picked up from
the build dir).

This patch stops installation of any files by forcing the
make "install" target be a no-op.

When invoking cmake on the qtsvg module (or any other module),
the CMAKE_INSTALL_PREFIX variable should be set to the qtbase build
directory.

The developer-build feature is propagated via the QtCore Config file,
so that when building other modules, you don't have to specify it
on the command line again.

As a result of the change, all libraries, plugins, tools, include dirs,
CMake Config files, CMake Targets files, Macro files, etc,
will be placed in the qtbase build directory, mimicking the file layout
of an installed Qt file layout.

Only examples and tests are kept in the separate module build
directories, which is equivalent to how qmake does it.

The following global variables contain paths for the
appropriate prefix or non prefix builds:
QT_BUILD_DIR, QT_INSTALL_DIR, QT_CONFIG_BUILD_DIR,
QT_CONFIG_INSTALL_DIR. These should be used by developers
when deciding where files should be placed.

All usages of install() are replaced by qt_install(), which has some
additional logic on how to handle associationg of CMake targets to
export names.

When installing files, some consideration should be taken if
qt_copy_or_install() needs to be used instead of qt_install(),
which takes care of copying files from the source dir to the build dir
when doing non-prefix builds.

Tested with qtbase and qtsvg, developer builds, non-developer builds
and static developer builds on Windows, Linux and macOS.

Task-number: QTBUG-75581
Change-Id: I0ed27fb6467662dd24fb23aee6b95dd2c9c4061f
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-15 11:31:31 +00:00
Alexandru Croitor
a9c379199d Fix internal features to also be evaluated
This amends 4f1a155909 and
37b154858f which caused the regeneration
of some json features to be internal. Some of those features were
not evaluated any more unless they were referenced in another feature.

Make sure to explicitly evaluate all internal features as well.

Change-Id: I4367f309585fe29dc89d8a6b793de381956ae51d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-03-21 10:29:38 +00:00
Alexandru Croitor
e5b2699750 Do define generation after feature evaluation
Instead of generating defines guarded by feature ifdefs,
record the define information (condition, name, value, etc),
and generate the final define statement only if the feature
condition evaluated to true.

This removes the need to generate feature defines
(QT_FEATURE_foo) for features that have neither public nor
private outputs in the configure.json file.

Also note that all qt_feature_definition() calls
(which correspond to type:"define" outputs in json files)
now generate defines only in the public header, which seems
to be consistent with how qmake evaluates json files.

Change-Id: I5210b405d5735dd9df5f7a55d1ea9547bb7b1159
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-03-18 15:34:13 +00:00
Tobias Hunger
64147fcb33 CMake: Add QT_CFLAGS_* when building x86simd tests
Change-Id: I5caa088d517cb9d3749c3ed8ef88a41552c1d340
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-03-18 12:33:44 +00:00
Alexandru Croitor
6ca047aba9 Use qt_evaluate_config_expression for feature enable conditions
Certain features like opengles2 can be enabled or disabled based
on the conditions that are specified in the ENABLE and DISABLE
parameters.
Because some of those conditions use STREQUAL with
a single quoted argument, we have to use
qt_evaluate_config_expression to circumvent the CMake bug
regarding single quotes, which is described in the function
implementation.
Only then will enabling / disabling work correctly.

Change-Id: I3b68ef611c985f0d8416fd089055fd862da1e542
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-03-14 13:56:30 +00:00
Albert Astals Cid
9bef044a0b cmake: Search and enable the sqlite[3] plugin
Added to QtFeature.cmake a way to be able to run feature_module begin
and end without having an actual module by passing NO_MODULE

Change-Id: Ib708bd3878e2591da193d18563c8932cc4b75e7f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-02-12 14:02:22 +00:00
Simon Hausmann
f1b688bc7c Fix qt_config_compile_test when cross-compiling
When we do

    qt_config_compile_test(egl_x11
        LABEL "EGL on X11"
        LIBRARIES X11::X11
        ...
    )

then check_cxx_source_compiles() aborts if the provided targets do not
exist (we map LIBRARIES to CMAKE_REQUIRED_LIBRARIES). However we just
want the test to fail. Therefore this patch verifies the presence of the
targets.

Change-Id: Ibd7c1b50d585339af0ca0de58bc5c9cd64d65d6d
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
2019-02-12 14:01:26 +00:00
Kevin Funk
4bfd6c010b cmake: Create Qt5 compat targets in config files
For now create targets a la "Qt5::Core" to stay compatible with the
current Qt5 naming scheme. The name is controllable via a CMake option.

Change-Id: If43c058221949b1900c2093f39ccc9d0f38028f1
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-02-12 11:09:03 +00:00
Kevin Funk
2635ab01d2 cmake: QtFeature: Do not error out when using Qt
... outside of qtbase.git

Change-Id: I1895ef07c881766e2b28839d0422916b6916e10e
Reviewed-by: Jean-Michaël Celerier <jean-michael.celerier@kdab.com>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-02-11 17:14:01 +00:00
Kevin Funk
99e14037e2 cmake: QtFeature add debugging aid
Persist the target name in the CMake cache description

Change-Id: I124a8b89e5845d12301993b0546c8d5c91b8d8bb
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-02-11 10:53:50 +00:00
Kevin Funk
04ff8b5b6a cmake: Do not rerun try_compile invocations
Change-Id: I5eccf9f810d7ee55a311884bd5cf483f8086bae6
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-02-11 10:53:41 +00:00
Albert Astals Cid
2ce3f440f9 Allow passing libraries to qt_config_compile_test
Fixes cxx11_future and ipc_posix tests

Change-Id: I0f3a7b1a0452724c07198a87c2fc25344e7451eb
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-02-11 09:26:08 +00:00
Tobias Hunger
6a1ee4de07 CMake: Store Qt features in CMake Cache
This is less self-contained than what we have, but significantly speeds
up cmake configure/generate runs.

This patch also warns when a feature is already defined.

Change-Id: I8cab63e208ba98756b47d362a39b462f5ec55e20
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-17 16:16:55 +00:00
Tobias Hunger
3ec578020c CMake: QtFeature optimization
Remove some unnecessary sorting, speeding up cmake by about 10s on my machine

Change-Id: Ieafbd16f6dd8cfe6d1af3c739bfe58e8bf724441
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-17 08:34:02 +00:00
Tobias Hunger
235769d56b CMake: Error out on mis-use of qt_pull_features_into_current_scope
Make it a bit harder to mis-use qt_pull_features_into_current_scope.

Change-Id: I2a6be28d7c0e6207217cb1908ec22cc757acd01a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-17 08:33:50 +00:00
Tobias Hunger
4f26758978 CMake: Introduce Qt::GlobalConfig to hold the global features
This simplifies the handling of features a bit as it removes the special
code to store two sets of features in Qt::Core.

Change-Id: I536d41cfc76a02af054e3cfbad6bda50b1e9e49a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-17 08:33:27 +00:00
Tobias Hunger
b705021b4e CMake: Check for visibility once
Change-Id: I5c729f4509eed16409df5eb048afb7f60c5ca57c
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-01-16 11:07:23 +00:00
Tobias Hunger
ff693d664b CMake: Remove one unnecessary feature push into parent scope
During qt_feature_begin_module no features are changed, so there is
no need to push features.

Change-Id: Id7ebcfad373caa284e790b7eb0a178eaa72216e5
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-01-14 12:27:44 +00:00
Tobias Hunger
07dfa3013c CMake: Get rid of useless underscores in QtFeature.cmake
Change-Id: I87eb55ed2ce01ab136dac3e2a587b43bd3f8a98e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-12-14 14:00:32 +00:00
Tobias Hunger
fac800ad1c CMake: Fix cmake test for features
Features are now always defined (to OFF) when they are not emitted.

Adapt the test for that.

Change-Id: Id5f662f07fea15c22027b9b00d1b53a288b4a0dc
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2018-11-22 08:39:15 +00:00
Tobias Hunger
b7b4af575f CMake: Simplify Feature handling
Simplify the scope handling of features by providing a function that
just pushes all QT_FEATURES into the parent scope. Use it.

Change-Id: Ic6552fe495394d73fcec6becf6852745ec2d6d59
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-11-05 15:01:58 +00:00
Tobias Hunger
3b74e0cc0b QtFeature: (Re-)evaluate QT_FEATURES based on cached values
(Re-)evaluate QT_FEATURE_* based on the corresponding cache values
named FEATURE_*.

Change-Id: I57e76af90221937e45979a6d0c366923983ca7d5
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-11-05 14:55:04 +00:00
Tobias Hunger
86098596ca QtFeature: Prefix temporary values with _
This gets makes it easier to see the QT_FEATURE_foo variables;-)

Change-Id: Ide9354d90eecdb15d6d5cec7c2bfb9cee348fb29
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-11-05 14:54:56 +00:00
Tobias Hunger
ec510d0ebc Store QT_FEATUREs that are not emitted
Store QT_FEATUREs that are not emitted, but do not show them in the UI. Also separate
out the UI (FEATURE_foo) from the internal CMake value (QT_FEATURE_foo). This does
break the overriding of settings, but that did not work well before either. This
will be fixed in follow-up patches.

Remove fallout: xkbcommon_system was now evaluated where it was not before. Remove
it as that is always the case now.

Change-Id: I2d303827a1cc9afeef93ad73285a2043ddaa9766
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-11-05 14:54:48 +00:00
Simon Hausmann
e9c45bbddd Begin port of qtbase to CMake
Done-by: Alexandru Croitor <alexandru.croitor@qt.io>
Done-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Done-by: Kevin Funk <kevin.funk@kdab.com>
Done-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
Done-by: Simon Hausmann <simon.hausmann@qt.io>
Done-by: Tobias Hunger <tobias.hunger@qt.io>
Done-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Done-by: Volker Krause <volker.krause@kdab.com>
Change-Id: Ida4f8bd190f9a4849a1af7b5b7981337a5df5310
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
2018-11-01 11:48:46 +00:00