Commit Graph

155 Commits

Author SHA1 Message Date
Alexandru Croitor
b1f8ca8032 CMake: Fix various issues with the Android build
Certain resources and compiled jar files have to be copied into the
non-prefix build dir location. They were previously only installed,
which doesn't do anything in a non-prefix build.

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

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

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

Task-number: QTBUG-85399
Change-Id: I4ac9d3929ea8ecc95ec99a77e621ad2121b68832
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-07-09 11:56:31 +02:00
Alexandru Croitor
f3c7d22dd0 CMake: Don't use libraries in /usr/local by default on macOS
qmake builds of Qt don't use libraries in /usr/local because the
path is not considered a system path. Only the SDK path should be
used as a source of system libraries.

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

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

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

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

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

Implementation notes

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

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

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

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

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

Fixes: QTBUG-85261
Change-Id: I28fe5bae7997507a83b37b4eb1e0188e64062c57
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-06-29 17:34:22 +02:00
Alexandru Croitor
2efd0fbc32 CMake: Add meta-target host_tools to easily build just the tools
A developer could write 'ninja host_tools' to build the qtbase tools
and their dependencies, and then configure another cross-compiling
build dir pointing to the previous host build. This shortens the
workflow for cross-building when working in qtbase.

Change-Id: I69e70d23ce9df8669bcadf326d0586f097e5cb21
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-26 22:14:29 +02:00
Alexandru Croitor
2d9c9ab874 CMake: Don't reset install prefix upon standalone test reconfiguration
CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT might be empty on the
first configuration, but because QtBuildInternalsExtra sets the
CMAKE_INSTALL_PREFIX, a second reconfiguration of a test would
stop setting the fake install prefix.

After some further consideration, there's no need to set the local
fake prefix conditionally, we can always do it (unless explicitly
opted out).

This makes sure that a reconfiguration of a test doesn't suddenly
install into the Qt prefix again.

Amends 37b132cd4e

Task-number: QTBUG-84346
Change-Id: Ic61aefe18418658455d8cdb9ebe6bcbcb8d67c99
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-06-08 18:25:51 +02:00
Jean-Michaël Celerier
35608c0761 cmake: quote paths to prevent issues when no install prefix is set
Change-Id: Ifa7f1ef70c4893e10cb4ce9a54d8a0806d19be93
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-05 20:57:32 +02:00
Alexandru Croitor
37b132cd4e CMake: Fix standalone tests to work properly on reconfiguration
And also fix qt-cmake-standalone-test to work for prefix builds.

The gist of it is that we have to protect tests not to be installed
into the Qt install prefix, but we also have to make sure that the
CMAKE_INSTALL_PREFIX is not changed globally (via cache value),
so that reconfiguration still works.

This took way too long to figure out.

Amends d6272d774c

Fixes: QTBUG-84346
Change-Id: I18c29574c9957fe05b86f701c8c14ec07e0f045b
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-06-04 22:28:06 +02:00
Alexandru Croitor
bf315c5526 CMake: Make build system of installed Qt more relocatable
Aka handle CMAKE_INSTALL_PREFIX in a more relocatable way.

The following story inspired this change.

If a user wants to build a Qt repo into a different install prefix
than the usual Qt one, this will fail configuration because we
look for various things like syncqt, qdoc, etc relative to
CMAKE_INSTALL_PREFIX, which will now point to a different location
where none of the above tools are located.

The intent for such a use case is to support building Qt packages with
Conan, which sets a random install prefix when configuring a repo.

The idea is to derive the qt prefix dynamically from the
QtBuildInternals package location. Essentially it's a reverse relative
path from the QtBuildInternalsConfig.cmake file to the install prefix
that was specified when initially configuring qtbase.

Once the dynamic prefix is computed (so we know where the possibly
relocated Qt is), we can find tools like syncqt and qdoc.

This is an initial attempt to support a use case like that.

More design work will probably needed in case if tools / libs need to
be found in a location different than the Qt install prefix (so
support for multiple install prefixes / search paths).

An example of such a case would be when building qtdeclarative and
qtquickcontrols2 as Conan packages in one go. Most likely the
qmltyperegistrar tool will be located in the random install prefix
set by Conan, so building qtquickcontrols2 might fail due to not
finding the tool in the original Qt install prefix.

