Commit Graph

646 Commits

Author SHA1 Message Date
Alexandru Croitor
729a73a9cf CMake: Remove old 3rdparty mechanism for double conversion
Change-Id: I2b20d4d9d95a1f7f59bc506046a1ebc20eb305f7
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-10 07:33:07 +01:00
Alexandru Croitor
b04d087bd0 CMake: Handle path components like INSTALL_LIBDIR more correctly
We recomputed INSTALL_LIBDIR for every new repo that is configured,
which is incorrect due losing any custom provided libdir when
configuring qtbase.

Save that information (and all other path components) in
QtBuildInternalsConfigExtra.cmake.
Make sure not to-recompute that information when configuring a project
other than QtBase.

Allow providing absolute paths instead of relative paths for these
variables.

Note that only absolute paths pointing somewhere under
the prefix will currently work, otherwise configuraion will fail. If
we need to support such a use case, we'll have to carefully check all
code that use these path components to make sure they handle absolute
paths correctly (current assumption is relative paths everywhere).

Use the computed paths when generating the qconfig.cpp file which is
used for qmake -query.

Task-number: QTBUG-81289
Change-Id: I331aa00e47988fe0ee4e533b5f95c4df11c4d96f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-03-10 02:16:00 +01:00
Alexandru Croitor
b9a9ff99c7 CMake: Update cmake/README with newer information
Change-Id: Ia0e723bb24b8a60dc02d2d218f5a2b5dc2b24017
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-03-09 23:09:24 +01:00
Alexandru Croitor
95e1469eb8 CMake: Port most of the configure summary support
Teaches configurejson2cmake about summaries / reports, so things
like enabled features, configure sections, notes, etc.

Add relevant CMake API for adding summary sections and entries,
as well as configure reports. The commands record the passed data,
and the data is later evaluated when the summary needs to be printed.
This is needed, to ensure that all features are evaluated by the
time the summary is printed.

Some report and summary entries are not generated if they mention a
feature that is explicitly exclduded by configurejson2cmake's feature
mapping dictionary. This is to prevent CMake from failing at configure
time when trying to evaluate an unknown feature. We should re-enable
these in the future.

A few custom report types are skipped by configurejson2cmake (like
values of qmake CONFIG or buildParts).
These will have to be addressed a case-by-case basis if still needed.

Change-Id: I95d74ce34734d347681905f15a781f64b5bd5edc
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-03-09 23:08:57 +01:00
Alexandru Croitor
627351f561 CMake: Set minimum deployment target for darwin platforms
Same value as QMAKE_IOS_DEPLOYMENT_TARGET in
mkspecs/macx-ios-clang/qmake.conf, etc.

Change-Id: I1f6a07d73c2126d0286e8d26f7e61a690607c8ce
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-03-06 17:12:40 +01:00
Joerg Bornemann
d0911d0a92 CMake: Port the 'separate_debug_info' feature
For this, we have to uninline the separate_debug_info configure test,
because supporting the conversion of this in configurejson2cmake is not
worth the hassle.

Separate debug information can be turned on for a target by calling the
function qt_enable_separate_debug_info. For Qt's shared libraries and
tools separate debug information is generated if the
'separate_debug_info' feature is manually turned on.

Change-Id: Ic2ffc15efef3794dc0aa42f3d853ef6d651a751c
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-06 13:38:37 +01:00
Alexandru Croitor
a9caec4a92 CMake: Fix Ninja Multi-Config framework builds
Depends on a new bleeding edge feature in as-of-yet unreleased
CMake 3.18, that allows building macOS frameworks using the
Ninja Multi-Config generator targeting more than
one configuration.

It uses the new CMAKE_FRAMEWORK_MULTI_CONFIG_POSTFIX_DEBUG
property which tells CMake to create properly named debug artifacts
in the Multi-Config ninja file.

Without it, both debug and release artifacts would have the same
location (no _debug) postfix, so it would be unclear which file
ends up being compiled as last (the debug or release variant).

Change-Id: I3e10832551731a18317da8f9667d96cec3dc3028
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-06 00:31:25 +01:00
Leander Beernaert
98fb632f47 Add QT_MODULE_SKIP_MODULE_INCLUDES property
When a Qt module has this property set, when we generate the
QtModuleDepends header file and find this module it will not be added.
This is required to be able to create a Core_qobject module, as it does
not have any headers.

Change-Id: Iaea1080919d05ace12e48693e02d8c0f4c669339
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-05 16:14:15 +01:00
Alexandru Croitor
4f7cc72298 CMake: Handle conditions in third party find modules correctly
Previously the FindWrap modules checked for hardcoded features
when deciding whether to use a bundled library or not. This proved
not to work correctly because features were not available when
the find modules were processed.

Introduce a new CMake API call that needs to be manually called
after an add_subdirectory call which declares a bundled library.

The call will check for the existence of the bundled target, and will
then set a cache variable QT_USE_BUNDLED_Bundled<TargetName>.

The same variable is written into a FindWrapFooConfigExtra.cmake file
which will be loaded by the appropriate FindWrap module. The module
can that use that variable to decided whether to link against the
bundled library or the system library.

Change-Id: I75e9a4f4e14d88d4490916a79ad12f1ce57891e0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-05 16:08:14 +01:00
Joerg Bornemann
46a2366d12 CMake: Port the 'debug_and_release' feature
This feature is read-only. It's controlled by the multi-config feature
of CMake. It mainly exists for the qmake support.

Change-Id: I322459598fe92568eda4d42319ded444537e95d4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-05 07:48:06 +01:00
Alexandru Croitor
aa5e43d491 CMake: Adapt to latest upstream Ninja Multi-Config changes
Most of the NMC-specific variables were renamed to be more general.

Change-Id: I8ee2874fecb9e57480ce51db9183c6cf3dd100af
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-03-04 17:16:24 +01:00
Joerg Bornemann
1a30a82830 CMake: Fix stack-protector-strong test and feature
And in order to do this we must teach qt_config_compile_test a
COMPILE_OPTIONS argument.

Change-Id: I66fa45142b544e3a2fc599af1c1a4c69b442b318
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-04 16:31:13 +01:00
Samuli Piippo
963017f588 Prepend prefix path after loading toolchain file
The original toolchain file may set CMAKE_FIND_ROOT_PATH instead of
appending it, which overrides the Qt's path.

Change-Id: I69a4bf4be6a999854bb8a84cf5032c6a9b739b2e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-28 08:31:34 +02:00
Leander Beernaert
92ee6dcec0 CMake: Generate Win32 Resource Files
Add support to generate win32 resources files through CMake. The
functionality is implemented via qt6_generate_win32_rc_file() in
Qt6CoreMacros.cmake.

Currently qt_add_test(), qt_add_module() and add_qt_gui_executable()
call the above function when building on windows. The function itself
has been written as part of the public API so it can be called from
other locations if required.

Change-Id: Id5388b3bf9a2068b36780d8268306326f990778c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-25 16:38:45 +01:00
Leander Beernaert
c1c011e355 CMake: Add missing linker flags for MSVC
This patch adds missing linker flags for MSVC in order to match
qmake's msvc-desktop.conf.

Change-Id: Ieb1206dae4517e8d9f36175f8fcebccd30e52d01
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-25 16:19:44 +01:00
Joerg Bornemann
119ffd4781 CMake: Port the reduce-relocations feature
As reduce-relocations implies bsymbolic_functions, we also add the
-Bsymbolic-functions linker flag.
Also, handle the .dynlist files that are passed to the linker by
bsymbolic_functions.prf in the qmake build.

Change-Id: I535c33fba888596d2f8975b16864bbe9f0a7caa4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-25 15:47:50 +01:00
Alexandru Croitor
26059d1b9b CMake: Allow building bundled 3rd party libraries in qtbase
A few things are needed to accomplish that:

- the python scripts do not ignore certain system_foo features anymore
  (it is a hardcoded list for now just to be safe)

- configurejson2cmake now outputs
  qt_find_package(WrapSystemFoo) calls for bundled libraries
  (see below)

- the harfbuzz .pro file is modified to accommodate pro2cmake
  not being able to correctly parse some conditional scopes

- the freetype .pro file is modified to make sure linking of the
  library succeeds without duplicate symbol errors, which qmake
  doesn't encounter due to magical exclusion of cpp files that are
  included in other cpp files (presumably for include moc_foo.cpp
  support)

- feature evaluation for Core, Gui, Network now happens in the
  qtbase/src directory, so that bundled libraries can be conditionally
  built

