Commit Graph

1133 Commits

Author SHA1 Message Date
Alexandru Croitor
125113c909 CMake: Fix configure not to pass clang compilers for Android
That breaks configuration with CMake version 3.18.x (but not 3.19 for
some reason).

Specifically configure ends up passing -DCMAKE_CXX_COMPILER=clang++
which overrides the compiler set by the CMake Android toolchain file,
and at the very end of CMake's configuration it complains about

 You have changed variables that require your cache to be deleted.
 Configure will be re-run and you may have to reset some variables.
 The following variables have changed:
 CMAKE_CXX_COMPILER= clang++

Which suddenly starts another configuration with the modified
compilers, ends up detecting host compilers and libraries and
basically everything breaks apart.

Fix QtProcessConfigureArgs.cmake not to pass the compiler options if
the mkspec contains 'android'.
Who knows, we might need this for other platforms too at some point.

Task-number: QTBUG-88460
Change-Id: Idd57870a7cb1009a4e7802e5b3d5ac735f2dacf6
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-11-16 12:36:33 +01:00
Li Xinwei
cd1075459c CMake: Install missing debug info for some executable files
Although many executable files were generated by qt_internal_add_tool().
Some executable files like designer and androiddeployqt were generated
by qt_internal_add_app(). Some executable files like windeployqt were
generated by qt_internal_add_executable(). For these executable files,
their PDB files won't be installed on MSVC platform, and their separate
debug info won't be generated and installed on other platforms.

To fix this, qt_enable_separate_debug_info() and
qt_internal_install_pdb_files() should also be called in
qt_internal_add_executable().

Fixes: QTBUG-88268
Change-Id: Id6a3b5842dba325166e3d696701c82ad942bca74
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-16 19:36:26 +08:00
Andreas Buhr
1aec96bffd update KDE-ECM CMake modules to include fuzzer sanitizer
Updates one 3rdparty CMake file from
https://github.com/KDE/extra-cmake-modules to include support for
fuzzing.

Task-number: QTBUG-88429
Change-Id: I19e7ed3c5602c34ba4b86e6b0df2ea3047c7c9e6
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-14 10:05:20 +01:00
Li Xinwei
215400e153 CMake: Install pdb files to proper directories in multi-config build
In multi-config build, for different configs, the pdb files of EXEs
should have different installation directories.

For example, when CMAKE_CONFIGURATION_TYPES=RelWithDebInfo;Debug,
<build_dir>/bin/moc.pdb will be installed to <install_dir>/bin/moc.pdb.
<build_dir>/bin/Debug/moc.pdb should be installed to
<install_dir>/bin/Debug/moc.pdb, not <install_dir>/bin/moc.pdb.

Fixes: QTBUG-88268
Change-Id: Idc7c92ca8d44bb81d990656af2b309306a4f5c6b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-14 01:05:08 +08:00
Assam Boudjelthia
29b17fa335 CMake: fix running Android tests
Android *.so files need to CXX visibility to default after
qt_set_common_target_properties() which was setting it to hidden.

Also, pass the correct androidtestrunner arguments for cmake check
target

Fixes: QTBUG-88228
Change-Id: Ia29cdc9e65153c9669f3ec06f74a46f8fcd8c507
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-12 23:11:35 +02:00
Tor Arne Vestbø
1777ddc234 cmake: Remove indirection via Startup target for EntryPoint
The EntryPoint interface target now contains all the logic
for what flags and optional static libraries to add when the
entrypoint is enabled.

The target property QT_NO_ENTRYPOINT can be used to disable
the entrypoint.

Change-Id: I9b14ff729366cd6307789c969ebd4b2ca19de77d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-12 18:43:43 +01:00
Joerg Bornemann
2d07ef0b56 CMake: Fix Core -> Core dependency in static build
Fix the overly strict regex in qt_internal_create_module_depends_file to
allow for - and _ in module names.

We had the above mentioned dependency cycle, because the module name
Core_qobject was translated to just Core, creating a Core -> Core
dependency.

Amends da7609e7d0.

Fixes: QTBUG-88437
Change-Id: I866f7ce31e9a1b92fe4c0a6450295c2f3c761558
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-11-12 14:25:06 +00:00
Alexey Edelev
d312580a05 CMake: Add special processing of opengl configure option
Since feature evaluation expects explicit 'no' value for INPUT_opengl
to disable either desktop or es2 opengl support, add special
processing for -no-opengl option into QtProcessConfigureArgs.cmake