As to the implementation details, the change does the following:
- Dynamically computes and sets the
  QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX variable when
  find_package()'ing QtBuildInternals. It's an absolute path
  pointing to where the relocated Qt is.

- When building qtbase this variable is not yet available (due
  to QtBuildInternalsExtra not existing), in that case we set
  the variable to the absolute path of CMAKE_INSTALL_PREFIX
  (but only for the initial qtbase configuration).

- Remove QT_BUILD_INTERNALS_ORIGINAL_INSTALL_PREFIX which was used
  for standalone tests purposes. It's not needed now that we compute
  the location of the Qt prefix dynamically.

- The Unixy qt-cmake and qt-cmake-private shell scripts now
  use a relative path to find the toolchain file we created.

- The toolchain file also dynamically computes the location of the Qt
  packages, and adds them to CMAKE_PREFIX_PATH.

- A lot of existing CMAKE_INSTALL_PREFIX uses are replaced with
  QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX. This includes finding
  tool locations, mkspecs dir, path environment setup for tools, etc.

- Some places still use CMAKE_PREFIX_PATH in the following cases
  - When determining paths while configuring qtbase (valid cases)
  - When I wasn't sure what the behavior should be, so I left them
    as-is (an example is documentation generation, do we want to
    install it into the random Conan prefix, or into the main prefix?
    Currently it installs in the random prefix).

Note that relocating a Qt installation does not work for non-prefix /
non-installed builds, due to hardcoded paths to include directories
and libraries in generated FooTargets.cmake files.

Task-number: QTBUG-83999
Change-Id: I87d6558729db93121b1715771034b03ce3295923
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-05-07 15:41:16 +02:00
Venugopal Shivashankar
f3bfee0cb6 CMake: Fix the setup for html_docs and qch_docs
Traditionally, these make targets generated HTMLs
and QCH only. This change fixes the dependency for
these targets to ensure that behavior.

Fixes: QTBUG-83877
Change-Id: Ic7c8afe5853d33fc4cc4cfd996f87e5f65df31ed
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2020-04-30 08:15:36 +00:00
Alexandru Croitor
39090ea15c CMake: Fix usage of correct install prefix for standalone tests
Previously configuration of standalone tests might have failed
due to CMake trying to create files in the /usr/local default
prefix.
Make sure to use a fake prefix in the binary dir instead,
unless another prefix is explicitly specified.

Change-Id: Icfcb32285aa5596abf1a918396b26673880a8d27
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-04-30 10:13:18 +02:00
Leander Beernaert
43031d98fc CMake: Allow sqldriver plugins to be built as standalone
This patch allows all the sqldrivers to be built as a standalone project.
It is not possible to build each plugin separately due to the configuration
features definition being located in the sqldriver's folder CMakeLists.txt.

In other words, the project needs to be generated from the
src/plugins/sqldrivers/CMakeLists.txt file.

Fixes: QTBUG-82962
Change-Id: If41c7e3827589391830a894a9c998d2e56239562
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-04-24 07:41:13 +02:00
Leander Beernaert
6fbeef4c6b CMake: Add qt6_add_plugin public API
This patch adds a publicly callable qt6_add_plugin() API to create
plugins. This API is meant to cover cases such as the plugandpaint
example.

This patch also renames qt_add_plugin to qt_internal_add_plugin in order
to avoid clashes with the public API. To avoid breaking the existing
projects, a compatibility wrapper function is enabled by default unless
QT_DISABLE_QT_ADD_PLUGIN_COMPATIBILITY is specified.

Fixes: QTBUG-82961
Change-Id: If5b564a8406c90434f1bdad0b8df76d3e6626b5f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-04-22 09:51:12 +02:00
Alexandru Croitor
d6272d774c CMake: Make sure not to use the Qt prefix for standalone tests
We don't want people accidentally installing tests into the
Qt prefix.

Change-Id: Ic99492559875f753897a83af162253cac846a8a5
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-04-17 15:59:33 +02:00
Alexandru Croitor
67ee92f4d8 CMake: Handle automatic rpath embedding correctly
Instead of using CMAKE_INSTALL_RPATH to embed an absolute path
to prefix/libdir into all targets, use the more sophisticated aproach
that qmake does.

For certain targets (modules, plugins, tools) use relative rpaths.
Otherwise embed absolute paths (examples, regular binaries).
Installed tests currently have no rpaths.

On certain platforms rpaths are not used (Windows, Android,
iOS / uikit).

