Commit Graph

332 Commits

Author SHA1 Message Date
Alexandru Croitor
0bfbe10ff2 CMake: Implement proper exclusion of tools including installing
The previous approach didn't work for prefix builds. While a target
might be excluded from building via EXCLUDE_FROM_ALL property, when
calling make install it would still try to install the target and
thus fail.

It's not possible to modify an install() command in a post-processing
step, so we switch the semantics around.

pro2cmake will now write a
qt_exclude_tool_directories_from_default_target() call before adding
subdirectories. This will set an internal variable with a list
of the given subdirectories, which is checked by qt_add_executable.

If the current source dir matches one of the given subdirectories,
the EXCLUDE_FROM_ALL property is set both for the target and the
qt_install() command.

This should fix the failing Android prefix builds of qttools.

Amends 622894f96e

Change-Id: Ia19323a2ef72a3fb9cb752ad2d4f2742269d11c4
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-04-07 23:22:33 +02:00
Joerg Bornemann
c356380154 CMake: Remove special handling of the 'static/shared' features
configurejson2cmake handles the 'static' and 'shared' features now.
There's no need to special-case it anymore.

Change-Id: I956e9f46ebe022b1da862e986ec05f41e1e804e0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-04-06 21:43:18 +02:00
Joerg Bornemann
2ea4320bf7 CMake: Remove special handling of the 'rpath' feature
configurejson2cmake handles the 'rpath' feature now. There's no need
to special-case it anymore.

Change-Id: I9aa9c9acdeb586de09d8a8d269909f8acb02e40a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-04-06 21:42:37 +02:00
Alexandru Croitor
430232e44d CMake: Adjust PCH support for multi-arch iOS builds
Starting with CMake 3.18, there is PCH support for darwin multi-arch
builds, like iOS simulator_and_device builds.

Also enable PCH for Objective-C++ files when the support is there.

To enable PCH for Objective-C++, we need to do enable the OBJCXX
language as well, but conditionally, because on non-darwin platforms
the language is probably not available.

Introduce the qt_enable_cmake_languages() macro which is called
automatically by qt_build_repo_begin().

Change-Id: I0e7f44be6577ac54ce940470036626409920e272
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-04-03 21:51:06 +02:00
Samuli Piippo
af6f3cb317 qt_record_extra_package_dependency: check that target exists
The target may not be defined which causes error:
get_target_property() called with non-existent target "qtwaylandscanner".

Change-Id: I58a9122456ccbbbb8fc9f0adce3b7ddcc985e6a4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-04-03 08:15:55 +03:00
Alexandru Croitor
0cdb4b20d3 CMake: Remove HEADER_MODULE handling from 3rd party libs
Installing headers is not supported for 3rd party libs (we don't run
syncqt, we don't install headers for 3rd party libs to
prefix/include).

Remove the unnecessary condition.

Change-Id: I46e9af7a7ca9de0138666b0d0faffc86238672ba
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-04-02 10:00:23 +02:00
Alexandru Croitor
6fdeaea24f CMake: Don't try to add 3rd party includes to ModuleDepends files
When creating the include/QtShaderTools/QtShaderToolsDepends file
in QtPostProcess.cmake -> qt_internal_write_depends_file(),
we decide which include files to append based on link dependencies
starting with Qt::, which happens to match 3rd party targets like
Qt::BundledSpirv_Cross which doesn't expose headers in the
prefix/include dir.

Mark all bundled targets with the QT_MODULE_SKIP_DEPENDS_INCLUDE
property to exclude them from being added to Depends files.

This should fix static builds of qtquick3d which includes
<QtShaderTools/QtShaderToolsDepend> which tries to include a
non-existent <QtBundledSpirv_Cross/QtBundledSpirv_Cross>.

Change-Id: I9dcff1e2ab721a7c21fcff3fda0faf8d023d60ba
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-04-02 10:00:20 +02:00
Alexandru Croitor
84a7f0d3d7 CMake: Don't use escaped plugin type for on-disk directories
The path where we install plugins is usually
prefix/plugins/plugin_type/plugin_name