- for each bundled library there are now two FindWrap scripts:
  - FindWrapSystemFoo which finds an installed library in the system
  - FindWrapFoo which either uses the system installed library or
    the built bundled one depending on a condition

- projects that intend to use bundled libraries need to link against
  WrapFoo::WrapFoo instead of WrapSystemFoo::WrapSystemFoo targets
  (this is handled by pro2cmake).
  Unfortunately manually added qt_find_package(WrapFoo) calls might
  still be needed as is the case for WrapFreetype and others.

- a new cmake/QtFindWrapHelper.cmake file is added that provides
  a macro to simplify creation of WrapFoo targets that link against
  a bundled or system library. The implementation is fairly ugly
  due to CMake macro constraints, but it was deemed better than
  copy-pasting a bunch of almost identical code across all
  FindWrapFoo.cmake files.

- a qtzlib header-only module is now created when using bundled
  zlib, to provide public syncqt created headers for consumers
  that need them. These are projects that have
  'QT_PRIVATE += zlib-private' in their .pro files
  (e.g. qtimageformats, qtlocation, qt3d, etc.)
  This is unfortunately needed due to QtNetwork using zlib
  types in its private C++ API.

The change includes support for building the following bundled
libraries:
- zlib
- libpng
- libjpeg
- Freetype
- Harfbuzz-ng
- PCRE2

The following 3rd party libraries are still using an old
implementation within the CMake build system, and should be migrated
to the new one in the near future:
- double-conversion
- Old harfbuzz

The are a few libraries that are not yet ported:
- system-sqlite
- systemxcb
- maybe others

Among other things, this change allows building qtbase on Windows
without requiring vcpkg.

Task-number: QTBUG-82167
Change-Id: I35ecea0d832f66c1943c82e618de4a51440971a5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-02-25 15:43:16 +01:00
Alexandru Croitor
1b47411832 CMake: Check for syncqt private headers directory before using
Only existing directory paths should be added to
INTERFACE_INCLUDE_DIRECTORIES, otherwise projects fail to configure.

If after running syncqt there is no private headers directory created
(due to the module not having any _p.h files), such a path should not
be added as an interface include path.

This fixes consumers of QtZlib, where there are no private headers.

Change-Id: I3fd1a7b5eb8f816d178d6d91223baa6f377e6f9f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-02-25 15:43:16 +01:00
Alexandru Croitor
173079819d CMake: Allow evaluating features before a module is processed
Introduce an internal qt_feature_evaluate_features() function
which takes a list of configure.cmake paths, and evaluates the
features declared in those files, thus setting a bunch of cache
variables.

This is required to implement the equivalent of what qtbase/src.pro
does, which includes the feature .pri files to decide whether
bundled 3rd party libraries need to be built.

Change-Id: I5552f488671c001eb3f204245b905ab981017a9f
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-02-25 15:43:16 +01:00
Alexandru Croitor
331b153be5 CMake: Fix FindWrapRt module when it's found multiple times
On Windows, when WrapRt is qt_find_pacakge()'d the first time, the
result is "not found", whereas a second time it would claim that the
package is found.

This is due to the WrapRt target being always created even if it has
no transitive dependencies, and thus a second search would check only
for the existence of the target.

Fix the module to only create the target if the relevant library
is found.

Change-Id: I5c838cbfbafb4029f96da815a0f72e4a8e6716b0
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-02-25 15:43:16 +01:00
Alexandru Croitor
8ab59fd8b3 CMake: Fix 3rd party library installation
Libraries created with qt_add_3rdparty_library should be installed
when the qmake 'installed' value is set in CONFIG. Introduce a new
INSTALL option to handle that in CMake projects.
If the value is provided, the library should always be installed
regardless of whether it's a shared or static library.

Fix the libraries to be installed to BINDIR/LIBDIR instead of
the config install dir.
Also install the CMake config files into the config install dir.

Change-Id: I86f1ef47680f08669a77db77e0d986f47d5fae2d
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-02-25 15:43:15 +01:00
Alexandru Croitor
ae9f0aa86a CMake: Allow creation of modules with no qtfoo-config.h file
Useful for header only modules that are declared in the same directory
as a regular module, but which doesn't have any features and thus has
no qtfoo-config.h file.

Will be used for the qtzlib module, which is built when system_zlib
feature is disabled.

Change-Id: I60c5f73c3e2a3a481a16c5872e06d5d109a04b10
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-02-25 15:43:15 +01:00
Alexandru Croitor
5838d1f6c3 CMake: Add functions to allow setting symbol visibility flags
Needed for 3rd party library code.

Change-Id: Ib994de1980515e849d4368249024d3d5e064fb46
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-02-25 15:43:15 +01:00
Alexandru Croitor
05a0a278fc CMake: Allow disabling warnings similar to CONFIG += warn_off
The QT_COMPILE_OPTIONS_WARNINGS_OFF property can be set on targets
in order to disable adding the default compiler warnings flags.

This is useful when building 3rd party library code.

Change-Id: I9f58ca4543b5ea0d2051b7f94f0042d24c4e3a16
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-02-25 15:43:15 +01:00
Alexandru Croitor
6d29264e3e CMake: Set minimum deployment target only for host macOS
A future change will come that sets it for iOS and friends.

Change-Id: I74b688ee62d24137e3cdf5475e1a9e858698ccf0
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-21 16:16:26 +01:00
Leander Beernaert
a99d7cf372 CMake: Add missing compile flags for msvc
This patch adds a couple of missing compile flags that are defined in
mkspecs/common/msvc-version.conf and mkspecs/common/msvc-desktop.conf
that were not yet ported to CMake.

Change-Id: I9ef0ef71cb0c063699fba4c067e90f6515169baf
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-20 16:11:02 +01:00
Leander Beernaert
f03a51a404 CMake: Fix use of compile define QT_NO_DEBUG
Prior to this patch QT_NO_DEBUG would not be correctly set for
generators which support multiple configurations such as Visual Studio
and XCode.

This patch also applies the define to all executables, which was
previously missing.

Change-Id: I16a911d15217a62093c68ba2b4c2545cdb8df1e6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-20 16:11:01 +01:00
Leander Beernaert
98543f0a13 Fix PATH environment variable for CMake tests
This patch fixes setting the correct value for the PATH
environment value. Currently, due to Windows' ; path
separator, every list entry was treated as a separate
environment variable that need to be set instead of
properly extending the PATH list.

Change-Id: Ib2fc031397459370beec84f9cb4ec6df7db00df3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-02-19 15:14:55 +00:00
Leander Beernaert
540bd6cf20 Only install tests data for prefix builds
If we install tests data for non-prefix builds it can cause tests to
fail as they find the data in the wrong location. An example of this is
tst_qsslkey.

Change-Id: I55bd2ff4cb5a0857dc857cb2149ffe4436ec6f99
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-18 21:22:58 +01:00
Leander Beernaert
ba165cae71 Set qt_add_test WORKING_DIRECTORY to OUTPUT_DIRECTORY
If qt_add_test() is called with OUTPUT_DIRECTORY and no
WORKING_DIRECTORY is specified, default the WORKING_DIRECTORY to the
same value as OUTPUT_DIRECTORY._

Change-Id: If373fe590508ad58d4632e0598cd0d9dddb2ae16
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-02-18 21:22:57 +01:00
Alexandru Croitor
e9672c747c Set a default value for CMAKE_OSX_DEPLOYMENT_TARGET
This replicates the behavior of QMAKE_MACOSX_DEPLOYMENT_TARGET in
qmake.

Change-Id: I273cd26994f2edfc52dc7b6278252c37b65b2356
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-02-18 21:22:35 +01:00
Alexandru Croitor
4ee289d2d8 CMake: Use correct C++ standard flag when building standalone tests
Before the patch we set the standard flags in two places:
- once when building qtbase
- and always when including QtSetup (for every repo that is built)

This change makes sure to also set the correct standards flag when
building standalone tests, because QtSetup is called to early in
that case.

Change-Id: Iad130b731e9eb9605bb91637364c33fdd49ce3cb
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-02-18 21:22:34 +01:00
Olivier Goffart
5fa2fc61c9 cmake: C++17 is mandatory
Change-Id: Ia0f2151d38fec84be31afc76fc380666861d7d80
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-02-18 14:44:58 +01:00
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
c53ee1f054 Merge remote-tracking branch 'origin/wip/cmake' into dev
Conflicts:
	tests/manual/rhi/hellominimalcrossgfxtriangle/CMakeLists.txt