Frameworks, app bundles and shallow bundles should also be handled
correctly.

Additional rpaths can be provided via QT_EXTRA_RPATHS variable
(similar to the -R option that configure takes).

Automatic embedding can be disabled either via QT_FEATURE_rpath=OFF
or QT_DISABLE_RPATH=ON.

Note that installed examples are not relocatable at the moment (due
to always having an absolute path rpath), so this is a missing feature
compared to qmake. This is due to missing information on where
examples will be installed, so a relative rpath can not be computed.

By default a Qt installation is relocatable, so there is no need to
pass -DQT_EXTRA_RPATHS=. like Coin used to do with qmake e.g. -R .

Relative rpaths will have the appropriate 'relative base' prefixed
to them (e.g $ORIGIN on linux and @loader_path on darwin platforms).
There is currently no support for other platforms that might have a
different 'relative base' than the ones mentioned above.

Any extra rpaths are saved to BuildInternalsExtra which are re-used
when building other repositories.

configurejson2cmake modified to include correct conditions for the
rpath feature.

It's very likely that we will need a new qt_add_internal_app()
function for gui apps that are to be installed to prefix/bin.
For example for Assistant from qttools. Currently such apps
use qt_add_executable().
The distinction is necessary to make sure that relative rpaths are
embedded into apps, but not executables (which tests are part of).

Amends e835a6853b

Task-number: QTBUG-83497
Change-Id: I3510f63c0a59489741116cc8ec3ef6a0a7704f25
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-04-17 15:59:25 +02:00
Alexandru Croitor
23be07c2d0 CMake: Autodetect Objective-C support only on macOS
On Android, check_language() reports that the languages are supported,
but enable_language fails afterwards.

On Linux it causes issues with the PCH. The PCH file might contain
a Clang pragma, even though the C++ compiler is GCC. Presumably due
to finding a Clang Objective-C compiler.

Change-Id: I1b4c54459772c089e7f6350872c87af52ad72a37
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-04-07 13:04:06 +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
Alexandru Croitor
1f442c684f CMake: Provide script to configure and build one or more tests
Before this patch there were a few ways to build tests
- Configure all tests as part of the repo build
- Configure all tests as part of the repo build, but don't build
  tests by default (-DQT_NO_MAKE_TESTS=ON)
- Configure all tests as a standalone project in a separate build
  dir using -QT_BUILD_STANDALONE_TESTS=ON

All of the above incur some time overhead due to the necessity
of configuring all tests.
Sometimes you just want to build ONE test (or a few).

To facilitate that use case, a new shell script called
bin/qt-cmake-standalone-test(.bat) can now be used to configure
and build one or more tests.

The script takes one single argument pointing to the desired test
project path and configures a generic template project that sets up
all the necessary Qt CMake private API, afterwards calling
add_subdirectory on the passed in project.

Example
$ path/to/qt/bin/qt-cmake-standalone-test ./tests/auto/gui/image/qicon

or

$ path/to/qt/bin/qt-cmake-standalone-test ./tests/auto/gui/image

After that, simply run 'ninja && ctest' to build and run the test(s).

This is the CMake equivalent of calling qmake on a test .pro file
(or on a tests SUBDIRS .pro file)

There are 3 details worth mentioning.

Due to the add_subdirectory call, the built artifacts will not
be in the top-level build dir, but rather in a nested build_dir.

The script currently can't handle more than one argument
(the path to the project), so you can't pass additional
-DFoo=bar arguments.

If a test uses a 3rd party library (like Threads::Threads)
which was not a public dependency for any of the Qt modules,
configuration will fail saying that the target was not found.
Perhaps we should consider recording these packages when
generating the StandaloneConfig.cmake files.

Change-Id: Icde6ecb839341d34f341d9a19402c91196ed5aa0
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-23 09:54:48 +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
Alexandru Croitor
60a93a15b1 CMake: Fix incorrect argument in QtBuildInternalsAndroid
Uncovered while building qtdeclarative.

Change-Id: If1a36f2640a3a5d765e7ca74b0ba1d39ef2a18f0
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-12 11:41:46 +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
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
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
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
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
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
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
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
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
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
Alexandru Croitor
981cfe7d79 Include QtPlatformSupport as part of find_package(Qt6BuildInternals)
This is needed because the ported over requires() clauses from qmake
to CMake are executed before qt_repo_build(), which means that all the
custom platform variables that we set (like LINUX, APPLE_OSX) need
to be available immediately after finding BuildInternals.