The plugin_type should not be escaped, so it should be used verbatim
(no escaping of slashes or dashes)..

So far it seems the only weird plugin types are wayland plugins which
contain dashes, like wayland-shell-integration, and the sub-ios plugin
which has a slash (platforms/darwin).

For cmake properties we use the escaped names.
This should fix tests in wayland where the wayland plugins can't be
found.

Change-Id: I93406731b8c872a82c0f247f5b7c6bdab4875455
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-04-02 09:39:41 +02:00
Alexandru Croitor
622894f96e CMake: Allow excluding tools and apps from the default 'all' target
Qt uses the qtNomakeTools() function to mark a directory which will
not be built as part of the default target. This is especially
important when cross-compiling (to iOS for example) because the build
process might fail.

The condition for not building these "GUI tool sub-directory projects"
is the absence of the "tools" value in qmake's QT_BUILD_PARTS
variable.

Introduce a QT_NO_MAKE_TOOLS CMake variable. If the value is true,
it's equivalent to "tools" not being present in QT_BUILD_PARTS.

Introduce qt_exclude_tool_directories_from_default_target().
It's the qmake counter part to qtNomakeTools().

Teach pro2cmake to generate it where appropriate.

Change-Id: If2e5958d91847ab139af0e452608510286e73fa0
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-04-02 09:39:36 +02:00
Alexandru Croitor
8c0fc9264f CMake: Don't generate docs for targets that don't exist
Such a case can happen when cross-compiling. Tools currently are not
built when cross-compiling, so if the desktop tool was not built,
accessing properties on that target would fail when trying to set up
the documentation building.

Change-Id: I2ffcbb9623df3e4daacdf4be3f48c4b2dd13851b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-04-02 09:39:21 +02:00
Alexandru Croitor
089a602a76 CMake: Fix usage of CMAKE_CROSSCOMPILING
Change-Id: I9557f44c4d99c8591d41512e9705791d77eb0eb3
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-04-02 09:39:18 +02:00
Joerg Bornemann
e0b89899e3 CMake: Fix qt_lib_XXX.pri files for modules with CONFIG_MODULE_NAME set
The function qt_generate_module_pri_file did not take into account the
CONFIG_MODULE_NAME argument of qt_add_module.
This resulted in wrong file names and content, e.g. qt_lib_test.pri
instead of qt_lib_testlib.pri.

Fixes: QTBUG-83176
Change-Id: Id6991396cf9ea5a1d155aa15402c0d84a8a9d082
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-03-30 14:54:16 +02:00
Joerg Bornemann
c269d8f086 CMake: Fix the re-computed value of INSTALL_*DIR variables
For INSTALL_*DIR variables that have the the same value as
CMAKE_INSTALL_PREFIX, a second cmake run cleared the value. This is
because file(RELATIVE_PATH) returns the empty string if we pass the same
absolute paths.

Fix this by checking the return value of file(RELATIVE_PATH) for the
empty string and setting it to ".".

It's a limitation of qmake that empty strings are not handled as ".".

Change-Id: I8fc4d1eabcc9d5634be2f3741b0002a347dd17e6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-25 11:16:48 +01:00
Alexandru Croitor
7c04c5427f CMake: Fix creation of forwarding headers to be at configure time
qt_add_module checks for the existence of the following directory
include/QtFoo/6.0.0/Foo when deciding whether a private module target
should contain that path in its INTERFACE_INCLUDE_DIRECTORIES.

There are 2 cases when it's created, when running syncqt, and inside
qt_install_injections. If syncqt doesn't create it because there are no
private headers (like in qttools/src/global), qt_install_injections
created it at generation time (for injected configure headers like
qttools-config_p.h)

Unfortunately that caused the existence check mentioned above to fail,
not exporting the path in the QtToolsPrivate's include directories,
and failing the qttools build.