Hopefully final merge from wip/cmake, and then all cmake changes
should target dev directly.

Change-Id: I29b04c9b0284e97334877c77a32ffdf887dbf95b
2020-02-13 23:29:51 +01:00
Liang Qi
6b2535ea15 Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	examples/widgets/graphicsview/boxes/scene.h
	src/corelib/Qt5CoreMacros.cmake
	src/corelib/Qt6CoreMacros.cmake
	src/network/ssl/qsslsocket.cpp
	src/network/ssl/qsslsocket.h
	src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp
	src/testlib/CMakeLists.txt
	src/testlib/.prev_CMakeLists.txt
	tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp

Disabled building manual tests with CMake for now, because qmake
doesn't do it, and it confuses people.

Done-With: Alexandru Croitor <alexandru.croitor@qt.io>
Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io>
Change-Id: I865ae347bd01f4e59f16d007b66d175a52f1f152
2020-02-13 18:31:40 +01:00
Christophe Giboudeaux
aa94565f89 Use INSTALL_DOCDIR when possible
Hardcoding 'doc' causes issues when installing qtbase but also
when trying to build the other modules documentation.

Change-Id: I5c57852add59d0dc0d067813feea0bbb0962c84b
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-12 08:45:22 +00:00
Leander Beernaert
572c03eb7a Add support for qt_helper_lib()
Add qt_add_3rdparty_library() function as a replacement for qmake's
qt_helper_lib feature.

All 3rdparty libraries will be available under the Qt:: alias when built
through this method so that they can properly register as dependencies
of a Qt module.

This patch also adds Qt3rdPartyLibraryConfig.cmake.in to export the
CMake configuration for static builds and shared libraries.

Change-Id: I52bf3a95ca22fccd9ab54343468847bb1b570c28
Fixes: QTBUG-81969
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-12 08:43:29 +00:00
Leander Beernaert
a2eb09a377 Only export public module link dependencies for shared builds
Unless we are building under a static library configuration there is no
reason to export the dependency on private libraries.

Change-Id: I724da38495dc55cc2783d4b19c01533fc0900d22
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-12 08:37:38 +00:00
Samuli Piippo
9bab556005 Fix typo for Mtdev pkgconfig target
Change-Id: Id6e7057e8010f67ba1c8ce948abc59bc7abf7b7b
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-11 09:20:14 +00:00
Leander Beernaert
c431e2d33c Refactor Metatypes dependency propagation
Every metatypes.json files is now added as an INTERFACE source file to a
target. This enables us later to correctly collect all the
metatypes.json files from dependent targets. This information is also
correctly exported via export()/install().

To avoid the metatypes.json appearing in every target's source list,
the file path is wrapped in a generator expression which will only be
evaluated when the consuming target has the property
QT_CONSUMES_METATYPES set to true. At the moment this is limited to
targets which need to interact with qmltyperegistrar.

Change-Id: I0ffebcd069a923383f7ed11cde2c94ecf2fb13f3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-10 15:07:34 +00:00
Alexandru Croitor
b06f086460 Don't add private module headers for private modules when not needed
If a module has the NO_MODULE_HEADERS option, we should not add
the private module header paths to the BUILD_INTERFACE of private
modules.

This fixes building static non-prefix qtdeclarative builds on Linux,
where non-existent QtXcbQpa headers failed the qtdeclarative
generation step.

Change-Id: Ic9fdd8c5688d3449576eb8a5dd852c252e29bf5b
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-06 21:43:14 +00:00
Leander Beernaert
cb1fbfa1a0 Remove qt_add_qml_module() from QtBuild
This bit is being move to QtDeclarative as it is not required to build
QtBase.

Change-Id: I7b559b8b0e33e66d92c97c93bc43b650e7150237
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-06 12:22:09 +00:00
Leander Beernaert
2c297ac598 Load module specific extensions for QtBuildInternals
This patch enables each module to load their own
Qt${version}ModuleBuildInternals.cmake to expose module specific
features when building Qt.

These scripts are only loaded when the package QtBuildInternals has been
loaded.

Change-Id: Ie58dd93ddd292cf106fe7ef147151a51fd5aa2b1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-06 12:21:58 +00:00
Leander Beernaert
a43f2a6caa Safeguard against multiple definition of dbus-1 target
Change-Id: Ibba9ce7ce472fe2939386065087f0b07ad811c3f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2020-02-06 12:21:49 +00:00
Leander Beernaert
225113d59b Fix qt_add_qml_module() for non-prefix builds
Always set the installation directory for Qml modules as it is required
for qt6_add_qml_module() to set the correct properties so that qml files
can be copied to the right location.

This patch also fixes the copy of qmldir. As it previously stood, the
copied file was not complete as it is possible fore the contents to
change after we exit this function.

Change-Id: I974269cf0507664b005a93bf27ab19941d99f1d6
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-05 15:18:31 +00:00
Leander Beernaert
20bb59ca61 Allow manually specification of moc.json files for metatype generation
qt6_generate_meta_types_json_file() has been extended to allow the
generated moc_....cpp.json files to be manually specified. This now
enabled the metatype generation to be used without resorting to AUTOMOC.

Additionally, Core_qobject declaration order has been temporarily moved
as it otherwise does not produce the correct metatypes dependency file
for Core. This will be fixed in a follow up patch.

Change-Id: I3266ab3073db478458a0c1dbc8b9fbab16622a64
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-05 15:18:03 +00:00
Alexandru Croitor
c5b61d2e90 pro2cmake: Handle QT += core-private correctly for modules
If a module project (Quick) contains QT += core-private, the
qmake semantics translated to CMake would mean the following:

target_link_libraries(Quick PUBLIC Core)
target_link_libraries(Quick PRIVATE CorePrivate)
target_link_libraries(QuickPrivate INTERFACE CorePrivate)

Whereas a QT_PRIVATE += core-private only means
target_link_libraries(Quick PRIVATE CorePrivate)

without adding any public dependencies to QuickPrivate.

To achieve that, we need a few modifications to both pro2cmake and
QtBuild.cmake

- pro2cmake doesn't automagically add public and private dependencies
  to targets when encountering a private module assigned to QT.
  Instead it generates the logic described above by passing correct
  LIBRARIES, PUBLIC_LIBRARIES, and PRIVATE_MODULE_INTERFACE values.

- pro2cmake doesn't do any dependency magic for non-module targets
  anymore, like executables, plugins, internal_modules. This means
  that QT assignments are now regular public dependencies.

- qt_add_module and qt_extend_target now accept a new
  PRIVATE_MODULE_INTERFACE option.

- qt_extend_target does not automagically make private modules be
   public dependencies on other private modules.

- qt_extend_target correctly assigns PRIVATE_MODULE_INTERFACE values
  to Private module only. For other target types, it's a no-op.

The change requires regeneration of all projects.

When we fix pro2cmake and QtBuild.cmake to properly handle
internal_modules (create only Private modules without creating
a non-Private counter part), we will need another project regeneration
to correctly assign dependencies.

Change-Id: I4c21f26b3ef3b2a4ed208b58bccb65a5b7312f81
Task-number: QTBUG-81780
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-05 14:36:16 +00:00
Samuli Piippo
4ddd4bf1aa Add additional include path for DRM
Tegra has drm.h header in include/drm instead of include/libdrm

Both paths are defined in libdrm.pc, but those are not used since this
cmake file searches only for xf86drm.h.

Change-Id: If1e979c7d5aec520b18eed5b3fcbb5ac2e15cc62
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-05 12:54:51 +00:00
Samuli Piippo
0f8039140c qtbase: don't use neon flags on arm64
NEON is mandatory for aarch64 and compiler doesn't recognize
-mfpu=neon commandline argument.

Change-Id: I36e9c40e3fd3604d4895da0526152e90b2165770
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-05 09:45:14 +00:00
Samuli Piippo
e1170185e3 qtbase: use syncqt.pl from QT_HOST_PATH
Use syncqt.pl from QT_HOST_PATH if that is given, since qtbase
sources might not be available and CMAKE_INSTALL_PREFIX doesn't
check for sysroot.

Change-Id: I165b17a5a02fd4dbb2340bf69a641b8aaab8fabd
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-05 09:44:10 +00:00
Leander Beernaert
7e2c198e90 Remove retained quick compiler resource files
Remove retained file feature as the expected behavior now is for the
compiled file to be retained by default.