Change-Id: I7345b69edf72c266508846766e64f42c99862d1d
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-27 08:42:18 +00:00
Joerg Bornemann
204765ba49 cmake: Include repo-specific setup files
This is useful for providing private CMake API which is not part of
QtBase. Also, fix the setup files to be included when building
standalone tests. The old ${PROJECT_NAME}Setup.cmake file inclusion will
be removed once all usages are adjusted.

Prompted-by: Alexandru Croitor <alexandru.croitor@qt.io>
Change-Id: I5bc2bca7371660c00b0301e94d025a29b68d6975
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-23 06:11:18 +00:00
Alexandru Croitor
ffe0889413 Fix examples find_package calls to work in prefix builds
To build examples as part of a non-installed Qt prefix build,
not-yet-installed Config files need to be found by find_package()
calls inside example projects.

Facilitate that by propagating the CMAKE_PREFIX_PATH and
QT_EXAMPLES_CMAKE_PREFIX_PATH paths in all relevant find_package()
calls where NO_DEFAULT_PATH is used.

Also adjust the inclusion of the QtFeature.cmake file to be relative
to the qt6 directory, rather than the current list directory.
This is needed to successfully find the file when parsing a Config
file from a non-installed build directory.

Change-Id: I36031279628f1f7741d8f4d7571484a6545227f7
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-21 13:10:37 +00:00
Joerg Bornemann
d8647910bc cmake: Init uic only if Qt::Widgets is a target
Otherwise we get errors like the following in non-gui projects:
  Error evaluating generator expression:
    $<TARGET_FILE:Qt6::uic>
  No target "Qt6::uic"

Change-Id: I8a3a6f8ec5e5c1c3d1f73369c5739a321c64bfbb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-20 13:52:00 +00:00
Alexandru Croitor
a0e3c1b399 Print build instructions when configuring qtbase
This is similar to how we show the instructions when configuring
in qmake land.

Change-Id: Iabd28acc3d74fd0175eab812a412744dac89e6f6
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-17 17:13:38 +00:00
Alexandru Croitor
6c00d9075e Use $$source_path/qtbase/cmake modules when doing non-prefix builds
This is similar to qmake, where the .prf files from the source
location of qtbase/mkspecs are used in a non-prefix build.
This means that if a developer changes the source QtBuild.cmake,
and then runs make in qtdeclarative, cmake will reconfigure
qtdeclarative because the timestamp of QtBuild.cmake changed.

Before this change you first had to make && make install in the
qtbase build directory, before qtdeclarative saw the modified
QtBuild.cmake.

This change also makes the module paths be prepended to
CMAKE_MODULE_PATH instead of appended, which means they will
take precedence to any path provided via command line.

Change-Id: I9178d5183a95b3b67bfe1b1fe91d3d3371ffe5c5
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-06 09:33:38 +00:00
Leander Beernaert
3f8ba1e55e Disable Examples in static build
Do not build examples in static builds as they are not prepared
for this configuration.

Change-Id: Ia0fd0a6cdfa3733bf13eb2ca8398668f26c0bedf
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-03 12:02:20 +00:00
Alexandru Croitor
a5cdca8033 Decide whether to build tools when doing a standalone test build
Needed for qtdeclarative standalone tests.

Change-Id: Ie012528d0d553cb63c2d79f3ded35e45872ee89a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-09-02 09:03:16 +00:00
Leander Beernaert
eeffac526e Update Android build configuration
Update Android build configuration to be compatible with the multi-arch
android build patch to qmake. We can now build and generate the apk
correctly. Executing on the device/simulator will only work once the
latest changes from 5.14 have been merged in.

We now replace target suffix with ${CMAKE_ANDROID_ARCH_ABI}.[so|a] so
we don't have to deal with handling targets which might have any of the
OUTPUT_NAME properties set.

The dependency and deploy settings generation has also been updated to
append the file contents to a string and then do a single file write
at the end.

Change-Id: Id3c5bd0428141ecaf962124a100390e3a4e41feb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-30 12:10:26 +00:00
Leander Beernaert
add4c4816c Add missing qml-root-path for Android
Add missing qml root path variable in the deployment configuration file.
Not having this variable will cause androiddeployqt not use the
qml dependency scanner to package all relevant dependencies.