Task-number: QTBUG-88142
Change-Id: Ib49123ee3e9f98035f6ec85a182382559f4db478
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-12 14:25:06 +00:00
Alexey Edelev
6af1358742 CMake: Fix configure arguments handling
All configure arguments should be processed as strings
and not be ignored if they satisfy CMake's FALSE criteria
(see https://cmake.org/cmake/help/latest/command/if.html)

Fixes: QTBUG-88424
Change-Id: I932038ad3c5999bed58957dec51fbf892bd650d7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-12 14:25:06 +00:00
Joerg Bornemann
cc3f693029 CMake: Do not set PKG_CONFIG_* environment variables
This reverts commit 9968a211f9.

The PKG_CONFIG_* environment variables should be added by the user
environment, preferably by the toolchain file.

Apparently, the change was added for Android before we turned off
pkg-config for Android. It is not needed anymore.

Change-Id: Ieeed09ae53a606c85d4937f463286b5b0f76bde9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-12 08:51:25 +01:00
Yuhang Zhao
f27f9e7bd3 MSVC: enable identical COMDAT folding for release builds
According to Microsoft's docs, /OPT:ICF is enabled by the
linker by default unless /OPT:NOICF or /DEBUG is specified.

If we are in RelWithDebInfo mode, /DEBUG is passed to the
linker to generate debug symbols, however, it caused the
identical COMDAT folding be disabled. We now pass /OPT:ICF
to the linker explicitly to prevent this.

[1] https://docs.microsoft.com/en-us/cpp/build/reference/opt-optimizations?view=msvc-160

Change-Id: I02099edb81034ace7bb19f1164d57829e3979a5f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-12 03:51:04 +08:00
Tor Arne Vestbø
a299f337c5 cmake: Handle exported namespace when computing deps
We need to handle the possibility of versioned dep (Qt6::Foo).

Change-Id: I66797dbc59f00500892958e9c99c4555cddcb980
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-11 16:34:50 +01:00
Tor Arne Vestbø
da7609e7d0 cmake: Handle genexes when computing depends
If not, the resulting dep would end up as 'Foo>', but we need 'Foo'.

Change-Id: I246b66eb0ac6b076eea200c4d1ad84bba8ed179c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-11 16:34:50 +01:00
Giuseppe D'Angelo
8780fbb2eb Build Qt (and client apps using it) with /permissive-
*Not* using /permissive- exposes Qt and client apps to interesting
bugs and/or build failures, (e.g. QTBUG-87225, or
19b5520abf). We demand strict
conformance by any other compiler, it's time to demand it from
MSVC too.

The Windows headers themselves are clean starting from the
Windows Fall Creators SDK (10.0.16299.0), and moreover Qt 6 will
drop WinRT; therefore, the comment in the mkspecs does not apply
any more.

Since /permissive- implies /Zc:referenceBinding, drop that
option. The other implied options are set on MSVC < 2017,
but I leave them in to avoid tinkering with the fragile lists
of C/C++ flags.

Rename the CMake internal helper function to better describe
what it does.

Fixes: QTBUG-85633
Fixes: QTBUG-85637
Fixes: QTBUG-85635
Fixes: QTBUG-88244
Change-Id: Ie03fddb61aa066fdc14b7231c22e7108b4a02fbb
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-10 20:01:49 +01:00
Joerg Bornemann
88efeb9e25 CMake: Map configure -hostdatadir to INSTALL_MKSPECSDIR
In the qmake-based build, the hostdatadir is the directory where "Data
used by qmake" is located. In the CMake build the equivalent is
INSTALL_MKSPECSDIR. Create the mapping accordingly.

Fixes: QTBUG-88211
Change-Id: I9e3d1af24bc7f41333ef2269fced5ab3fcfa848d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-10 18:06:54 +01:00
Christophe Giboudeaux
30ba185583 CMake: Allow using DESTDIR when installing documentation
Previously, QtDocsHelpers.cmake was invoking CMake to copy
files or directories instead of using installation targets.

This resulted in DESTDIR being ignored.

Now we create installation targets and ask CMake to
install them.

Change-Id: Idbc79d47a37f9ca865d28543bdbbdde3ba448fa3
Fixes: QTBUG-87382
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-10 16:54:42 +01:00
Tor Arne Vestbø
4b063c8467 Move iOS entrypoint logic to entrypoint library
Change-Id: Ie0fc8368953a59d06a31847ed417bc3c35f29b90
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-10 16:53:31 +01:00
Joerg Bornemann
30a9b045cc CMake: Implement configure -list-features
Extend qt_configure_get_padded_string to make the feature list look like
qmake's.

Fixes: QTBUG-88144
Change-Id: I714f2b2f3537b506365a03b5b6bc3413e9cab167
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-10 16:53:31 +01:00
Alexandru Croitor
a3b9e3459f CMake: Warn when building Qt with a generator other than Ninja
For now, we only support building Qt with the Ninja generator (and
Ninja Multi-Config).

Issue a warning when a different generator is used.
Allow opting out of the warning by passing
-DQT_SILENCE_CMAKE_GENERATOR_WARNING=ON.

Change-Id: I5faa5b0ca5fd42efc090ad2ccf4f896bd77e50ca
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-11-10 16:53:31 +01:00
Joerg Bornemann
e990b649fa CMake: Make Release the main config of a -debug-and-release build
In configure we need to set the Release configuration first to make it
the main configuration.

Change-Id: I5fe744b0dcea009c4d672bf519b38c80c87475dd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-10 14:23:08 +01:00
Joerg Bornemann
5b136abd21 CMake: Fix installation errors in multi-config build
In multi-config builds (which equals the debug-and-release feature) we
exclude tools of the non-main configurations from the default build.
But we still create installation rules for them.  Mark those as optional
to avoid "cmake --install" yielding errors if those tools weren't built.

Fixes: QTBUG-85411
Change-Id: Ic2d3897d1a1c28a715d9a024ec8606fff00e0315
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-10 04:24:28 +01:00
Alexey Edelev
a1ce164d74 CMake: Make zstd config-based lookup quiet
Make zstd config based lookup quiet and check for version variable
as required for ZSTD target.

Add IMPORTED_LOCATION by default for pkg-config based search.
Expect that select_library_configurations will set correct value
for ZSTD_LIBRARY.

Fixes: QTBUG-88091
Change-Id: Ia5079154ce4fc4eefbc0931317219b5ca0f3f82f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-09 17:47:57 +00:00
Alexey Edelev
76230d9879 CMake: Add handling of PLUGIN_EXTENDS for generic plugins
Modify pro2cmake converter to add extra argument to
qt_internal_add_plugin. DEFINE_IF FALSE is added to generic plugins
those had "PLUGIN_EXTENDS = - " specified in .pro files.

Fixes: QTBUG-87861
Change-Id: I9269df19a32a088f5261f50e7ffff6d29c3d605f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-09 18:47:51 +01:00
Tor Arne Vestbø
c2e1a773e0 Don't add module pri library entry for header modules
The QT.foo.module entry is used for linkage, so we shouldn't
add it for header only modules.

Change-Id: Ibb6e7ab08083ccab11d7e060f35c54153e3751c0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-09 18:08:02 +01:00
Tor Arne Vestbø
8186f18c4a cmake: Allow module to specify initial depends
Change-Id: I85f39f16f2103dcb42ff467bbc79a0baf6c020e1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-09 16:01:51 +01:00
Joerg Bornemann
4ea99db8f3 CMake: Fix qt-configure-module location in configure's output
For non-cross-builds, qt-configure-module is located in
CMAKE_INSTALL_PREFIX/bin, not below the staging prefix.

Fixes: QTBUG-88262
Change-Id: Ib6cdd88ece391d5b8ce850b991564e5bed1e475d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-09 14:04:31 +01:00
Joerg Bornemann
ec1d553bbf CMake: Avoid usage of FEATURE_debug_and_release in QtSetup.cmake
If the user turns on debug_and_release with the configure script,
FEATURE_debug_and_release will not be set, and the debug postfix won't
be set correctly.

Directly use FEATURE_debug_and_release's condition instead.

Change-Id: Ica4af3caa25f2e6712eca4659818aac2c8b95256
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-09 13:56:43 +01:00
Joerg Bornemann
41d948c50b CMake: Fix configure -developer-build
Configure now translates -developer-build to INPUT_developer_build
without setting FEATURE_developer_build.

The install prefix determination code in QtSetup.cmake happens much
earlier than the feature evaluation. As the developer_build feature is
merely a switch that's supposed to be flipped by the user, we can just
translate the INPUT_developer_build value to FEATURE_developer_build in
QtSetup.cmake.

Fixes: QTBUG-88318
Change-Id: I57918232359e2e367e41b779d3f4737731dd76e5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-09 13:56:38 +01:00
Tor Arne Vestbø
a32ae53b88 cmake: Add function to get a target property, with empty string as fallback
Change-Id: Ic39fefb91e9ca0f36c815c969ff1072767a9ab16
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-08 13:14:30 +01:00
Alexey Edelev
2433e5804c CMake: Locate zstd using CONFIG
Trying to locate zstd package configuration prior to use pkg-config.

Define explicit IMPORTED_LOCATION_DEBUG and IMPORTED_LOCATION_RELEASE
in case of pkg-config usage.

Fixes: QTBUG-88091
Change-Id: I3cb86a66fad4e7b78b3d2fcff061508fc25e25a7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-08 03:13:13 +01:00
Alexey Edelev
a66e5a3eca CMake: Add PCRE2 library selection depend on debug version availability
Use select_library_configurations to select applicable libraries
set for PCRE2.

Fixes: QTBUG-88092
Change-Id: I11e669a0142d53a3c344c86bd1d8eb797df4ba97
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-08 03:13:03 +01:00
Alexandru Croitor
2db41fefa0 CMake: Allow using a custom target for qt_internal_add_docs
Some repos (like qtimageformats) might not have Qt modules, but they
still need a target to pass to qt_internal_add_docs().

Allow passing custom targets to qt_internal_add_docs() without trying
to generate bogus include paths.

Change-Id: I12191e5b16c082e62e40c96d0eb4d6c0256e7ea4
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-11-07 19:33:37 +01:00
Alexandru Croitor
d38b29bfa6 CMake: Private module pri files should have internal_module
Change-Id: I35b4111e4044ae6283eb8175173453db9001c71b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-11-07 19:33:37 +01:00
Joerg Bornemann
2746051522 CMake: Disconnect docs installation targets from generation targets
"ninja install_docs" should not run the "docs" target, because with
the usual workflow
    ninja docs
    ninja install_docs
the documentation would be built twice.

That of course means that "ninja install_docs" will fail if "ninja
docs" wasn't run before.

Analogous for html_docs, qch_docs, the repository-level and
module-level documentation targets.

Change-Id: I8ad83602dd393b5afc79a19ab3d395987c889d0d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-06 22:03:51 +01:00
Joerg Bornemann
db939d8f33 CMake: Fix top-level documentation install targets
The following targets did not do any actual installation:
install_docs, install_html_docs, install_qch_docs,
plus their repository-level counterparts.

Add the following dependencies:

install_html_docs
    --> install_html_docs_<repo>
        --> install_html_docs_<module>

Analogous for qch.

The install_docs target already triggers install_html_docs and
install_qch_docs. Analogous for install_docs_<repo>.

Fixes: QTBUG-86738
Change-Id: I3468e000e050e2787a859e61d40161f5459cb351
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-06 22:03:51 +01:00
Joerg Bornemann
e31c6c7337 CMake: Add version information to Qt plugin DLLs
Tools and library DLLs already have version information embedded.
Add the missing _qt_internal_generate_win32_rc_file call for plugins.

Fixes: QTBUG-87747
Change-Id: I619948f4066ce229d41e8b93f125751e1d28e26c
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-06 22:03:50 +01:00
Alexey Edelev
aa6ad15424 CMake: Rework INPUT_ variables handling
INPUT_ variables enable FEATURE_ variable only in case if valid
"true"-like value is assigned from command line.

Amends dc43061e9a

Fixes: QTBUG-87755
Task-number: QTBUG-88142
Change-Id: I65e85c7548981fdec94366b531f6df6396be71b7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-06 10:16:31 +01:00
Joerg Bornemann
ca59c20939 CMake: Fix usage of cache variables in qt.toolchain.cmake
We have some cache variables that are used in our qt.toolchain.cmake
toolchain file, for example QT_CHAINLOAD_TOOLCHAIN_FILE. When CMake
runs a configure test with try_compile, our toolchain file is included
again, but only a restricted set of variables is available.

Add the variables that are used in our internal toolchain file to
CMAKE_TRY_COMPILE_PLATFORM_VARIABLES. This makes them visible for
try_compile calls operating on source files.

Also pass the variables via the environment to support try_compile
calls that operate on whole projects.

Fixes: QTBUG-87873
Change-Id: Iebca9e23686bec5072194b15482e1782b9367a0e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-05 13:04:56 +01:00
Yuhang Zhao
f9e45287d8 CMake: don't add the same parameter twice
Change-Id: Ic5001f296b56f1181f5e37718e090f931eca8b50
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-04 10:07:50 +00:00
David Skoland
e674ee5328 Add quotes to cmake_args in guess_compiler_from_mkspec function
These were omitted in the original change, which cause cmake builds to
fail configuring

Change-Id: I37996099aaa0d912ce06b1f06c175cc5cf159e33
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-11-04 08:08:19 +01:00
Martin Storsjö
3e13fd43df cmake: Always add -Wno-ignored-attributes for clang targeting windows
This matches how it is in the qmake mkspec, silencing a lot of
warnings - but contrary to when building with qmake, it's only
applied when building Qt itself. For external projects built with
cmake, the Qt headers are included with -isystem, which silences any
warnings from those headers.

Change-Id: I1a498d3c2715cb73e647668cb7226ceeffb7ff0b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-04 06:38:35 +02:00
Cristian Adam
68f3e37449 CMake Build: Enable separate debug info for all target types
Now all shared libraries and executables will get .debug files on
the platforms that support FEATURE_separate_debug_info

With the directory property _qt_skip_separate_debug_info certain
targets can retain the debug symbols in the binary e.g. lupdate with
MinGW 8.1.0 will cause objcopy / strip to fail.

Fixes: QTBUG-87015
Change-Id: I03b106e68ef0a42011d1ba641e6f686b2e7b7fb4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-04 01:41:06 +01:00
Martin Storsjö
46dd4df4b9 cmake: Set a warning flag based on the target arch, not build host
Change-Id: I0b524d52286210b7782dd710467fbc3a742d0c08
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-03 21:36:35 +02:00
Alexey Edelev
dc43061e9a CMake: Add handling of user-defined INPUT_foo cache variables
"configure" script translates feature-related parameters to INPUT_
variables instead of FEATURE_.

Both INPUT_ and FEATURE_ variables passed to cmake script are
equivalent. FEATURE_ has higher priority in case if both are defined.

Fixes: QTBUG-87755
Change-Id: If697a0d62ab839877a3196ea74e631582a570dda
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-03 16:28:14 +01:00
Joerg Bornemann
9a50d62039 CMake: Fix Windows top-level configure.bat
We must write config.opt in the same directory we're reading it from.
We must not write the -top-level argument to config.opt.
This amends commit 2a29426e39.

Change-Id: I96da9094579fec29c290411677d6b538878399f4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-03 13:06:14 +01:00
Alexandru Croitor
72aab8b487 CMake: Bump the minimum required CMake version to build Qt to 3.18
Add a new function that returns the minimum CMake version required to
build Qt. Pass that value to cmake_minimum_required() when building
qtbase and its standalone tests.

The minimum supported CMake version is read from qtbase/.cmake.conf
and its value should be updated when the need arises. It's the main
source of truth for all repos.

Provide a way to lower the minimum CMake version at configure time by
passing a value via QT_FORCE_MIN_CMAKE_VERSION.
This is not an officially supported way of building Qt. If the
specified version is lower than Qt's supported minimum, show a
warning.

Nevertheless the option is useful for testing how Qt builds with a
different minimum CMake version due to different policies being
enabled by default.

Issue warnings for CMake versions that are higher than the minimum
version but are known to cause issues when building Qt.

A counterpart change is needed in qt5 to ensure the minimum CMake
version is set at the proper time for top-level builds.

Ideally we would use the same 'check the CMake minimum version` code
in all our repositories, but that will cause lots of duplication because
we can't really find_package() the code and doing something like
include(../qtbase/foo.cmake) hardcodes assumptions about repo
locations.

So for now we don't bump the minimum version in child repo
cmake_minimum_required calls (qtsvg, qtdeclarative, etc).
Instead we record both the minimum supported version and the computed
minimum version (in case a different version was forced) in
QtBuildInternalsExtra.cmake.
Then we require qtbase's computed min version in
qt_build_repo_begin().

This won't set policies as cmake_minimum_required would, but at least
it propagates what minimum CMake version should be used for child
repos.

We might still have to bump the versions in child repos at some point.

Task-number: QTBUG-88086
Change-Id: Ida1c0d5d3e0fbb15d2aee9b68abab7a1648774b9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-11-03 13:06:14 +01:00
Tor Arne Vestbø
6032a9ca1a Allow adding linker flags to qmake module pris
The flags go before the library in the final linker line, as opposed
to the dependencies declared in LIBS.

This allows us to declare the flags for the entrypoint
in the project file of the entrypoint, instead of in
a standalone prf.

Change-Id: I35c054fe9fdaa6add7cd0e8ba3f7304f975ff80f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-03 00:14:04 +01:00
Tor Arne Vestbø
517c885239 Allow adding extra content to module pri
On the qmake-side we had exports, but they were quoted.

Change-Id: I95af4b927079691cab6403fec850f345ba181a00
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-02 16:44:10 +01:00
Joerg Bornemann
1bb6779389 CMake: Let configure guess the compiler from mkspec argument
The arguments -platform, -xplatform and -device determine the mkspec
that's used for the qmake companion files.

If the user specifies a mkspec that indicates usage of clang or icc,
set the respective CMake variables to use one of those compilers.

Fixes: QTBUG-87836
Change-Id: I2b10d819b0eb92a97d7f79672547b1e2d821cf33
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-02 16:33:40 +01:00
Alexandru Croitor
b54dd671aa CMake: Bump the minimum required CMake version to use Qt to 3.14
At the moment our examples require a minimum of 3.14 due to changes
in upstream CMake's Autogen functionatlity to support Qt 6. Anything
lower would simply not work with Qt 6.

It's not clear yet if we actually want to require 3.14, or something
higher. At the very least there were many significant changes to
support iOS in CMake 3.15.

But for now just bump the version checked by Qt6Config.cmake to be
consistent with what's in our examples.

Task-number: QTBUG-88086
Change-Id: I119c2ad05a18c357fe7c659b30685af87475fc84
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2020-11-02 13:06:22 +01:00
Yuhang Zhao
4b694032df Improve clang-cl support for Qt6
1. clang-cl doesn't support "-fno-exceptions", it uses msvc's parameter.
2. some parameters supported by msvc are not supported by clang-cl
and they are causing huge warning message flood, don't add them.
3. use correct optimize parameter for clang-cl.

Change-Id: Idbadf139127143c5fa6c49068588cb26f47da7a2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-02 20:06:22 +08:00
Yuhang Zhao
bbeca236b5 Fix compilation error on Windows
When linking static libraries, MSVC's link.exe complains about
the unknown parameter "/INCREMENTAL:NO" and output a lot of warning
messages about this. This doesn't happen when it's linking exes
or dlls.

The situation is a lot more worse when we are using clang-cl.
clang-cl will print some error message like it can't find a
file named "/INCREMENTAL:NO" and just stop compiling. It seems
clang-cl treat unknown parameters as input files.

Fixes: QTBUG-87875
Change-Id: I37ed29de082b0258e81494db54f275417ab42708
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-01 10:59:29 +00:00
Alexandru Croitor
53b11882c8 CMake: Cleanup module and plugin define situation
The QT.<module>.DEFINES assignment in pri files needs to take into
account the module name when computing the define name. This is the
MODULE value that qmake specifies.
In CMake that would be the value of CONFIG_MODULE_NAME.

Previously the value of the define was computed in
qt_internal_module_info() without taking into account the module name.

While qt_internal_module_info() ended being used also for plugins and
other target types, the defines computed by it were meant to be used
only for Qt modules.
Thus remove the <result>_define assignment from
qt_internal_module_info and move its computation directly into
qt_internal_add_module, taking into account the value of
CONFIG_MODULE_NAME.

The only other use of module_define was in qt_internal_add_plugin but
that was merely a long overdue copy-paste error, qmake doesn't
propagate QT_FOO_LIB defines for plugins.

As result, a define special case in testlib is not needed anymore,
because the define is now computed properly.

Finally, QT_FOO_LIB should not be used while building the Qt module
itself, so instead of using PUBLIC_DEFINES option of
qt_internal_extend_target, use target_compile_definitions(INTERFACE)
directly.

Change-Id: I4d44f7461bac2f0c09aec3e995d02dfe36e00883
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-30 21:59:20 +00:00
Alexandru Croitor
02f429f06c CMake: Clean up order of assignments in generated module pri files
Makes the diff between Qt 5.15 and 6.0 easier to read, to see what's
missing.

Change-Id: Idf8aa17b3ab8494f6855c172665423a53ca8a024
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-30 17:49:08 +01:00
Joerg Bornemann
cde42e2f76 CMake: Remove outdated TODO comments
We do not have host-specific INSTALL_*DIR variables in the CMake build.
It is equivalent to a qmake build with host prefix = prefix.

Change-Id: I65731e6038508b6c28e3f2819b624ba19abfc82a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-30 09:34:08 +01:00
Joerg Bornemann
8fc59e552f CMake: Yield fatal error on malformed INSTALL_MKSPECS
The value of this variable must be exactly "mkspecs" or end with
"/mkspecs".

Change-Id: I39f83e9660794dfe23f5fd39fb1084b87ba1f140
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-30 08:23:32 +01:00
Joerg Bornemann
4670ef3cc4 CMake: Write INSTALL_MKSPECSDIR to qconfig.cpp
The value of this variable - whithout the mkspecs part - is what's
called the host data dir in Qt5.

Fixes: QTBUG-87681
Change-Id: I3dfeed17e8a614476aef4d9c651a141ce62e6551
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-30 08:23:03 +01:00
Joerg Bornemann
cb7f4030bc CMake: Fix [qt-]configure[-module].bat arguments with backslashes
We must escape backslashes in CMake code that's to be evaluated and in
the arguments we read from config.opt.

Change-Id: I65d033c77f71888974983aa3d834acb2fe89f3fb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-30 08:22:35 +01:00
Joerg Bornemann
2a29426e39 CMake: Fix argument passing for configure.bat / qt-configure-module.bat
Passing arguments with equal signs was broken for configure.bat and
qt-configure-module.bat. An argument FOO=BAR was split at = and written
as
    FOO
    BAR
to config.opt, breaking every attempt of assigning CMake variables.

We must not iterate over %* in batch files to avoid splitting arguments
at equal signs. Instead, pass %* unmodified to a CMake script that
writes config.opt.

Fixes: QTBUG-88019
Change-Id: I7c743a206961d1ed168f2313f864905f6b345b49
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-30 08:22:30 +01:00
Joerg Bornemann
de3bd64425 CMake: Prepare configure/qt-configure-module for calling more scripts
In a subsequent change we will call another CMake script from
qt-configure-module.bat. Write the location of qtbase/cmake into the
generated scripts instead of the path to QtProcessConfigureArgs.cmake.

Change-Id: Ie333b16d310b215c6e49efa27740c7525453d28f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-30 08:22:26 +01:00
Joerg Bornemann
91384c9918 CMake: Allow lower-case values in feature values
CMake considers ON/OFF as booly string values regardless of the case.

Make the value comparison in QtFeature.cmake case-independent.
It's now possible to build Qt with '-DFEATURE_gui=off'.

Fixes: QTBUG-87948
Change-Id: I3d948e8219ad9728414803c8c4cd756034073b46
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Rolf Eike Beer <eb@emlix.com>
2020-10-29 18:25:22 +01:00
Alexandru Croitor
bae96f1792 CMake: Fix generation of prl files for non-qtbase modules
Previously we determined if a library represented by an absolute path
is a Qt module by checking if it's located in the build dir of the
current repo.

That is not sufficient for non-qtbase prefix builds, where
a Qt module might link against both a module in the current
build dir and in the prefix dir.

Detect such cases, and rewrite the absolute paths to relocatable paths
(either framework flags or paths starting with $$[QT_INSTALL_LIBS].

This should fix building examples with qmake that use QtQuick.

Fixes: QTBUG-87840
Change-Id: Icaf8f1a7c66292c80662fd0d5771a5a1628a9899
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-29 12:11:53 +01:00
Kai Koehne
342cc61d3e CMake: Support installing extra cmake files for tools
Add an EXTRA_CMAKE_FILES argument to qt_internal_add_tool()
that allows tools to install an additional Macro.cmake file.

This is modelled after similar functionality in qt_internal_add_module.

Task-number: QTBUG-87870
Change-Id: I80838b8966f1018fdd379b1da877b6bc418de075
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-29 08:53:07 +01:00
Kai Koehne
1f6543902d Fix qdoc builds for non-top-level developer builds
Fixes a regression introduced in commit 748b3b9c89 for builds
that are both not a QT_SUPERBUILD and not QT_WILL_INSTALL.

Change-Id: I52b920176a2696fa6206b89b2b69ae1a7f3fbc25
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-28 17:14:57 +01:00
Tor Arne Vestbø
5c2656cfb6 cmake: Allow specifying module 'uses' entries
Change-Id: Iee02654e0f52e36e026b8074e0eacb0ea1804685
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-28 16:52:32 +01:00
Joerg Bornemann
da1854c683 CMake: Re-work documentation targets
The top-level prepare_docs target is supposed to run before the
generate_docs target.

The repository-level targets like prepare_docs_qtbase now also run
before their respective generate targets.

To achieve that, several intermediate targets had to be introduced.
The dependencies for top-level generate_docs look like this:

              /--> generate_top_level_docs_Core --\
generate_docs ---> generate_top_level_docs_Gui  -----> prepare_docs
              \--> ...                          --/

The dependencies for repo-level generate_docs_<repo> look like this:

                     /--> generate_repo_docs_Core
generate_docs_qtbase ---> generate_repo_docs_Gui
                     \--> ...

generate_repo_docs_Core --\
generate_repo_docs_Gui  -----> prepare_docs_qtbase
...                     --/

Analoguous for qch_docs.

And last but not least, the module-level generate_docs_<module> depends
on prepare_docs_<module>, just like before.

The strangely named top-level install targets have been renamed to
install_html_docs, install_qch_docs and install_docs.

The html_docs target is now merely an alias for generate_docs.

Apart from prepare_docs, the top-level targets do not depend on the
repository-level targets anymore. Targets that are just an alias (docs,
install_docs, ...) have been re-defined to depend just on the respective
top-level targets.

Fixes: QTBUG-87758
Change-Id: I24466d3a252d518a30a2064bf876be881c46231f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-28 10:38:28 +01:00
Tor Arne Vestbø
e24be7b6c3 cmake: Avoid -NOTFOUND suffix in module pri config
Change-Id: I1407a661c482d918dd143f291ee648bc7b18feef
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-28 00:22:30 +01:00
Tor Arne Vestbø
ba661f6bf1 cmake: Don't limit qt_internal_add_cmake_library to tests
Change-Id: I2dbe8075de6704a7a6557b877dc279a4b4cddd54
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-28 00:22:22 +01:00
Tor Arne Vestbø
598e873c84 cmake: Don't add module header for interface libs without headers
Change-Id: Ifba869586a65f28d5ff47bb2c01ce638110f493f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-28 00:22:19 +01:00
Alexandru Croitor
f65abc6344 CMake: Export QT_QPA_DEFAULT_PLATFORM in QtBuildInternalsExtra
The value is useful for QPA plugins built in repos other than qtbase,
to decide if it should be a default plugin or not.
Currently useful for qtwayland.

Also export a qmake value assignment when doing static builds, just
like src/gui/configure.pri does.

Change-Id: I1253f1a7e178b24b16e2615ba20d1e92b0b87b1a
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-27 19:26:35 +01:00
Ulf Hermann
d0bc2cefd2 CMake: Do not overrun the list end in qt_remove_args
Otherwise we get error messages from CMake.

Change-Id: I374b87e38550062b841b7eacf5fbb6bb5ccbdbde
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-27 12:49:39 +01:00
Assam Boudjelthia
f8a83fc5c0 CMake: allow using ANDORID_NDK_ROOT for user projects
Allow CMake for Android to use ANDROID_NDK_ROOT to deduce the path for
QT_CHAINLOAD_TOOLCHAIN_FILE instead of the user providing it manually.

Change-Id: Ida728011d5ca8d5a723d341ea77b173e8f105f8c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-27 13:49:39 +02:00
Tor Arne Vestbø
851e1cb4c4 cmake: Allow target to specify initial module internal config
Change-Id: I7312fa19aad84b020015b304b1cd2cd5acc83b81
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-26 20:10:48 +01:00
Alexandru Croitor
bcc7d34540 CMake: Provide a qt-internal-configure-tests script
This is meant to be called by our CI instructions to build standalone
tests of a Qt repository.

Currently it just calls qt-cmake with
-DQT_BUILD_STANDALONE_TESTS=ON, but it might contain more things in
the future.

The script also simplifies configuring standalone tests locally, due
to not having to remember the name of the magical variable.

Change our CI instructions to use the new script.

Change-Id: I6bc02b4e94adc9d0d05fecb0fe70a561043271f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-26 15:23:25 +01:00
Alexandru Croitor
1b4ea4a1d8 CMake: Fix target dependency cycle regarding qpa plugins in qtwayland
With the introduction of the new 'default_qpa_plugins' custom target,
a target dependency cycle occurred in qtwayland:
qtwaylandscanner -> default_qpa_plugins -> a wayland qpa plugin ->
WaylandClient -> qtwaylandscanner

The issue is twofold:
- default_qpa_plugins accidentally depended on non-qpa plugins.
- All qpa plugins were enabled by default, including the wayland ones.

Fix the default_qpa_plugins target not to depend on regular non-qpa
plugins.

Also fix qpa plugins not to be enabled by default, but instead only
choose one qpa plugin to be the default (via evaluating the
DEFAULT_IF) condition.

Amends df9c7456d1

Change-Id: I22cd2c72f6b75be54263fd21097258bd179e3616
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-26 13:46:49 +01:00
Alexandru Croitor
20292250d4 CMake: Fix handling of rpaths for tests with CMAKE_STAGING_PREFIX
Task-number: QTBUG-86053
Change-Id: I2f368d9dc2d871b67bd6261aadd8ef4c1dd1ae54
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-26 13:46:49 +01:00
Alexandru Croitor
5fa823491b CMake: Fix automatic sysrootification detection for qmake
The way we detected whether SysrootifyPrefix needs to be set was
incorrect.

We checked if extprefix == prefix => SysrootifyPrefix should be
true. But that was previously always the case for a non-prefix build,
which means it was not possible to build apps (due to qmake expecting
to find include dirs in the sysroot, despite the non-prefix Qt not
being installed anywhere into the sysroot).

Instead we should do what qmake does. Only set SysrootifyPrefix to
true if extprefix was not provided and a sysroot is available.

To make it work for iOS and Android, the sysroot detection code had to
be moved earlier than the SysrootifyPrefix detection.

Task-number: QTBUG-86053
Change-Id: Idcc1260a675fb2ef9ae27fc9dc42a68b30f763b8
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-26 13:46:49 +01:00
Topi Reinio
c4245e7b8c CMake: Don't invoke QDoc excessively
The html_docs target does not need to call QDoc a third time as
both its dependencies already do that.

With qmake, html_docs did invoke QDoc if CONFIG did not include
'prepare_docs', but none of the Qt modules used that configuration.
We can manage without it for now.

Fixes: QTBUG-87751
Change-Id: I45d2d06006c566c431ae41d7f3a06d6b809987f2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-24 17:44:34 +00:00
Joerg Bornemann
4bf8f70bfe CMake: Let doc targets depend on doc tools in top-level build
For top-level builds it's desirable to have "ninja generate_docs" build
all tools needed to generate the documentation.

This is problematic since the doc-generating targets are created before
the doc tool targets. Thus, we must defer the dependency connection if
the doc tool target is not yet available.

This patch adds the functions qt_internal_defer_dependency and
qt_internal_add_deferred_dependencies.

Change-Id: Ica940b80882e67cb0e0943e95541f7f4d1885948
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-23 21:11:40 +02:00
Joerg Bornemann
86064e1298 CMake: Fix typo in variable name
Change-Id: I310ff17c75970482803294bb5f4473bcaebdc151
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-23 21:11:36 +02:00
Alexandru Croitor
419db858f5 CMake: Fix deprecation defines not being set properly
Instead of propagating the deprecation wranings, we compiled all code
with -Ddeprecations.

Change-Id: I0233ddc85bdbdcb93d366073b2cea5d47bdbe52a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-23 20:12:12 +02:00
Tor Arne Vestbø
83ad237771 cmake: Produce internal module pris like qmake does
qmake treats internal modules as just the regular module file,
but with a _private suffix, as opposed to the current cmake
logic, that treats it as the private module file, resulting
in missing e.g. the Qt.foo.module entry.

Change-Id: Id55ca4c23921656d5abfd1d0fdf6430d4fe120bf
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-23 16:37:14 +02:00
Joerg Bornemann
6681fa7b73 CMake: Allow docs generation without installing in top-level builds
This patch allows in top-level prefix builds to build Qt and to generate
the documentation without running cmake --install first.

For top-level builds we now always use the qdoc binary from the build
directory, not the installation directory.

We also have to copy the global doc files to the build directory to make
them accessible to the generate_docs target.

Change-Id: I2251603418fc3df9a21c7f2892789e9ff6c8cc21
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-23 11:36:48 +02:00
Tor Arne Vestbø
1f53a91ed3 cmake: Respect NO_PRIVATE_MODULE when generating module pri files
Change-Id: Id5816d6598a0a484c20674f34f6f809e68671e6b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-23 11:36:48 +02:00
Tor Arne Vestbø
6baa0f4ccc cmake: Don't add include paths to module pri if there are no headers
Change-Id: I8fa01f45410805399a511a87c6f04192ce42d374
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-23 11:36:48 +02:00
Alexandru Croitor
5d81a5d4f9 CMake: Fix headersclean to build with proper flags
It's not sufficient to pass -I{prefix}/include when doing the header
clean check.

We need to propagate all target include directories and compile
definitions, and also the compile flags for good measure.

For macOS frameworks we also need to explicitly pass an -iframework
flag (qmake passses -F instead), to ensure that <QtGui/qfoo.h> style
includes are found when building other repos than qtbase.

Task-number: QTBUG-82615
Change-Id: I76d12340bc01c5c948ff04df9a3df384dcb7e076
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-23 01:32:39 +02:00
Alexandru Croitor
2a3a99fe44 CMake: Use compiler launcher for headerclean rules
This ensures ccache or sccache is used to cache the compilation of the
headerclean checks.

Task-number: QTBUG-82615
Change-Id: Ie944eb1d643e7271551c9f8337609741e419e9d8
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-23 01:32:34 +02:00
Alexandru Croitor
7c23281db3 CMake: Fix headersclean to work on macOS
It appears there's a difference between the chosen macOS compiler path
in the CI versus the compiler path on my local machine.

In the CI the chosen compiler path ends up 'being /usr/bin/clang++'
whereas for me locally it's

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++

For some reason the headersclean commands succeed in the CI, but
locally they fail for me saying that standard library includes can not
be found, unless an explicit sysroot flag is specified.

I assume that in the CI the '/usr/bin/clang++' compiler shim chooses some
implcit sysroot, whereas the longer Xcode compiler expects an explicit
sysroot.
It's probably also affected by the fact that in the CI we pass an
explicit CMAKE_OSX_SYSROOT to a non-standard Xcode location e.g.

/Applications/Xcode11.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk

Note the '11' in the Xcode app name.

Locally I don't pass a custom CMAKE_OSX_SYSROOT, and my Xcode is
installed in a regular location e.g /Applications/Xcode.app.

The sysroot flag and path is added to regular CXX compilation rules
inside CMake's core (in cmLocalGenerator.cxx).

Reuse the same variables that CMake uses and add them to our headersclean
command rules.

Task-number: QTBUG-82615
Change-Id: Ic03ea27e39471f5fa168eb5970bf3d3f1d1be251
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-23 01:32:29 +02:00
Alexandru Croitor
df9c7456d1 CMake: Add convenience custom targets to build Qt plugins
Add 3 new convenience custom targets:
'qt_plugins', 'qpa_plugins' and 'qpa_default_plugins'.

Additionally, if we detect that an internal executable / test
links against Gui, add a dependency on the 'qpa_default_plugins'
custom target, so that if a developer configures Qt for the first time
and then calls ninja 'tst_foo_check', we ensure the test will launch
successfully because the default QPA plugin will also be built.

Change-Id: If6dd70844b5effdf8a293f65f8785855cc85b132
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-22 23:32:23 +00:00
Joerg Bornemann
736408880b CMake: Do not prepend -l to libs starting with dash in prl files
For example, we must not prepend -l to -pthread, -framework and -lfoo.

Fixes: QTBUG-87760
Change-Id: Ie1bc7a76183c2c4980c519b5f23dde6c47ec85a9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-22 20:47:10 +02:00
Joerg Bornemann
4b016c87c1 CMake: Advertise qt-configure-module in configure output
...instead of qt-cmake-private.
Also, add ".bat" on Windows.

Change-Id: I2aa94ac76f2dadfb8e94d68b19bb379b3d45a93d
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-22 20:47:10 +02:00
Joerg Bornemann
90e384d286 CMake: Fix CMake generator auto-selection on Windows
The variable to check for a Windows host system was mis-typed.

Change-Id: I25b14b80d25bfec0c1a00e99833520b6fb6a4b02
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2020-10-22 20:47:10 +02:00
Alexandru Croitor
9a7de1abf5 CMake: Pad the configure summary string with one more dot
This makes the diff-ing of the config summary between qmake and CMake
builds correct.

Change-Id: I720b69572c23afd78e6d0bea6cdf0740980c3b36
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-22 18:06:19 +02:00
Joerg Bornemann
9ff9a54bfb CMake: Fix INPUT_* names with dashes
In configure.json files we have inputs with dashes, e.g.
bundlex-xcb-xinput. In configure.cmake files, these are read in their
normalized form, e.g. INPUT_bundled_xcb_xinput.

Normalize the input names in QtProcessConfigureArgs.cmake like we
already do for feature names.

Change-Id: Iece414d40a0e9e2920580f2fda68e25cd32674c9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-22 18:06:19 +02:00
Volker Hilsheimer
34943a6f70 Turn warning about missing xcodebuild into notice
On a mac that can build all of Qt with CMake, Ninja, and command line tools,
there should be no warning just because a build tool that
won't get used is not available.

Turn the warning into an informative message instead so that IDE
integrations (such as VSCode's CMake integration) don't flag warnings.

Change-Id: I250c0e5dd0633b36ff2b690a52ba7ce3ceb22218
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-10-22 02:43:17 +02:00
Joerg Bornemann
80a2878e20 CMake: Fix additional target info files
...for QT_BUILD_TOOLS_WHEN_CROSSCOMPILING.

qt_internal_export_additional_targets_file now gets two lists of target
names when run from qt_export_tools:
 - TARGETS containing actually existing targets, and
 - TARGET_EXPORT_NAMES containing the target names as they appear in the
   additional target info file.

Operations that require actual targets are run on the TARGETS, in the
additional target info file only TARGET_EXPORT_NAMES are written.

This distinction is required for the case where the host Qt lacks a
tool that is built in the target Qt.

Example: host Qt is built with DEVELOPER_BUILD=OFF, target Qt is built
with DEVELOPER_BUILD=ON. Then the host Qt lacks qmljs, but it is built
in the target Qt. TARGETS contains qmljs_native, and
TARGET_EXPORT_NAMES contains qmljs.

Fixes: QTBUG-87693
Change-Id: I615aed996bfcbe654274defcda8c1cb2cc4b7b4e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-10-20 20:59:21 +02:00
Joerg Bornemann
748b3b9c89 CMake: Fix html_docs targets for top-level builds
Do not append "/qtbase" to QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX
when doing a top-level build. The "/qtbase" suffix is already part of
this variable's content.

Fixes: QTBUG-87682
Change-Id: If1c2075dc58d4b07a4c3a1eed12cc3336c5dc8e6
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-19 16:38:39 +02:00
Joerg Bornemann
73f9c514dc CMake: Ignore license-related configure arguments
Do not print warnings for the configure arguments -commercial,
-opensource and -confirm-license. We're not removing the arguments yet
to keep existing build scripts working.

Fixes: QTBUG-86096
Change-Id: Ieb63e2f2b81c022e8559cde6c3e0be0b8ce655ca
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-17 23:27:31 +02:00
Tor Arne Vestbø
b5af140809 Generalize the winmain/qtmain entry-point library
The use-case is relevant for other platforms as well.

Now that Qt has a module system we can also replace a lot of the
hand crafted logic for linking with simpler constructs.

Change-Id: Ib6853aaf81bfea79c31f2de741d65b4b56f23ef6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-17 12:13:00 +02:00
Tor Arne Vestbø
f6012c4a56 cmake: Fix logic for adding staticlib to module pri
Change-Id: I2426e78bb509a37e7e3924506903cd84732f88d8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-16 23:59:28 +02:00
Alexandru Croitor
1f9ec097b2 CMake: Rename some public API functions
Some of them have a different (hopefully better) name now.
Some are marked as Technical Preview.
Some are renamed to be internal.

Marking add_qt_gui_executable as TP with the intention to un-TP it
after we rename it and change its behavior as discussed in the API
review meeting.

Additional changes to add_qt_gui_executable and qt6_add_resources have
been filed as separate tasks that will be worked on separately.

See comments on PS1 for details.

Task-number: QTBUG-86827
Change-Id: I56a84a1943b0902bb807310dc620eb381824e8dd
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-16 13:53:04 +02:00
Joerg Bornemann
557d2adbe8 CMake: Autodetect Android toolchain file and NDK
The Android toolchain file is now autodetected from the location of the
NDK. The NDK location can be specified by setting the CMake variable
ANDROID_NDK_ROOT. Auto-detection of the Android toolchain file is the
only purpose of this variable.

In recent Android SDK installations the path to the NDK is well-known
and can be auto-detected too. If only ANDROID_SDK_ROOT is given, we try
to detect ANDROID_NDK_ROOT first and from that the Android toolchain
file.

Adjust the build instructions in cmake/README.md, and remove the part
where we suggest to set some environment variables that are only used to
create the cmake call.

Task-number: QTBUG-87068
Change-Id: Ia0df5df7651e98979e9cead1cdae7b17ecbc4afb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-13 19:44:45 +00:00
Ulf Hermann
4e10abb4c1 Add externConstexpr to MSVC compile options
We want this in order to be able to export constexpr members.

Change-Id: I33ba7964ebee54fe656df983985d8d6fa0b99358
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-13 08:38:25 +02:00
Joerg Bornemann
18357033b4 CMake: Fix the -sanitize configure option
This needs to map to ECM_ENABLE_SANITIZERS.

Fixes: QTBUG-87316
Change-Id: I9e983728af0ba69fd428944e647f0afae8c61772
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-12 13:57:56 +02:00
Alexandru Croitor
0a0949837e CMake: Allow customization of the generated CMake toolchain file
Provide two customization points:
 - optionally include a 'qt.toolchain.extra.cmake' file if it exists
   and is placed next to the main generated toolchain file.
   This use case is mostly for the Qt installer, so that it can create
   an extra file with correct installer-provided paths, instead of
   patching the toolchain file directly.
- optionally include a file passed via the command line CMake argument
  'QT_TOOLCHAIN_INCLUDE_FILE'.
  The use case is for application developers that might want to adjust
  the toolchain file after the modifications done by the Qt installer.

These options do not replace the existing QT_CHAINLOAD_TOOLCHAIN_FILE
option, which is meant to chainload a platform specific existing
toolchain file (like Android or Emscripten).

Task-number: QTBUG-87068
Change-Id: I956949840f55742cfbd3bc8fc0bd8c6b3f774d3d
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-12 13:36:03 +02:00
Alexandru Croitor
acf9b3a68b CMake: Split QtBaseGlobalTargets.cmake into multiple files
And wrap the various behaviors into separate functions.

Change-Id: If940351af34e445de050f2b46301de7080b1555b
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-12 13:36:01 +02:00
Alexandru Croitor
5b90b650a4 CMake: Implement missing iOS-related configure options
Detect an iOS build when either an -sdk option is passed
or when -xplatform macx-ios-clang is passed as a target
mkspec.

Now that CMake 3.17 is released, change the default behavior of the
iOS build to configure with simulator_and_device set to ON, like it
is with qmake.

Update the documentation regarding iOS configuration.

Change-Id: I91aaf706610b8d3c69f1ad4ba9dadee2b1e5db97
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-12 13:35:57 +02:00
Alexandru Croitor
e57ccd45ca CMake: Rename some additional functions that should be internal
Amends e0c62a48b8

Task-number: QTBUG-86815
Change-Id: Ic65d8dda1aed390c78408616fb22f38edd2e1dce
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-10-12 13:35:55 +02:00
Alexandru Croitor
1e1805ed36 CMake: Workaround iOS Xcode issue when configuring app
It appears that CMake's Xcode generator default behavior can't really
handle imported object libraries location, which Qt uses extensively
(all the qt_add_resource calls).

Specifically the project fails to configure with the following error
message:
The OBJECT library type may not be used for IMPORTED libraries under
Xcode with multiple architectures.

An issue was filed upstream at
https://gitlab.kitware.com/cmake/cmake/-/issues/21276

In the mean time, it looks like it's possible to work around the issue
by setting XCODE_EMIT_EFFECTIVE_PLATFORM_NAME global property to OFF.
This needs to be done before the very first project() call, so we do
it in the generated Qt toolchain file.

Note that the workaround only works if the CMake project is configured
with a single architecture given to CMAKE_OSX_ARCHITECTURES.
If multiple arches are given, it will fail with the same error
message.

Fixes: QTBUG-87198
Change-Id: I2556ae28b2fc2d9cfe464a5acf9c4fcbaf01b654
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-12 13:35:53 +02:00
Alexandru Croitor
28ed9e3e2d CMake: Set some additional info variables in Qt6CoreConfigExtras
Add info whether Qt was an infix built, and whether the reduce_exports
feature was enabled. These variable were set before in
Qt5CoreConfigExtras.cmake.

Change-Id: Id077763cfffd5ee6f1a7a28d04cf92dc46390c54
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-12 13:35:50 +02:00
Alexandru Croitor
c6a5cdcee6 CMake: Introduce Qt6::Startup target
Add an abstraction over Qt::WinMain (aka qtmain.lib) and
iOS's runtime linker entry point (_qt_main_wrapper).

The Core target will now link against the Startup target on all
platforms, instead of just WinMain on Windows.

The creation and linkage interface definition of the Startup target
is done at find_package(Qt6Core) time via the private call of
_qt_internal_setup_startup_target().

This will add automatic linkage of WinMain to executables marked with
the WIN32_EXECUTABLE property on Windows.
As well as the addition of the '-Wl,-e,_qt_main_wrapper' linker flag
when linking iOS executables.

Qt users can opt out of this behavior by either setting the
QT_NO_LINK_QTMAIN property or variable. This is in line with
Qt 5 behavior.

Task-number: QTBUG-87060
Change-Id: I7d5e9f1be0e402cf8e67e6f55bfd285f9e6b04f4
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-12 13:35:48 +02:00
Oliver Wolff
22b72a6f7a win: Set correct target mkspec for qmake builds for arm64 builds
As there is no other way of obtaining information about Qt's paths at the
moment, windeployqt is still querying qmake for these information. For a
cross compiled Qt, the proper target mkspec has to be set in this case.

Change-Id: I0b7b7719c9055d432576185ac4f7572a5ba1dd6b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-09 08:06:34 +02:00
Joerg Bornemann
13c4dfb274 CMake: Fix tool targets for top-level cross-builds
When loading the tool packages from the host Qt we must ignore
QT_NO_CREATE_TARGETS. Otherwise tool targets like Qt6::moc are not
available.

Task-number: QTBUG-85080
Change-Id: I2c8c8e68863f28a4f1d9cd2f70090455c49d8df2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-09 07:28:10 +02:00
Kai Koehne
ab4acdbeb1 Do not build tests and examples by default for configure -cmake
Tests were never built by default, except for -developer-build.
Examples were build, but aren't anymore by default if you
run cmake directly.

Let the default be figured out by cmake, and only set
BUILD_EXAMPLES and BUILD_TESTING if the user has
expicitly passed them via -make or -nomake.

Task-number: QTBUG-87217
Change-Id: I37321d96cc1e9e184a711a858c860b0205d5b74f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-08 11:12:30 +00:00
Kai Koehne
0cb0119f43 CMake: Remove outdated info from README.md
3.17.0 is released since a while. ANyhow, the requirement for
3.17 for simulator_and_device builds is already mentioned
at the start.

Change-Id: Ic8813bb60b010feb97a47b878124c3e75658813d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-08 13:12:18 +02:00
Alexandru Croitor
b7f1915bd2 CMake: Fix leftover usage of qt_add_executable
All usages should be replaced with qt_internal_add_executable instead.
This should fix configuration failure of benchmarks and manual tests.

Amends e0c62a48b8

Task-number: QTBUG-86815
Change-Id: I0791d849998ed9517e32f699d843367949b97cb9
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-07 16:52:12 +02:00
Joerg Bornemann
417ae745ec CMake: Issue warning if chainloaded toolchain file does not exist
Change-Id: Ib7e9b172c6e42feb074955786d49b071639ca86e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-07 13:26:03 +02:00
Joerg Bornemann
3cb4f45ca8 CMake: Introduce QT_CHAINLOAD_TOOLCHAIN_FILE
This variable can be set when using qt-cmake[-private] to override the
CMake toolchain file that is chainloaded by Qt's toolchain file.

Task-number: QTBUG-87068
Change-Id: Id529408381e4174becda1ba07a489535c8cf1314
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-07 13:26:01 +02:00
Joerg Bornemann
9ef4411d81 CMake: Document convenience scripts in README
Change-Id: I7ec7f01f744285fc086de8a0430afbf49563adce
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-07 13:25:58 +02:00
Alexandru Croitor
af9197ff91 CMake: Add missing Android values in qdevice.pri
These were introduced in
675805e9eb and
b9c85d6b0e

They should be exported if they were set.

Change-Id: Ieec565980ba148f675f84dcdd7c19894e349085f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-07 10:08:37 +02:00
Alexandru Croitor
4270522916 CMake: Export the chosen iOS SDK used when configuring Qt
The value is used by mkspecs/features/mac/default_post.prf and
ultimately by xcodebuild to decide which arch and SDK to build
against.

For a simulator_and_device build, no value needs to be set as far as
I can see.

Task-number: QTBUG-87218
Change-Id: I41992bec6b16aadfd87c3f7c10653a6094e76d3e
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-07 10:08:31 +02:00
Alexandru Croitor
98cc32d93e CMake: Add iOS mkspec mapping for the wrapper qmake
If no mkspec is provided, we default to the macx-clang-ios mkspec when
building for iOS. This ensures that the wrapper qmake script is usable
for building iOS apps with qmake.

Task-number: QTBUG-87218
Change-Id: Ib02b580c8382b04455c9f820163062591d14a15b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-07 10:08:28 +02:00
Alexandru Croitor
6fb81a2c14 CMake: Remove leftover debug output
Amends 07b6d3367d

Change-Id: I8d5922af13903c6a10f967035bca70a89b19f86f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-06 14:55:36 +02:00
Alexandru Croitor
2354274f39 CMake: Allow embedding debug info in object files with MSVC
Introduce a new feature called 'FEATURE_msvc_obj_debug_info' which
should allow usage of sccache for Windows MSVC configs.

Enabling the feature will replace the default '/Zi' compile flag
that CMake sets in Windows-MSVC.cmake with '/Z7'.

This ensures that the debug info is placed into the compiled object
file instead of placing it in the compilation .pdb file via
mspdbsrv.exe.
The final pdb file will still be created for shared libraries and
executables due to the linker '/debug' flag.
Static libraries will not have a .pdb file, instead the debug info
being embeeded in the .lib file.

The downsides of using '/Z7' are more disk space usage, slower
link times, more memory used for linking because the linker needs
to deal with more symbols.

The upside is that caching each indepedent cl.exe call is possible.
This is what Chromium uses with goma, and Firefox with sccache.

We're not enabling the feature by default to allow easier
testing (and switching it off) in the CI if it proves not to be
feasible.
It will probably have to be disabled at least for building
qtwebengine due to high memory requirements.

Task-number: QTQAINFRA-3934
Change-Id: I89e0e57995e938a780be318d1faec700194aa93f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-06 10:07:10 +02:00
Alexandru Croitor
98bea5857a CMake: Introduce CMake-only optimize_full feature
Enabling it will force usage of '-O3' flag when building Qt.
If the platform has no '-O3' flag, use '-O2' as a fallback.

Task-number: QTBUG-86866
Change-Id: If13f7de954ba5c01dc9634f06a85529828fe90a9
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-06 10:07:08 +02:00
Alexandru Croitor
07b6d3367d CMake: Refactor optimization flag handling and add optimize_full
Introduce a bunch of helper functions to manipulate compiler
flags and linker flags for the
CMAKE_<LANG>_FLAGS_<CONFIG>
and
CMAKE_<LINK_TYPE>_LINKER_FLAGS_<CONFIG>
CMake variables.
These variables can be assigned and modified either in the cache
or for a specific subdirectory scope, which will apply the flags
only to targets in that scope.

Add qt_internal_add_optimize_full_flags() function which mimics
qmake's CONFIG += optimize_full behavior.

Calling it will force usage of the '-O3' optimization flag on supported
platforms (falling back '-O2' where not supported).

Use the function for the Core and Gui subdirectories, to enable full
optimization for the respective Qt modules as it is done in the qmake
projects.

To ensure that the global qmake-like compiler flags are assigned
eveywhere,
qt_internal_set_up_config_optimizations_like_in_qmake() needs
to be called after Qt global features like optimize_size and
optimize_full are available.

This means that qtbase and its standalone tests need some special
handling in regards to when to call that function.

Task-number: QTBUG-86866
Change-Id: Ic7ac23de0265561cb06a0ba55089b6c0d3347441
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-06 10:07:05 +02:00
Alexandru Croitor
e6fd92816d CMake: Install PDB debug info for MSVC builds
Supports installing linker generated debug info for shared libraries
and executables, as well as compiler generated debug info for static
libraries.

Works with Ninja Multi-Config as well, with the caveat that the files
are installed optionally, aka the install rule will not error out if
a pdb file is not present. This is necessary, because it's not
possible to create per-config install rules properly.

Fixes: QTBUG-87006
Change-Id: I95e91a6557eb0ee0f882103be54cd38795c349f7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-06 10:07:02 +02:00
Joerg Bornemann
1f52f45836 CMake: Implement missing Android-related configure options
Implement the last remaining Android-related configure options for the
CMake build.

Print warnings for options that have no equivalent in the CMake build.

Let -android-ndk automatically deduce the CMake toolchain file, and
error out if that fails with a hint how to fix the situation.

Task-number: QTBUG-85373
Change-Id: I8399e5334ae0f1f6634e381775a308d34f7c482b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-06 06:31:18 +02:00
Joerg Bornemann
260a6e86c2 CMake: Extend message functions in QtProcessConfigureArgs.cmake
qtConfAddWarning was missing, despite being used.

All of the three qtConfAdd* functions take multiple parameters and pass
them to the CMake's message() function.

Change-Id: I1fad46c6fd00b2e733b32cda482bbf1341ffc63f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-06 06:31:18 +02:00
Joerg Bornemann
cc0c27c421 CMake: Fix typo in ANDROID_SDK_ROOT's help text
Change-Id: I1edc7e7ae443c306aca64b8f6a92c8b32fad6117
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-06 06:31:18 +02:00
Joerg Bornemann
c09df7b57c CMake: Implement configure -reduce-exports
This option maps to FEATURE_reduce_exports. The feature is on by
default, except for MSVC. The reduce_exports configure test is not used
in the CMake build.

The <LANG>_VISIBILITY_PRESET and VISIBILITY_INLINES_HIDDEN target
properties are now explicitly initialized in the
qt_set_common_target_properties function, because we don't have access
to the feature in QtSetup.cmake where the CMAKE_<LANG>_VISIBILITY_PRESET
variables were set before.

Task-number: QTBUG-85373
Change-Id: I378453f0e0665731970016170302871e20ceb4e2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-05 10:05:20 +02:00
Alexandru Croitor
081ec14b25 CMake: Clean up the public API a bit
Add some missing versionless functions.
Rename some functions that are not meant to be public API, and their
usages.

Task-number: QTBUG-86827
Change-Id: Ifb66c04cd7598d83fe80c01a92ab2d269ebaf396
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-01 14:57:12 +02:00
Joerg Bornemann
84485dfad3 CMake: Fix -[no-]warnings-are-errors configure argument
The CMake build uses the WARNINGS_ARE_ERRORS variable, and the feature
warnings_are_errors exists only in the qmake build.

Change-Id: I1e548b30b210b3dd1b2f23041d490a981312f4ba
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-01 14:56:23 +02:00
Samuli Piippo
b376f8b9eb CMake: use HostInfo when QT_HOST_PATH is set
HostInfo is used in places whenever QT_HOST_PATH is set, regardless
whether CMAKE_CROSSCOMPILING is set or not. Make sure that HostInfo
is available when QT_HOST_PATH is set.

Change-Id: I39763a61d77e97dc9c4cc3875bce4deb942f870a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-30 07:27:11 +03:00
Assam Boudjelthia
7a41b928d4 CMake: fix sdkBuildToolsRevision not being set for user apps
Add qt6_android_get_sdk_build_tools_revision() function to get the
Android SDK build tools revision, the logic is moved from
QtPlatformAndroid to Qt6AndroidMacros. The update QtPlatformAndroid
header comments.

Task-number: QTBUG-85982
Change-Id: If3e5b46fa583f929a24794792c9d5a52beb83990
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-29 19:28:12 +03:00
Assam Boudjelthia
bfd07072fe CMake: make QT_ANDROID_DEPLOYMENT_SETTINGS_FILE consistent with qmake
Make name format of QT_ANDROID_DEPLOYMENT_SETTINGS_FILE consistent with
qmake, that is android-${target}-deployment-settings.json.

Task-number: QTCREATORBUG-24678
Change-Id: I2bdb056cf7a82fd83aaf658f3a405a0c9ef05756
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-28 17:25:19 +00:00
Joerg Bornemann
3d54f47cea CMake: Generate *AdditionalTargetInfo.cmake for tools
This ensures that we have the configuration-independent IMPORTED_*
properties set on tools.

Fixes: QTBUG-86893
Change-Id: I2b772c21341e6e4631379d4a5a99580ec96909ed
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-28 17:29:38 +02:00
Joerg Bornemann
347d2163b2 CMake: Write proper *AdditionalTargetInfo file in debug-only build
To provide the IMPORTED_LOCATION target property we must write
the *AdditionalTargetInfo.cmake file for all debug-only builds, not only
the ones containing a release configuration.

Task-number: QTBUG-86893
Change-Id: I9ecd01483660f434a3f1ea12fa2af756cdcf9932
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-28 17:29:35 +02:00
Julien Schueller
32309fb446 CMake: FindGLIB2 to include gthread2 sub-library
Avoids undefined references to g_thread_init.

Fixes: QTBUG-86727
Change-Id: Ic41b0dab9e4e23083faf4e9abcf7acc517172e49
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-28 15:48:17 +02:00
Alexandru Croitor
9bcabd71a7 By default don't try to use pkg-config when targeting Android
It causes issues in our Windows CI, because the strawberry perl
pkg-config is found. And even that one is unusable, due to a bug in
CMake which is tracked at
https://gitlab.kitware.com/cmake/cmake/-/issues/21239

Change-Id: I58816195d35459e8a44c923399c35a4956c222a2
Reviewed-by: Simon Hausmann <hausmann@gmail.com>
2020-09-28 15:48:17 +02:00
Alexandru Croitor
7bb91398f2 CMake: Allow finding Qt CMake packages in additional locations
By default, when using the Qt6 CMake package to look for components,
the find_package() calls for the components use NO_DEFAULT_PATH to
ensure that CMake doesn't accidentally find system (distro) packages.
Instead we limit the paths to one level up from where the Qt6 package
is.

Unfortunately that doesn't quite work for finding Qt packages that
might have been installed into a different prefix than where the main
Qt prefix is.
This happens when Qt addons are built by Conan, and installed into
a separate prefix.

To allow calls like find_package(Qt6 COMPONENTS ConanAddon) to work
in a scenario as described above, introduce a new variable called
QT_ADDITIONAL_PACKAGES_PREFIX_PATH which can be used to specify
additional paths where Qt CMake packages should be found.

This is similar to previously introduced QT_EXAMPLES_CMAKE_PREFIX_PATH
variable which was meant for a similar case, but only for examples.

Additionally, allow disabling the NO_DEFAULT_PATH option by setting
the QT_DISABLE_NO_DEFAULT_PATH_IN_QT_PACKAGES cache variable to TRUE.
This would allow regular usage of CMAKE_PREFIX_PATH to work, at the
risk that system Qt CMake packages might be found.

Augments 5cd4001bf2
and ffe0889413.

Fixes: QTBUG-86882
Change-Id: Ia8e060cbba6d2a10c3d63d81892f2c71e4236a9a
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-09-28 15:48:17 +02:00
Assam Boudjelthia
45896797c6 CMake: use ANDROID_SDK_ROOT instead of ANDROID_SDK consistently
Make the use of ANDROID_SDK_ROOT consistent.

Task-number: QTCREATORBUG-24678
Change-Id: If967bdc4d252996098fa210cf38429fe075eacb1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-26 16:43:02 +00:00
Alexandru Croitor
151323b94b CMake: Add $import_prefix/include as an include path for each Qt module
To support finding Qt headers of modules installed into a different
prefix than the main one, add the $import_prefix/include path as a
public include path for each built Qt module. With this, includes like
 #include <QtNetworkAuth/QOAuth2AuthorizationCodeFlow> will work.

The macOS framework case is handled automagically by CMake, which
ends up passing '-iframework $import_prefix/lib'.

Change-Id: I02ce9cacf157aab9721c1d6073a377607c5b89c7
Fixes: QTBUG-86881
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-09-26 11:25:20 +02:00
Joerg Bornemann
893ee16352 CMake: Fix build of Release user projects against RelWithDebInfo Qt
Building a user project in Release configuration against a Qt built with
CMAKE_CONFIGURATION_TYPES=RelWithDebInfo;Debug led to the user project
being linked against the Debug Qt libraries. This is especially painful
with MSVC where debug and release runtimes are incompatible.

We now create *AdditionalTargetInfo.cmake files along the
exported *Targets.cmake files that set the IMPORT_*_<CONFIG> properties
to the values of the release config Qt was built with.

User projects built with an unknown
configuration (CMAKE_BUILD_TYPE=ArbitraryName) will link against a
release Qt. This can be controlled by setting the variable
QT_DEFAULT_IMPORT_CONFIGURATION to, for example, DEBUG in the user
project.

Fixes: QTBUG-86743
Change-Id: I12c4b065a9845c7317f6acddab46b649f2732c9e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-25 17:02:52 +02:00
Joerg Bornemann
dae078e521 CMake: Export 3rdparty dependency find_package calls of private modules
Consider a Qt module with a 3rdparty library target in
PRIVATE_MODULE_INTERFACE, e.g. XKB::XKB in Qt6::GuiPrivate. Consumers of
GuiPrivate automatically depend on XKB::XKB. In order to do that they
must find_package(XKB ...). As all find_package calls for GuiPrivate are
in the same place as the ones for Gui, this package must be marked as
optional. Otherwise all consumers of Qt6::Gui would have to have the
xkbcommon package installed too.

This patch exports find_package calls for every 3rdparty public
dependency of private modules and marks them as optional.

Change-Id: Ia1eeb09c29927fb6634ef08b477684ed6f123267
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-25 06:58:55 +02:00
Alexandru Croitor
3031787485 CMake: Fix sanitizer build when using Clang on Linux
Apparently the combination of the --no-undefined linker flag together
with ASAN when building on Linux with Clang does not work.

Disable --no-undefined flag in such a scenario. Note that linux-clang
mkspec doesn't add that flag at all, which is why asan builds work
there.

Change-Id: I6167c757ce4be5d2263311bc84e5fb445b0f7c2d
Fixes: QTBUG-86879
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-09-24 18:23:17 +02:00
Cristian Adam
079cf55111 CMake Build: Add support for -qtlibinfix configure parameter
Rename all libQt6*.so to libQt6*<infix>.so

Task-number: QTBUG-85438
Change-Id: I4b91ffaaec7bea61454b0d3c794c77f2d0868d54
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-23 17:31:13 +02:00
Assam Boudjelthia
ac0be4d568 Android: set default API level to 23 in docs
Android minimum API level for Qt 6 is 23, this reflects that to some
instances that still mention 21.

Change-Id: I996f3ed3af14dca114129351d6ea06afcb8f45f5
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-23 17:59:07 +03:00
Assam Boudjelthia
1c33b4e729 CMake: partially revert 00a1e5d
00a1e5da7e wrongfully added parts of
QtPlatformAndroid.cmake which were removed in
32121e9882. This removed the part in
question again

Change-Id: Ie18968e6a165f52c68f4941ced6add266985bc48
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-23 17:59:07 +03:00
Tor Arne Vestbø
5c1ed8bb74 Use 'A' for Apple framework version instead of Qt major version
All system frameworks use 'A' instead of the major version of the
framework, and Xcode's code signing assumes that the framework version
is 'A' when signing embedded frameworks (FB7323980), so leave the
version 'A'. This is also what Apple recommends.

Change-Id: Idbf2e30e156c3e869da8f75731e568524d9407e5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-23 16:59:06 +02:00