Change-Id: I5a791a182825b223eb4497970fbb1c47c70135cc
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-05 09:27:27 +00:00
Leander Beernaert
465949420a Update add_custom_command and add_custom_target dependencies
If we don't add the executable used by the custom_target and/or
custom_command to list of the command's/target's dependencies
(DEPENDS) the generated file will not update should the executable
change.

Change-Id: Idce30f3dd4f756d9e8f6848c5e16f5dd6c7c8f0a
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-03 08:07:03 +00:00
Christophe Giboudeaux
4954adea39 Don't hardcode the include directory name
Hardcoding "lib" caused build issues and wrong
INTERFACE_INCLUDE_DIRECTORIES paths in generated CMake configuration
files if INSTALL_INCLUDEDIR pointed to a different location.

Contributes to QTBUG-81289

Change-Id: I3276ecbb4bf5df1c0b4c496c0287b4a69586d683
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-01-31 12:41:47 +00:00
Christophe Giboudeaux
3f386095ad Don't hardcode the library directory name
INSTALL_LIBDIR may point to a different directory than "lib".

Contributes to QTBUG-81289

Change-Id: Ia8220515e3ee3703539aa28655e6c806736615ec
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-01-31 10:10:10 +00:00
Christophe Giboudeaux
7f6eb6ead6 Don't hardcode the binary directory name
INSTALL_BINDIR may point to a different location than "bin". In order
to avoid errors when trying to install qtbase, "bin" is replaced with
"INSTALL_BINDIR" where necessary.

Contributes to QTBUG-81289

Change-Id: I1d4f9fb2617547c9b0e44d6690caebb2b6768e2f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-01-31 10:09:47 +00:00
Christophe Giboudeaux
5fc2882ac5 Add INSTALL_MKSPECSDIR to the install locations
Linux distributions may want to install mkspecs files into a
different subdir in order to make Qt6 co-installable with
older versions.

Contributes to QTBUG-81289

Change-Id: Ie4a64370d742948d5ca4f2eaed6ea550d2676707
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Christophe Giboudeaux <christophe@krop.fr>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-01-31 10:09:39 +00:00
Alexandru Croitor
2ed9aeb687 Fix CMAKE_BUILD_TYPE to be force set
Otherwise CMake sets an up an empty default value itself, and then
the value in QtBuildInternalsExtra does not end up being used, and
then QtSetup ends up setting a Debug value.

Amends 34a112e383

Change-Id: If97a1d8c19ad5e7f690283997ff80dd9588cd521
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-01-30 20:45:17 +00:00
Leander Beernaert
67ea445f09 Append to AUTO_MOC_OPTIONS in order not override existing value
Change-Id: Id1bf607e31ee2baa5ffb6d6b4aedd98ea83e5e15
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-01-29 15:55:49 +00:00
Leander Beernaert
f47efdac1d Only add --automoc-json to AUTOMOC_OPTIONS for metatypes targets
Change-Id: I7c2e859a83ea78c2a6cf2ad59c175c1b29a74621
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-01-29 15:36:55 +00:00
Leander Beernaert
a6ccef651d Generate metatypes dependency file
Due to generator expression it is impossible to recursively evaluate the
link dependencies of a target. This is required by QtDeclarative's
qmltyperegistrar.

To overcome this we generate a ${target}_metatypes_dep.txt file which
contain lines with the following pattern:
${PATH_TO_METATYPES.json}=${PATH_TO_METATYPES_DEP.txt}

This can be used to recursively evaluate the dependencies at run time.

Change-Id: Ia4cee0632c16ba9631e0289db906fe9d320844a3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2020-01-29 14:20:54 +00:00
Alexandru Croitor
34a112e383 Fix CMAKE_BUILD_TYPE to be a cache variable in QtBuildInternalsExtra
Rather than pass the build type in the wrapper, make sure the build
type is a cache var, so it gets picked up when building other repos.

This reverts commit f72ca4cf85.

Change-Id: I5d91ab66249b6c40c5e548b0eec0e467ba0f2ebc
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-01-29 11:56:27 +00:00
Leander Beernaert
f72ca4cf85 Forward CMAKE_BUILD_TYPE, if available, in qt-cmake
Change-Id: I299e16cfc084b3fc009e806902e26121ebdd454b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-01-29 09:39:32 +00:00
Alexandru Croitor
fd590b9482 Don't create convenience plugin target when not needed
If the OUTPUT_NAME of a plugin is the same as the CMake target name,
don't try to create a custom target with the same name. That will
cause configuration errors due to duplicate targets.

Amends f67d8ae2d4

Change-Id: Iaea7c68e22dbc1e345ba10950c312618abba4c21
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-01-27 14:21:58 +00:00
Alexandru Croitor
b714219fea Fix qt_import_plugins compatibility with Qt 5
Handle versionless plugin names passed to qt_import_plugins.

Task-number: QTBUG-74137
Task-number: QTBUG-80477
Change-Id: Ic7fb6e54d2822c7eb58a7874b4a1c137f0c101d9
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-01-27 11:59:51 +00:00
Alexandru Croitor
f67d8ae2d4 Fix plugin target names to be compatible with Qt 5
In Qt 5, qmake generates CMake Config files which expose the plugins
as imported libraries. The name of these libraries are derived from
the plugin class name. So QCocoaIntegrationPlugin, and not qcocoa.

To keep compatibility between Qt5 and Qt6 CMake target names,
the pro2cmake script should generate plugin target names based on the
plugin class names.
To avoid passing the same name in qt_add_plugin (target and CLASS_NAME),
derive the class name from the target if the class name is
not explicitly specified.

Also add a new OUTPUT_NAME parameter which is used to change the
final file name of the plugin, so that it's compatible with Qt5.
For example to generate a qcocoa.dylib file, instead of
QCocoaIntegrationPlugin.dylib file.

The same OUTPUT_NAME value will be used for generation of plugin .prl
files for qmake consumption.

Change-Id: I4d53e680d7beb62befecd359cdf6bba60a34ff0d
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-01-27 11:49:11 +00:00
Alexandru Croitor
c9bea1ad62 Add initial support for CMake "Ninja Multi-Config" generator
This allows doing debug_and_release builds with Ninja on all
platforms.
The "Ninja Multi-Config generator" is available starting with CMake
3.17.

Desired configurations can be set via CMAKE_CONFIGURATION_TYPES.
Possible values: "Release, Debug, RelWithDebInfo, MinRelSize".
For example -DCMAKE_CONFIGURATION_TYPES="Release;Debug".

The first configuration is the 'default' configuration which is
built when calling ninja with no arguments.

To build all targets of a certain configuration use "ninja all:Release"
or "ninja all:Debug".

To build all targets in all configurations use "ninja all:all".

Note that the first configuration influences which configuration of
tools will be used when building the libraries for all configurations.
In simple terms, when configured with
-DCMAKE_CONFIGURATION_TYPES="Release;Debug" the release version of moc
is used by AUTOMOC.
When configured with -DCMAKE_CONFIGURATION_TYPES="Debug;Release"
the debug version of moc is used by AUTOMOC.

Framework builds and Ninja Multi-Config don't currently work together
due to multiple bugs in CMake, which ends up generating an invalid ninja
file with duplicate rules. There are also issues with placement of the
debug artifacts.

This will be handled in a follow up patch after CMake is fixed.

Task-number: QTBUG-76899
Change-Id: If224adc0b71b7d1d6606738101536146aa866cd7
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-01-27 11:47:57 +00:00
Leander Beernaert
cce8ada814 Support for QML Type Registrar
Change-Id: Ifc1f44cf40b22c20ab768333ba9d5ce58a5f7250
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-01-24 12:29:30 +00:00
Alexandru Croitor
d1be8b9ceb Fix dependencies for SIMD object libraries in macOS framework builds
This manifested in Coin when ninja tried to build qdrawhelper_sse2.cpp
before the Core framework headers were copied, resulting in a
fatal error: 'qatomic.h' file not found.

Make sure every SIMD object library has all PRIVATE dependencies of
its parent library PRIVATE dependencies (except for other SIMD object
libraries), to make sure that the framework headers are copied by the
time the SIMD source file is compiled.

Here's an example for clarification. Gui_simd_sse2's LINK_LIBRARIES
property should have all the values of Gui's LINK_LIBRARIES property
(like Qt::Core) filtering out all SIMD object library targets (
like Gui_simd_sse2, Gui_simd_sse3, etc).
Thus we make sure the SIMD object libraries are built after Gui's
dependencies are built.