This patch also fixes QT_ANDROID_BUNDLED_FILES files not being
processed.

Change-Id: I5bca33cdbb57098f283b38516b777571806da9e5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-28 12:29:12 +00:00
Leander Beernaert
3cb9ee3a5b Fix Android build for other Qt modules
Install missing QtBuildInternalsAndroid to installation path.

Change-Id: I6141ff72b57a6445f1718bc17d64a7ed59a91620
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-16 15:58:38 +00:00
Leander Beernaert
2c7ccfefed Perform check for tool builds before src
Perform the test whether tools should be built before entering the
source directory of a project. In QtDeclarative this would result in
a configuration error since the tools are used while building everything
under src.

Change-Id: I33ce2cb317ef221836d696654f3bb4e39db47e54
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-07 08:28:27 +00:00
Leander Beernaert
a9d2c5b6d7 Android: Final changes for APK generation
Generate the ${MODULE}-android-dependencies.xml for the androiddeployqt
tool. This will ensure all the right plugins and dependencies are
packaged when generating the apk.

This change also changes the visibility for executable to default/public.
Not having this will cause the application to crash as we can't locate
main() in the executable (shared library).

Additionally pro2cmake conversion script has been updated to perform
the required conversions for the Android settings.

Finally, the 6 projects in QtBase that have Android dependencies have
been updated with the new script and the step that produces the xml
files in run at the end in QtPostProcess.cmake.

Change-Id: I9774ba1b123bc11cae972fa37054ef2c51988498
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-06-26 08:34:37 +00:00
Alexandru Croitor
fe3bd212fc Merge remote-tracking branch 'origin/wip/qt6' into wip/cmake
This changes many different CMake places to mention Qt6 instead of
Qt5.

Note that some old qt5 cmake config files in corelib are probably not
needed anymore, but I still renamed and kept them for now.

Change-Id: Ie69e81540386a5af153f76c0242e18d48211bec4
2019-06-14 16:31:09 +02:00
Alexandru Croitor
cfcd50875b Try to find Test package before calling add_subdirectory(src)
in qt_build_repo().

This is important for qtdeclarative for example, which builds QmlTest
functionality in ./src, and thus needs Test lib to be available.

Change-Id: I84326d79844526f2f177c19de30bab0c858773e3
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-06-13 14:59:55 +00:00
Alexandru Croitor
bb959af00a Automatically find apple frameworks when building a repo
Instead of doing it just in qtbase/src, we need to do it
for all repos before building ./src.

Change-Id: I57f226b849cd5370ffbbbea8a694697d400957a4
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2019-06-13 14:25:02 +00:00
Simon Hausmann
6732fa3a29 Fix linking of examples
Provide add_qt_gui_executable() as function in our public API that takes
care of automaticWinMain linkage. We can use this in the future to
encapsulate similarplatform-specific behavior and adjustments, such as
module generation onAndroid.

In order for the examples to see the function in Qt5CoreMacros, three more
additional fixes were required:

    * Do the build_repo_end() call _before_ attempting to build the
      examples, as we need the build_repo_end() to include QtPostProcess
      and complete the creation of all the target config files.
      Otherwise the find_package() calls in the examples see something
      incomplete.

    * Add more QT_NO_CREATE_TARGET guards

    * Always call find_dependency on the dependencies, regardless of the
      target creation mode. This way a find_package(Qt5 COMPONENTS
      Widgets) will still load Qt5CoreMacros.

Change-Id: I03ce856e2f4312a050fe8043b8331cbe8a6c93e6
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-06-12 14:19:34 +00:00
Alexandru Croitor
aa956e0822 Change qt_build_repo to build tools if present and needed
This is needed for qtdeclarative, to automatically start building
the tools if needed.

Change-Id: I3cbe129e8bb6fa8572a8e34fd3653b51727cb244
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-06-07 09:49:05 +00:00
Leander Beernaert
053766d796 Fix Standalone Example build when crosscompiling
Added qt_examples_begin() and qt_examples_end() macros to setup the
example list so it can be re-used in other projects.

When cross-compiling, we also need to set
CMAKE_FIND_ROOT_PATH_MODE_PACKAGE to BOTH in order for find_package()
to work correctly.

Removed support for building the whole qtbase/examples folder as a
standalone project. Building examples is only supported when building
the whole of qtbase (qtbase + examples together) or each individual
example is built separately against an installed Qt version.

