Commit Graph

573 Commits

Author SHA1 Message Date
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
7909de1beb CMake: Define QT_STATIC for static builds
QT_STATIC must be defined for static builds to have the right
import/export symbol macros defined. Originally, this macro is wrapped
in a condition. That's why we extend qt_feature_definition to be able
to write a prerequisite to qconfig.h.

Change-Id: I610e60acc7f5bdc031eff6d53a76e0b229a5c8c2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-04-01 21:19:35 +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
Leander Beernaert
9968a211f9 CMake: Fix pkgconfig calls when cross-compiling
When cross-compiling with CMake, before this patch pkgconfig calls would
find libraries which are part of the host system and not the target
system.

The current approach used is based of the discussion present in
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4478, and should
be considered a temporary solution until the issue is properly addressed
in upstream CMake.

Change-Id: I535d4d48c2a5d34689082b80501b3b6ae30d7845
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-26 12:46:16 +01: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
0446bf5ba3 CMake: Fix auto-detection of precompiled header support
PCH files were only used while building qtbase. Make sure the value
is exported to the BuildInternalsConfig file, so the value is re-used
when building other repositories.

Also disable PCH when building simulator_and_device iOS builds, because
CMake doesn't currently generate separate PCH files per architecture.

Change-Id: I79955ebc557b800bc3c704deac519fe80012c229
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-25 10:46:46 +01:00
Alexandru Croitor
67af991c59 CMake: Make sure to install Qt3rdPartyLibraryConfig.cmake.in
Repos like qtshadertools need it when configuring their own
bundled libraries.

Amends 572c03eb7a

Change-Id: I540e99d5bd2938299a10220a1a5e0d97091077b3
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-23 16:42: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
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
Tor Arne Vestbø
77885f8402 cmake: Remove APPLE prefix from platform names
None of the other platforms have it.

Change-Id: Ib448c2c03ba03f711b507ef391977c0e6aa7c192
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-16 17:57:56 +01:00
Tor Arne Vestbø
db745fdd2d cmake: Fix naming when referring to Apple macOS
Change-Id: Iafb5e448d0d65d42f788464fc600594a5666f9af
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-16 17:57:52 +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
Tor Arne Vestbø
3a2fa3fec5 cmake: Add default Info.plist for macOS with some important keys
The default Info.plist shipped with CMake lacks an NSPrincipalClass
entry, which is crucial for making macOS apps run in full resolution
on retina screens.

We make sure the file is only picked up on macOS, not iOS and friends,
since those platforms require another principal class. If needed we can
extract the value out as a CMake variable and use the same file for all
Apple platforms. Doing so would assume all keys are single-platform
only, so if that's not the case we need platform-specific files.

We should probably extract the package type out as a variable too,
so that the file can be used for both apps, plugins, and frameworks,
but doing so requires setting up that variable somewhere based on
the target type, which CMake doesn't allow in an easy way.

The file itself is based on the file CMake ships, combined with
keys inherited from Qt's existing plist templates for qmake, and
adjusted to match what Xcode generates by default these days.

Change-Id: I3f5109e5fff63cdbd109a99d4008948d4bd2102b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-13 15:23:56 +01:00
Tor Arne Vestbø
17be43c58e cmake: Disable GL deprecations on Apple platforms
Change-Id: I87b98ae68d996868cefaaf578722ac24be745145
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-12 17:05:10 +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
a1867333d4 CMake: Install the QtBuildInternalsAndroid.cmake fille
It's needed when building qtdeclarative.

Needs to be copy_or_install to support non-prefix builds as well.

Change-Id: Ied59f6a1f8403be3721a0ad46f5a3b2f569028ca
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-12 11:41:42 +01:00
Alexandru Croitor
aa77fbca69 CMake: Don't build tests and examples by default on Android and iOS
Change-Id: Ia31733e2cadfb52d11426c40f3543bedc48342c4
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-12 11:41:35 +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
14546d1816 rcc: Teach rcc the --no-zstd option
It is needed when cross-building Qt using CMake, where the zstd
feature might have different values between the host and target,
in which case the build system tells rcc not to use zstd when
the feature is disabled.

Amends d20c980576

Change-Id: I9dc55b59b1be5272b79aa5f1e2daf2b516a157d6
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-03-12 11:41:26 +01:00
Tor Arne Vestbø
39ad96033c Fix spelling mistakes
Change-Id: I389727ce9b8d3ef2a54156b682ef5aeccb39ebd2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-11 17:51:15 +01:00
Tor Arne Vestbø
cd80f347cf Update instructions for developer builds with CMake
Change-Id: I101a4b12bae393fa188bb2633cc2d74170adbb4c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-11 15:31:40 +01:00
Alexandru Croitor
1ef8470c80 CMake: Update the README regarding the minimum cmake version required
The minimum required CMake version to build Qt on any platform is
3.16.0 at the moment. That's the first version that ships the
implementation-specific AutogenInfo.json files, which we parse
to implement the Qt moc --collect-json functionality.

Change-Id: I6160cd74fa228aa330f4c1e512ffb766afc5f8a3
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-10 07:33:37 +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
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