Note that using INTERFACE_LINK_LIBRARIES to avoid the filtering of SIMD
targets in the generator expression would only work in shared Qt builds.
In static Qt builds where PRIVATE dependencies become PUBLIC, CMake would
insert $<LINK_ONLY:Gui_simd_foo> entries in INTERFACE_LINK_LIBRARIES
which causes CMake to be confused and fail at generation time.

Change-Id: I246c1394b9c9830c0ebd11e6621e56b992a6a1f2
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-01-22 12:36:06 +00:00
Leander Beernaert
3854b5892b Add QT_TEST_RUNNING_IN_CTEST environment variable for test
When running tests with CMake's CTest, set the environment
QT_TEST_RUNNING_IN_CTEST to 1. This can be useful to deal with tests
that do not properly work when running from CTest.

For instance, the qmake test in this patch has one test that only works
when not run from CTest.

Change-Id: I01eea9131de69c18118a9ed9f96e9296d5ea20f1
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-01-14 13:24:55 +00:00
Leander Beernaert
1f2cdd8a04 Add support for test timeouts
Change-Id: Iba805cbc16d179e5b080ccc00542329270075aa1
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-01-13 12:28:24 +00:00
Leander Beernaert
108393d33b Fix Generator Expression for static non-prefix builds
Change-Id: Icd32164943d7bb0639de3022bae749d0010674fc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-01-10 10:18:55 +00:00
Jean-Michaël Celerier
ea81b69cde Implement qtbase fixes for superbuilds
Change-Id: I0d3445cf0740e3925fa9342dac4d07892518afe5
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-01-08 10:42:21 +00:00
Leander Beernaert
a182efb9c4 Fix is_framework check for interface libraries
Change-Id: I59832e698eceb98a2a03f4a3e2de88b1d18fda6e
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-01-06 15:05:44 +00:00
Joerg Bornemann
4b2de41b13 CMake: Add support for framework builds
Framework builds are enabled by default on macOS.
They are controlled via the framework feature.

Task-number: QTBUG-75751
Change-Id: I00bc64672f02bbd1672508b2b5010d202984a961
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Qt CMake Build Bot
2020-01-06 11:53:53 +00:00
Leander Beernaert
0095ff4e06 Add custom targets for documentation
Adds custom targets which take care of generating and installing
documentation files.

Every module has a global set of targets suffixed with the module
name in order for them to be unique when we implement super builds.
The targets are the same as the list below, but replace ${target}
with the module's name. Eg.: docs_qtbase.

For every target which has an qt_add_docs() call, we now create the
following set of custom targets:

* docs_${target}
* html_docs_${target}
* qch_docs_${target}
* prepare_docs_${target}
* generate_docs_${target}
* install_docs_${target}
* install_html_docs_${target}
* install_qch_docs_${target}

Fixes: QTBUG-75859
Change-Id: Ie84cb9a2dedbe7333d9a84f4d73383442deca477
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-18 14:27:01 +00:00
Leander Beernaert
ed6e6c3787 Expose Patch Version in QtConfig.cmake
Change-Id: I2166d480c0b717fc9137f8eb42d5aab7a091395d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-11 15:46:08 +00:00
Leander Beernaert
6c20ae774c Add option to specify working directory for qt_add_test
Change-Id: Iba5104cccdc613f7b2cf0d1454209578adaac824
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-12-10 13:24:10 +00:00
Friedemann Kleint
de142e8f22 cmake/README.md: Clarify some points
- Mention location of the configure.cmake
- Specify the path to the conversion scripts

Change-Id: Ia6e13a1f4d2c29f2fbaf35acdd70ab16c7175d37
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-09 14:36:52 +00:00
Alexandru Croitor
a64acbea9c Make sure to install QtModuleToolsVersionlessTargets.cmake.in
Amends 04d895681a

Task-number: QTBUG-74137
Task-number: QTBUG-80477
Task-number: QTBUG-75984
Change-Id: I617c2abf421bc1378545e5a36fd44533131ef471
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-06 15:11:33 +00:00
Alexandru Croitor
04d895681a CMake: Fix creation of versionless targets for tools
We can't use qt_internal_export_modern_cmake_config_targets_file for
executables like tools, because it's not possible to use
INTERFACE_LINK_LIBRARIES with executables like you can with libraries.
We also can't create aliases to non-global imported targets.

Instead create new imported executable targets, fish out the imported
location, and assign it to the versionless targets.

Task-number: QTBUG-74137
Task-number: QTBUG-80477
Task-number: QTBUG-75984
Change-Id: I6a3c9c67ef4699c72a6c9a627c63158dfd6557f8
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-06 11:11:16 +00:00
Leander Beernaert
05ba991d39 Fix meta types json file install for non-prefix builds
Change-Id: I76fd379dacb7db79d4ed6ca47954ae8e703842d4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-05 15:09:50 +00:00
Alexandru Croitor
f4e80ea688 Clear QT_KNOWN_MODULE_${module}_TOOLS cache vars on reconfiguration
Otherwise if you configured a commit that has tool A, and the switch
to a commit where tool A does not exist anymore, reconfiguration
will fail.

Change-Id: Ibb244b9630a6f4fecd27d51ce28eceff07ba8666
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-05 14:52:42 +00:00
Leander Beernaert
0f220d473a Collect Json Metatypes from CMake's Automoc
This patch adds a new bootstrap tool which will read CMake's
AutoGenInfo.json and ParseCache.txt to determine what the current
list of json files is that needs to be passed to moc --collect-json
option.

Right now this is enabled for qt_add_module() with the option
GENERATE_METATYPES. pro2cmake has also been updated to detect qmake's
CONFIG += metatypes and to generate the above option for modules.

The implementation lives in Qt6CoreMacros so it can eventually be used
in the public facing apis.

The generated meta types file is saved under the target property
QT_MODULE_META_TYPES_FILE.

Change-Id: I03709c662be81dd0912d0068c23ee2507bfe4383
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-04 10:48:06 +00:00
Alexandru Croitor
9eea24ed60 Don't export private include paths if there are no private includes
Needed when building Qt Creator with CMake + Qt6 non-prefix build.
Specifically qttools's QtUiPlugin does not have any private headers,
but the non-existing include path was exported, which caused an error
when configuring Qt Creator.

Change-Id: I662bc502fe3134fba083bde273b7f63fe1470277
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-03 17:14:14 +00: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
Alexandru Croitor
9061f29872 Provide a way to specify extra tool package dependencies
In the qtwayland repo, both WaylandClient and WaylandCompositor
packages need access to the qtwaylandscanner tool. That means
that the add_qt_tool(qtwaylandscanner) can't use the TOOLS_TARGET
argument to associate a dependency with only one of the above
modules.

Instead add_qt_tool now allows specifying a non-existent module
name for the TOOLS_TARGET argument, which can be manually
depended on by other packages.
Actually, you could specify the non-existent module before as
well, but that didn't do everything that had to be done.

This required a bit of refactoring in how the Dependencies file
for Tools packages is created. Now the file is created in
qt_export_tools.

Two new functions were also added to allow recording additional
dependencies between packages.

Also some bug fixes were done to make it all work. Specifically
the _FOUND variable generated in the Dependencies file was incorrect.
Also there are some quotes missing when appending extra package
dependencies via the QT_EXTRA_PACKAGE_DEPENDENCIES property.

Change-Id: I167efec16dff8d036e191df3572ea72764e22bc5
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-26 10:58:56 +00:00
Alexandru Croitor
8d35ad8726 Add FindWrapHarfbuzz
Apparently we didn't have a wrap find module for it before. Add one,
and add special support to handle a Gentoo broken Config file which is
exported by an autotools build of harbuzz.

Change-Id: I83cbeb817caf2610104c16713d4eac6ab6f8c63b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-11-25 11:58:02 +00:00
Cristian Adam
974536c4aa CMake: Do feature testing for linker flags
Instead of hardcoding which platforms and which compilers support
certain linker features, do the proper probing via
check_cxx_source_compiles.

Change-Id: I676010970d8f3a8f2a8340c5d15dfcef76fe9191
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-22 17:08:02 +00:00
Cristian Adam
f4efaf54d5 CMake: Add support for building with Clang-MinGW toolchain
Clang doesn't have a mkspec just a win32-clang, there is
win32-clang-g++ and win32-clang-msvc.