Change-Id: I9d26b94b48b95af230b76ab618becb21d2d45581
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-06-06 12:27:41 +00:00
Kevin Funk
e99f4a5c89 cmake/ does not necessarily exist in a module
E.g. qtsvg does not have a cmake/ folder

Change-Id: I216776a4997709222064aa76195a32e7bdb6b080
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-06-05 14:39:39 +00:00
Alexandru Croitor
9864ff22aa Optionally include ${repo}Setup.cmake file in qt_build_repo_begin
This is meant to keep repo specific functions and macros that should
not pollute QtSetup.cmake. For example QtDeclarativeSetup.cmake
will automatically be included when building qtdeclarative.

Change-Id: I4d26cbb1a7ffafb153a888fc918af337000d5e41
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-05-28 17:03:55 +00:00
Alexandru Croitor
3122e7c01a Fix qt_build_repo to be more robust
Check for the existence of CMakeLists.txt files before trying
to call add_subdirectory on examples, tests and src folders.

Change-Id: I7be76de5f7520c1dd181c610fd1dc2200ac74672
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-05-28 17:02:38 +00:00
Alexandru Croitor
c7fd10a022 Allow building the tests directory as a standalone CMake project
At the moment, Coin builds tests as a separate qmake invocation
against an installed Qt. We need to support the same with CMake.

Change the tests subdirectory to be a standalone CMake project when
CMake does not detect an existing QtTest target while processing the
subdirectory. If the target exists, it means we are building the whole
repo, if the target does not exist, we need to call find_package
to find the installed Qt.

Refactor and move around a few things to make standalone tests build
successfully:
- add a new macro to set up paths to find QtSetup
- add a new macro to find all macOS frameworks
- add a new macro to set up building tests
- add a new macro that actually builds the tests
- export the INSTALL_CMAKE_NAMESPACE value into the BuildInternals
  Config file
- export the CMAKE_BUILD_TYPE value, because a test project doesn't
  have a .git subdir and thus defaults to be built in Release
  mode, even though qtbase might have been built in Debug, so to
  avoid the mixing, the propagate the build type
- stop overriding INSTALL_CMAKE_NAMESPACE and
  QT_CMAKE_EXPORT_NAMESPACE inside QtSetup if they are set, because
  the tests project doesn't specify a major version, and if we
  override the values, the moc / uic targets don't get the correct
  major version prefix and configuration fails

Change-Id: Ibdb03687302567fe325a15f6d1cb922c76240675
Fixes: QTBUG-75090
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-22 11:12:54 +00:00
Simon Hausmann
d61ca95fc0 Simplify top-level CMakeLists.txt for modules
Implement some aspects of qt_parts.prf to simplify the top-level
CMakeLists.txt for repositories that follow the common qt structure
(src, tools, tests, examples).

Change-Id: Ia35f4e9207e92c1cf0406353561b0cc52dcb0e59
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-21 08:05:44 +00:00
Alexandru Croitor
a859cb508c Automatically install repo specific cmake find modules
Some qt modules need to find 3rd party packages for which there
are no Config files. We need to write custom CMake Find modules to
find those packages. These find modules need to be installed so that
they are used when a user consumes the Qt packages.

Automatically include and install these find modules if they exist,
as part of qt_build_repo_end().

Change-Id: I14aad35ed2999cac8bdda65ca4aeaf74d04fdb71
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2019-05-20 13:48:16 +00:00
Alexandru Croitor
9542e78525 Use the qt_build_repo() macros for building qtbase as well
To implement this, create a new Qt5BuildInternals package.

All child Qt modules like qtsvg should use
find_package(Qt5BuildInternals) or
find_package(Qt5 COMPONENTS BuildInternals) in the their
top level CMakeLists.txt.
This will make the qt_build_repo() macros available.

For qtbase we slightly cheat, and specify a CMAKE_PREFIX_PATH
pointing to the source folder that contains the BuildInternals
package.

For the other modules we actually use a configured and installed
package Config file.

This change moves variables that used to be written into the
QtCore Config file into the BuildInternals package. This way
things that are relevant only for building additional Qt modules
does not pollute the QtCore package.

Task-number: QTBUG-75580
Change-Id: I5479adff2f7903c9c2862d28c05c7f485ce3e4eb
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-15 17:33:51 +00:00