To fix that, create the injection files (and directories) at configure
time, using qt_configure_file instead of file(GENERATE).

Change-Id: Idd9b6ec36e986c4de95d11557170e1c70927211c
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-23 09:55:00 +01:00
Alexandru Croitor
e510a4e327 CMake: Introduce qt_configure_file
It has the same kind of signature as file(GENERATE) but
creates the files at configure time rather than generation time.

CMake provides a few ways to generate files
file(WRITE) -> always overrides content
configure_file() -> only overrides if content changes, creates file
                    at configure time, can only take a file as input
file(GENERATE)   -> only overrides if content changes, creats file
                    at generation time, can take a string or file
                    as input

Because dealing with an input file is a hassle (need to create one,
make sure it's installed, make sure it's used correctly in the
various build types like super-build, non-prefix-build, etc)
people tend to use file(GENERATE) instead, which can take a string
argument, and is thus easier to use.

Unfortunately that introduces subtle bugs because the
file is created at generation time, but there are existence
checks which are done at configuration time.

Thus qt_configure_file allows creation of files at configure time,
without having to provide an input file. Underneath it uses
configure_file(). Once CMake 3.18 is released, the implementation
can be switched to use file(CONFIGURE).

Change-Id: Ic8f8d88541ef0b25d01af143352c8c9ba390ad5f
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-23 09:54:56 +01:00
Alexandru Croitor
edf5fe49b3 CMake: Add global / top-level docs targets
Previously you could use either module-specific or
repo-specific 'docs' targets.
For example 'ninja html_docs_qtbase' or 'ninja html_docs_Core'.

Now there's a global / top-level target called
'docs', so 'ninja docs' works.

For super builds it will build the documentation of all
configured repositories.

For a single repo build, it's equivalent to calling
'ninja docs_repo_name'.

Also for consistency, add the "docs_Core" target, which was missing
before. So now a 'docs' target exsits for repo names AND targets.

New global target names are
- docs
- prepare_docs
- generate_docs
- html_docs
- qch_docs
- install_html_docs_docs
- install_qch_docs_docs
- install_docs_docs

Amends 0095ff4e06

Change-Id: I686be1e0962e40cbce860e8ac2cabb056b360ac2
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-18 17:25:15 +01:00
Leander Beernaert
1b7008a3d7 CMake: Fix Windows VM Test Runs
Simplify the handling of simd specific sources. The previous
implementation was causing simd instructions to bleed into the main
library.

The tests were failing because the avx instruction were leaking into
Qt6Gui due to the previous problem. This in turn caused any test which
required Qt6Gui code run to crash since it is not possible to run avx
instruction in the VMs.

This patch also disables PCH for the simd sources as they result in
warnings related related to using PCH header not compiled for the
architecture in question. The latter can cause the build to fail in
conjunction with warnings as errors.

Change-Id: I1be98f2f5e967f33793d6a2e6134a24ef1709566
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-03-16 17:30:38 +01:00
Alexandru Croitor
6e286247e8 CMake: Don't make a private module depend 1kk times on the public one
The exported INTERFACE_LINK_LIBRARIES property now looks a lot more
sane.

Change-Id: I093fcb242607023dd0b103298562b299cb803028
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-13 19:14:55 +01:00
Alexandru Croitor
5804473578 CMake: Propagate minimum required C++ standard to consumers of Qt
Aka the version of C++ that needs to be supported when compiling
applications that use Qt headers (C++17 at the moment).

Change-Id: I64dec297e8329f31b1d9864f216a95782049ed06
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-12 11:41:32 +01:00
Alexandru Croitor
37714de9a6 CMake: Remove code for old 3rdparty mechanism handling
The only two uses (QtHarfbuzz and QtDoubleConversion) have been removed,
so now the code is not needed anymore.

Change-Id: Id9ef628fa139f1431395bcdd1705463dfafb1051
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-10 07:33:20 +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
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
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
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
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
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
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
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
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
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
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
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
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
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