Change-Id: Iff521e955559dfb2308e377b41e86b3f62c42e70
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-22 17:06:18 +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
Alexandru Croitor
1fd21c47d0 Fix warnings when a module's plugin type has underscores
In qtwayland, there were a bunch of warnings of the following type
when configuring:

"The plug-in 'f' does not belong to any Qt module".

This happened because the plugin type had underscores, and was not
sanitized when comparing a the plugin type of plugin.

Add a function to do the sanitization, and use it everywhere.

Change-Id: I728b5f1e18fa5f8876c4a57dbd4e33148cb242d5
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-11-15 18:02:12 +00:00
Alexandru Croitor
dfc583005b Fix add_cmake_library to use a correct plugin suffix on macOS
Qt plugins on macOS use .dylib, whereas CMake created used
".so" instead.

Change-Id: I3ea73a52a0675a0cfce4997ca413df79e63cfaa7
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-11-15 12:25:22 +00:00
Alexandru Croitor
38354d7d61 Rename / prefix all our private API functions with qt_
Rename internal APIs like extend_target to qt_extend_target.
Prefix apis with qt_ where required.

Keep old names for compatibility until all their usages are removed.

Change-Id: I9a13515a01857257a4c5be3a89253749d46a4f41
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-14 09:05:33 +00:00
Alexandru Croitor
9e6456a49d Fix not to add warnings_are_errors property to INTERFACE targets
Amends f000685612

Change-Id: I3b61b64bb9c755de38f4a5ffcb07b39b38bd4fd7
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-11-13 16:17:23 +00:00
Alexandru Croitor
250ad9843f Always build tests by default when building standalone tests
Amends 021c17c62f

Change-Id: I8181270ef7506eb5da4d3b43e105e100ed5581e4
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-13 10:00:34 +00:00
Alexandru Croitor
e7f188b2d2 Don't include standalone tests config file if none exists
Some repos like qtimageformats don't generate a config file for
standalone tests because the repo creates no modules.

Amends de3a806def

Change-Id: Id42338804605a883f975feb5dd81eda5acc6e687
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-13 10:00:12 +00:00
Alexandru Croitor
edcf5d0144 Fix qt_skip_warnings_are_errors_when_repo_unclean for executables
Amends f000685612

Change-Id: I48d7a42e11e609fa3a387b7669ee96bd10c856e4
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-13 09:59:56 +00:00
Alexandru Croitor
f000685612 Add support for skipping warnings are errors
Unfortunately not all repositories are marked as warning_clean
in their .qmake.conf files. For instance qtconnectivity and
qttools are not warning clean. Therefore we need to skip
warnings_are_errors flags on all targets created in that repository.

Add support for skipping the warnings are errors flags, by setting
a QT_SKIP_WARNINGS_ARE_ERRORS property on a target, and use that
within a generator expression with all the accumulated flags.

To mimic behavior of qmake, and set the property on all targets
created by add_qt_module, add_qt_plugin, etc, one simply needs
to set the QT_REPO_NOT_WARNINGS_CLEAN variable in the
repo project CMakeLists.txt.

Change-Id: Ib5a487af6601ae1519a0988a89f8083f94f92267
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-12 17:30:35 +00:00
Leander Beernaert
681e8b4ead Add add_qt_manual_test()
This patch adds add_qt_manual_test() which is a simple wrapper around
add_qt_executable() which does not build under ${CMAKE_BUILD_DIR}/bin
or install the targets.

This could potentially be used later to tag manual tests.

Change-Id: Ic4e0a1d133009f5a858b9394347a0996cf42683f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-12 14:46:44 +00:00
Alexandru Croitor
17e2befe2a Don't install QtFooTestsConfig.cmake if no modules were built
When configuring qtx11extras on macOS, we ended up installing the
file, which made Coin think that at least one module was built,
and thus it tried to build tests as well.

Don't install the file if no modules were built, thus preventing
from trying to build tests in Coin.

Amends de3a806def

Change-Id: I920a0b40a6ded12140f251352da53b68eef6560d
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-12 13:21:31 +00:00
Alexandru Croitor
04e86bab13 Make sure to install QtStandaloneTestsConfig.cmake.in
Otherwise leaf modules fail to configure.
Amends de3a806def

Change-Id: Ie304c0021ada9911044abdb7e460b8da8e986a8f
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-12 10:35:22 +00:00
Leander Beernaert
2199a50a2a Build test/manual if it contains a CMakeLists.txt
Change-Id: Ibada60b0902f9c6a6a7284489a56106e0021a9de
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-12 10:06:46 +00:00
Simon Hausmann
1b41a62893 Fix armv7 embedded Linux build
In gui's CMakeLists.txt we have

    if (NOT ANDROID)
        ...
        add_qt_simd_part(Gui SIMD neon SOURCES ...)
        ...
    endif()

and later

    if(UNIX AND NOT ANDROID AND NOT APPLE_UIKIT AND NOT INTEGRITY AND NOT (TEST_architecture_arch STREQUAL "arm64"))
        add_qt_simd_part(Gui SIMD neon
    endif()

Since add_qt_simd_part internally uses an OBJECT library to compile the
sources with different flags and then link into Gui (in this case), we
may end up with an error when add_qt_simd_part is called twice for neon,
because the constructed target (Gui_simd_neon) exists already.

We can re-use an existing target though, as the SIMD features is the
same.

Change-Id: I7a21c6e66b47e918a53fa3b1a7db9e053ecc8d87
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-11 13:04:12 +00:00
Alexandru Croitor
8ef64341c3 Fix architecture config tests values to be written only once
Every time the qtbase project was reconfigured, the list of
config tests results was appended to a cache variable which was
never reset, resulting in multiple copies of the same values
being written to QtBuildInternalsExtra.cmake.

Make sure to clean the cache variable before appending to it.

Also change the variable to be all upper-case, to be consistent
with other cache variables.

Change-Id: Ic12046730a080595e19377981a726bc330641dc1
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-08 16:12:29 +00:00
Alexandru Croitor
021c17c62f Add support for -nomake-tests and -nomake-examples equivalents
A developer can pass either -DQT_NO_MAKE_TESTS=ON or
-DQT_NO_MAKE_EXAMPLES=ON to exclude tests or examples from being built
as part the default make target (when you write just make or ninja).

With ninja, tests and examples can be built separately one by one,
by typing
 $ ninja tst_foo
or
 $ ninja example_bar

Same can be done with the Makefile generator.
 $ make tst_foo

All tests / examples can be built in one go by typing
 $ ninja tests/all
or
 $ ninja examples/all

With the Makefile generator unfortunately it's not as nice and is most
likely an implementation detail, but it can still be done by running
something like
 $ make -f CMakeFiles/Makefile2 tests/all
or
 $ make -f CMakeFiles/Makefile2 examples/all

Change-Id: I34f168b3ab41e952a21d3ace5634e25a9f41922e
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-08 16:05:44 +00:00
Alexandru Croitor
de3a806def Make standalone tests build via top level repo project
Previously repo/tests/CMakeLists.txt was a standalone project on which
CMake could be called. This was useful for Coin to be able to build
and package only tests, but was a bit troublesome because that means
having to specify the usual boilerplate like minimum CMake version,
which packages to find in every tests.pro project.

Instead of having a separate standalone project, modify the top level
project and associated CMake code to allow passing a special
QT_BUILD_STANDALONE_TESTS variable, which causes the top level project
to build only tests, and find Qt in the previously installed qt
location.

This also means that when building a repo, we generate a
${repo_name}TestsConfig.cmake file which does find_package on all the
modules that have been built as part of that repo. So that when
standalone tests bare built for that repo, the modules are
automatically found.

qt_set_up_standalone_tests_build() is modified to be a no-op because
it is not needed anymore. Its usage should be removed from all the
other repos, and then removed from qtbase.

Non-adjusted tests/CMakeLists.txt projects in other repositories
should still be buildable with the current code, until they are updated
to the new format.

Adjust the Coin build instructions to build the standalone tests in a
separate directory.

Adjust pro2cmake to generate new structure for the tests/tests.pro
projects.

Adjust the qtbase tests project.

Fixes: QTBUG-79239
Change-Id: Ib4b66bc772d8876cdcbae1e90ce5a5a5234fa675
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-08 15:42:32 +00:00
Alexandru Croitor
c51fe841f4 Fix handling of _nolink targets for the QtNetwork module
When a _nolink target is exported, instead of getting the original
namespace prefix, it gets the Qt6 prefix
(OpenSSL::OpenSSL_nolink -> Qt6::OpenSSL_nolink).

There is some special case code in Network autotests which tries
to access the former target name, which doesn't exist when building
standalone tests.

Make sure to create a Qt6:: library alias for _nolink targets during a
build (so before the library is exported), and change the Network
autotests project to use this Qt6:: namespaced library, which will
ensure it is found both in a standalone tests build and in a regular
Qt build.

Also make sure to actually call find_package to find the OpenSSL
library when building standalone tests, otherwise configuration will
fail.

Change-Id: I3da5b958e72e745a50380f8ab1644459a7c6b005
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-08 15:09:54 +00:00
Alexandru Croitor
3cfaa19c60 Fix interface library issues on Android
Don't call qt_android_dependencies for interface libraries.
Also make sure not to set properties which don't start with
INTERFACE_ prefix.

Change-Id: I0afdffd34c9aebe0d7ac4731b57dd4d505f84570
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-11-08 15:09:41 +00:00
Alexandru Croitor
8294d85d80 Don't add linker scripts to interface libraries
It only makes sense for non-interface libraries.

Change-Id: I80ac942ed546a6ac866e827aa2026e4e6ac897b2
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-11-08 15:09:31 +00:00
Alexandru Croitor
46cf1f11f0 Don't query MODULE_PLUGIN_TYPES property on interface libraries
The reason is that interface libraries have to have properties
prefixed with INTERFACE_ and more importantly we don't set the
property for interface libraries at the moment.

Amends d1542e8a73.

Change-Id: I86bf99995278b9086fa0e3815e10d5d54d9ea4dc
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-11-08 15:09:23 +00:00
Leander Beernaert
512aae3abe Fix Android x86 builds
Replace condition x86 to i386 to match other platforms.

Regenerate src/gui/CMakeLists.txt

Disable SSE4 on android x86 to match qmake.

Change-Id: Ic0d330206f2d70a79d72553aa3ff0f91ff58119c
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-08 09:40:24 +00:00
Leander Beernaert
cd9813d276 Add support for benchmark conversion
Convert benchmark executables to add_qt_benchmark().

Currently add_qt_benchmark just calls add_qt_executable() and
ensures that it they build under CMAKE_CURRENT_BUILD_DIR and do not
install.

Add QT_BUILD_BENCHMARKS option to enable/disable building of benchmarks.

Change-Id: Id0bc676698d21d50048d97d9abef51d92ccb6638
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-04 15:48:30 +00:00
Frederik Gladhorn
92fdc6b2ea cmake: Fix setting QT_DISABLE_DEPRECATED_BEFORE
The last set would override the variable instead of appending to it,
thus QT_DISABLE_DEPRECATED_BEFORE was never set.

Change-Id: I173b91704a855fcda1f2b86172d318e3953466db
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-31 13:48:09 +00:00
Leander Beernaert
69fb4ae343 Distinguish between qt_plugin and regular plugins
If we do not encounter the load(qt_plugin) statement in the .pro file
but we do see the entry CONFIG+=plugin, treat the target as a regular
CMake library instead of treating it as a qt_plugin by default.

Change-Id: I67ad5c865a1a5ab691a6b0d86c2db4b686aa04dd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-28 09:20:37 +00:00
Leander Beernaert
080f9ad160 Enable running test on Android
This patch converts all add_executable calls when building for Android
to a module library and replaces the call to add_test() to use
the android testrunner binary.

Change-Id: I10ba5919217cdc93cc2cbbb7d13ad9d10fc5ac1a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-28 09:18:28 +00:00
Alexandru Croitor
d183c21a2c Fix declarative tests
e1fd607493 in qtbase removed the
qml1 imports enum from qlibraryinfo.cpp, qconfig.cpp, etc.

With the recent merge from dev, this was not adjusted in
qt_generate_qconfig_cpp, and thus we generated one too many strings
in qconfig.cpp, which resulted in
QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath) returning
"imports" instead of "qml" subfolder, thus causing all qml modules
not being found.

Fix this by removing the extra qconfig.cpp entry, and all other
references to the location.

Change-Id: I128f667281138e2e0ef0fe1ced4af0405c532fef
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-25 16:21:06 +00:00
Leander Beernaert
790d380f8b Add custom targets to generate Android APK
This patch adds two custom targets to generate android apks. The
targets are named ${TARGET}_prepare_apk_dir and ${TARGET}_make_apk. The
first one insures the binary is copied to the right location and the
latter invokes androiddeployqt on the apk directory.

Change-Id: I8152cef387b50ec03ee2bfd92b56910a6f22754c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-23 09:08:10 +00:00
Tobias Hunger
edf61092f2 QtBuild: Use STRING type for install locations
Use STRING type for install locations as we use them relative to the
CMAKE_INSTALL_PREFIX.

PATH type will get expanded to absolute paths by newer CMake versions,
so that breaks our logic.

Change-Id: I36be1f0378c4fb07ad8db0051d540f9d243000be
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-21 11:29:04 +00:00
Tobias Hunger
1c2db89027 Write out a module description file
Write out a file with some JSON data to describe a module.

This file contains information on how that module has been built.

Change-Id: I8a604692663cbb7b76b96b97124130e30b822e4b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-21 11:28:55 +00:00
Leander Beernaert
51979657a1 Add ALLOW_UNDEFINED_SYMBOLS to add_qt_plugin
Allow plugins to be built with undefined symbols when
ALLOW_UNDEFINED_SYMBOLS is specified.

Change-Id: I6bc809e3e5257302157bf8484f850d8319674a4a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-21 10:04:22 +00:00
Leander Beernaert
077ea818af Rename builtin test data resource name
Rename the builtin test data resource name to something more unique as
there are name clashes when building tests which also add a resource
named 'testdata'.

Change-Id: Icc1bbff3134e1dbc6ea4f6a87a1715b936c723cc
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-18 13:20:56 +00:00
Leander Beernaert
373be4200b Add conversion code for Java code
Add support to pro2cmake to convert java code for android.

Add support to override API_LEVEL for the Android sdk jar file. If the
sdk is not found, we'll default to the one located by QT_ANDROID_JAR.

Change-Id: If0b746dc7f9148ac43e6592a4a4dd23d46bbd4cd
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-18 13:20:46 +00:00
Simon Hausmann
7e7f41e40c Pick the latest available C/C++ standard when compiling Qt
This maps the behavior of mkspecs/features/qt_common.prf and enables the
use of C++17 for example in Android, where the toolchain supports it
anyway.

Change-Id: I41f4bdb160a3929e2fb78f36efb1ad5f2ad391a5
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-10-17 19:23:25 +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
Alexandru Croitor
4a7e7103e7 Fix precompile header usage
Latest CMake will try to compile the given precompiled headers
as C files, due to enabling the C language in the project + also
having c files.

Make sure to wrap the precompiled headers in a CXX language only
generator expression.

For details, see https://gitlab.kitware.com/cmake/cmake/issues/19839

Change-Id: Ib3508ad920092455c300b1a566ba6152bab032db
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-15 13:50:25 +00:00
Leander Beernaert
c13bafec09 Add QT_RESOURCE_TARGET_DEPENDENCY source file property
In the plugin test in QtBase we have a scenario where we have target
binaries that are inputs to add_qt_resource(). If we do not remove these
files from the dependency list for add_custom_command() cmake will
fail to generate the build files.

If we mark them as generated source files, we'd have to add a special
rule to generate them. Furthermore, using $<TARGET_FILE:...> does not
work due processing done by add_qt_resource.

To bypass this we check whether the property is set and instead of
adding the file to the dependency list we add the target referenced
in that property. RCC will still work as expected but will fail if the
files aren't present.

Change-Id: I16855a54f5606d6fe27ab1347ed7ff4f40392c98
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-15 13:46:36 +00:00
Leander Beernaert
69bb9f7cad Fix output property for add_cmake_library()
OUTPUT_DIRECTORY by itself is not a valid cmake target property.

Change-Id: Ic3a2a81b8b982ad7ccf0551000a157f9a4d3ef22
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-15 13:12:04 +00:00
Simon Hausmann
a3fd3c193d Remove compatibility code for old call sites of qlalr processing
Change-Id: I48801c336f7546b9366c70d877d20222c16dd4ff
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-15 08:39:55 +00:00
Alexandru Croitor
190e9dcdcf Regenerate files after dev -> wip/cmake merge
Note the following bigger things that had to be done:
Handle GSS library / feature with a new custom find module.
Implement rudimentary support for relocatability (does not currently
handle extprefix).

Change-Id: Ic6cd27dda7ebca9829f51cb42ea76fff6d1767ef
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-14 19:01:19 +00:00
Alexandru Croitor
1e27ad1697 Don't include header directories that don't exist
If a module is marked as NO_MODULE_HEADERS, we shouldn't
try to include the non-existing include directory which is
usually generated by syncqt.

Note it seems that NO_SYNC_QT and NO_MODULE_HEADERS seems
to converge, so it might make sense to merge them in the future.

Change-Id: Iab4e2907ed68776632337b37496b015535da8784
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-14 15:06:10 +00:00
Alexandru Croitor
7119023829 Always try to find dependencies for plugins
Generated plugin CMake files should always try to call
find_dependency, especially in static builds.

pkg_check_modules sets a cache value for foo_FOUND instead of
a directory scope foo_FOUND, which means that find_dependency
will not be called in another scope, and thus fail to create
needed imported targets.

Note this makes the code be the same as in
ModuleDependencies.cmake.in.

Change-Id: I0b58b038afcb72cb27d0b433371bc9cb5e4bfec9
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-14 15:02:52 +00:00
Leander Beernaert
6694689a26 Fix Android build from multi-arch qmake changes
Add condition replacements for the android ABIs.

Add a replacement for QT_ARCH to ANDROID_ABI, since QT_ARCH is only used
with the android build for now.

Change-Id: I553d7910546de32236f723ec2e9a05a18da76130
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-14 13:49:40 +00:00
Leander Beernaert
ecccb71d3d Fix handling of OUTPUT_DIRECTORY in add_cmake_library
extend_target() does not handle the OUTPUT_DIRECTORY argument, so we
must handle it ourselves.

Change-Id: I31880a516ae185f3255b2a51f41d61ee6b1d9838
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-11 12:18:20 +00:00
Simon Hausmann
f2d15b9683 Minor fix to qt_process_qlalr API
It's probably best to make it follow the usual calling convention that
the associated (consuming) target is the first parameter of the
function. So first this change accepts both formats.

Change-Id: I1f20706b23d5e819e0eb689eecedb3afb49df3b7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-11 12:02:08 +00:00
Leander Beernaert
1dd82a8843 Add SKIP_INSTALL to add_qt_plugin()
Provide a SKIP_INSTALL argument to add_qt_plugin for test cases with
plugins lacking install information.

Change-Id: Iddb3843fab1790d69d64686530a46057a2ff0477
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-11 09:23:13 +00:00
Joerg Bornemann
b2de87a089 CMake: Create output directory for qmlcachegen
Change-Id: I395de27bfe0eed46c595ac664b2c7218abbdb28b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-11 09:19:53 +00:00
Leander Beernaert
6167031ecc Add 'add_cmake_library' to QtBuild.cmake
Add add_cmake_library to allow us to create normal cmake targets using
all the information we have collected via the conversion script.

This function is only meant for tests. For an example,
see tests/auto/corelib/plugin/qpluginloader/lib/lib.pro.

Change-Id: I738cb8ac241b8da1a1da3ef957c24dc7a754d43f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-10 14:15:06 +00:00
Leander Beernaert
b42feb02ce Add install directory for plugins without type
When we run into a plugin that does not have a type and is not a
qml plugin, we try to see if we can find the target installation path
and provide INSTALL_DIRECTORY AND ARCHIVE_INSTALL_DIRECTORY to the
add_qt_plugin call.

We run into this frequently with the unit tests.

This patch also changes add_qt_plugin() to use the value provided in
INSTALL_DIRECTORY for ARCHIVE_INSTALL_DIRECTORY if no value is provided
for the latter.

Change-Id: I61278904a4d2d72308079cd362bd085b4e2f540c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-10 13:06:51 +00:00
Alexandru Croitor
87ba355d95 Fix automatic plugin importing in static builds
QtPlugins.cmake.in uses file(GENERATE) and target_sources() to
propagate the generated cpp files which contain plugin initialization
code to their consuming targets.

Unfortunately due to a bug in CMake, if the file is generated in a
different scope than the consuming target, the CMake generation
step will fail saying that the source file can not be found.
See https://gitlab.kitware.com/cmake/cmake/issues/18399 for details.

In the case of qtdeclarative, find_package(Qt6) is called at the top
level scope (this is when the file gets generated),
but the targets are created in subdirectory scopes, and the GENERATED
source file property is not propagated across scropes.

Circumvent the issue by instead using file(WRITE) and configure_file()
which create the file at configure time rather than generate time.

This will pollute the current binary directory with some more files,
but at least successfully fixes the build.

Change-Id: I3ab3b12dcbf6a9d0ab9ee87173e4a1952325b37b
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-10-09 09:22:27 +00:00
Jean-Michaël Celerier
d1542e8a73 Match qt_import_plugin API with qt5's
Some work was needed to make the plug-in types,
and which plug-ins are available for each type
in client code.

Change-Id: Ib71feca31069deca3d3f54c8613054f5f8ae410c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-10-09 09:05:39 +00:00
Leander Beernaert
5260c1d62a Update add_qml_module() to use INSTALL_QML_FILES
Update add_qml_module() to use the new INSTALL_QML_FILES argument from
qt6_add_qml_module().

This patch also updates pro2cmake.py to remove the QT_QML_SOURCE_INSTALL
property from qml files.

Change-Id: I6623b2de76bb55bd6750e48f7d45c53ca536b391
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-08 13:42:17 +00:00
Leander Beernaert
1a4f0e2583 Update add_qml_module to use DO_NOT_INSTALL_METADATA
Update to match latest changes to QtDeclarative.

Change-Id: Ie455c0418e95c288149b4b1a29b065a8876e8b7e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-08 13:28:20 +00:00
Oliver Wolff
e81441421b cmake: Add IOBluetooth to list of apple system frameworks
The framework is needed for qtconnectivity.

Change-Id: I6a502564fb5543ca94ba5ae458a544286e34564c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-10-01 13:41:25 +00:00
Alexandru Croitor
48699561d9 Enchance qt_find_package with opt-in debug capability
Sometimes when writing a qt_find_package and configuring a project,
you might get the following error from CMake:

CMake Error at QtBuild.cmake (set_property)
Attempt to promote imported target "WrapFreetype::WrapFreetype" to
global scope (by setting IMPORTED_GLOBAL) which is not built in this
directory.

This means that another find_package call, found WrapFreetype
in another directory scope other than the current one, and thus the
found target cat not be made global. Sometimes that implies that the
qt_find_package might not be needed if WrapFreeType will always be
found via a transitive depdendency.

By setting QT_DEBUG_QT_FIND_PACKAGE=1 on the command line, you can
make qt_find_package skip all of its behavior if the package was
already found and the provided targets were also found.

Unfortunately this behavior can not be made the default, because there
is no way to find out in what scope the package was found, and if it's
legal to make the targets global. At least I haven't found a way to do
that yet.

Thus the opt-in QT_DEBUG_QT_FIND_PACKAGE is a means to help with
debugging such cases.

Change-Id: I04242ed0f2fd0a75bc199386d28a1a0bd92da41a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-01 13:34:38 +00:00
Mårten Nordheim
ef9cef6dff Add a find_library entry for the GameController framework
Needed for QtGamepad

Change-Id: I50227949eb509c021ba8d9b4dbe2b36b6a6de87f
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-01 12:50:04 +00:00
Alexandru Croitor
0ceef4cb54 Always append extra cmake modules to CMAKE_MODULE_PATH in Qt6Config
During a static build we need to use the find modules
in 3rdparty/extra-cmake-modules/find-modules when generating a
ModuleDependencies file, so that the generated find_dependency()
calls succeed. This means that the files have to be shipped with
Qt6 package, making them pseudo public API.

There is also a need to use these files when building QtWayland.

Instead of setting / unsetting CMAKE_MODULE_PATH only in module
and plugin Dependencies cmake files, just set them once when finding
Qt6.

This will allow QtWayland and QtX11Extras to easily find the required
third party packages, without having to hardcode the paths in multiple
repos.

Change-Id: I750d0421a269e5632afa1bb62498c2501d73cdb1
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-01 12:05:59 +00:00
Jean-Michaël Celerier
309f96ccb6 Add CMake support for directfb plug-in
Change-Id: I126545e1da54018ce081b42a29e62ca30ee04d64
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-30 11:31:54 +00:00