Commit Graph

28 Commits

Author SHA1 Message Date
Alexandru Croitor
41800c3c31 CMake: Add /OPT:REF flag when building Qt on Windows
In qmake it's done for all qmake projects, in CMake we lean on the
safe side and apply it to building Qt itself. User CMake projects can
then choose to add it themselves.

Task-number: QTBUG-85992
Change-Id: I51919f947d43ffd9925e3d2837dcad17e480367d
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-08-19 18:26:00 +02:00
Joerg Bornemann
d6e41abd62 CMake: Handle -D, -I, -F and -L configure arguments
Introduce new CMake variables and map
-D to QT_EXTRA_DEFINES,
-I to QT_EXTRA_INCLUDEPATHS,
-L to QT_EXTRA_LIBDIRS,
and -F to QT_EXTRA_FRAMEWORKPATHS.

Those variables only affect the Qt build, not user projects.

Fixes: QTBUG-85878
Change-Id: I229df2eed1505a2619068d0d32975962b052569a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-17 18:19:24 +02:00
Alexandru Croitor
f32a38b6c6 CMake: Don't use lld linker for Android with a Windows host
Most of the time lld just gets stuck (deadlock) waiting on some
mutex, thus failing integrations.

Amends 64c111e10f

Task-number: QTBUG-85911
Change-Id: Id73bf967a7aeb0e0cbccfaafe056b325c8711f82
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-08-06 19:20:04 +02:00
Alexandru Croitor
b3b1e47378 CMake: Introduce qt_internal_add_app
This new function is meant to be used where load(qt_app) is used.

It delegates functionality to qt_add_executable, while handling
some additional behavior via a finalization function (mostly handling
of macOS Info.plist files and icons, as well as Windows icons and
resource files)

It uses a new PlatformAppInternal interface target.

Task-number: QTBUG-85757
Change-Id: I1a2d5851b137fcd4a6323e0e06fb154f91619800
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-07-31 12:55:32 +02:00
Alexander Volkov
865582bd7f Add -Wsuggest-override for gcc >= 9.2
gcc doesn't report warnings for final methods since version 9.2:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010

Change-Id: I7152351aac0e3bad86d777e119f25137ef97ec6f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2020-07-24 13:10:51 +03:00
Tor Arne Vestbø
1048d83fc2 Limit OpenGL deprecation silencing on Apple platform to Qt itself
Apple deprecated the entire OpenGL API in favor of Metal, which
we are aware of, so we don't need to see the warnings when building
Qt.

Instead of applying the silencing globally for all Qt consumers,
both internal and external, we now limit the silencing to Qt itself.
That means user code that explicitly uses any of the deprecated APIs
will see the warnings. Note that this does not apply to merely using
any of the Qt OpenGL APIs. The user has to explicitly use the platform
APIs that have been deprecated.

The warnings need to be disabled on a build system level, so that
that they are passed as -D flags on the command line. If the defines
were done in Qt headers (qguiglobal.h e.g.), they would require the
user to always include this header before any of the Apple headers.

Change-Id: I3f2a2a5211332a059ad4416394251772c677fdcb
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-07-02 10:27:58 +02:00
Alexandru Croitor
a046833176 CMake: Enable bitcode when targeting UIKIT aka iOS
Building an iOS app with qmake failed because Qt itself was not built
with bitcode enabled.

Enable building with bitcode.
Make sure qrc resource files and bundled 3rd party libraries also
build with the regular Qt module flags and thus with bitcode enabled.
As a consequence gc_sections has to be disabled for UIKIT platforms.

Task-number: QTBUG-82581
Task-number: QTBUG-84781
Task-number: QTBUG-85240
Change-Id: I15fe668725a139c02f2a32a5db849b46d4ce325c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-07-01 10:03:54 +02:00
Alexandru Croitor
de29af7663 CMake: Make GL_SILENCE_DEPRECATION a public define for all consumers
In qmake land the define is set in mkspecs/common/macx.conf which
means it should be public for all Qt consumer apps as well, not just
internal targets. Make it so.

Amends 17be43c58e

Task-number: QTBUG-83929
Change-Id: I9f9d7dfca24b54977cb8364723c3618d3fec2e73
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-06-12 22:34:21 +02:00
Alexandru Croitor
6a47e1c4ee CMake: Propagate largefile flags to all internal consumers
The large file flags in qmake land are set in the
mkspecs/features/unix/largefile.prf file, which is loaded by qmake
when a CONFIG += largefile entry is written by configure into
qmodule.pri.

This essentially makes them global flags for all private Qt targets
because qmodule.pri is a global file loaded load(qt_build_config)

Thus assign the flags onto the PlatformCommonInternal target instead
of the PlatformModuleInternal one.

One peculiarity though is that in qmake land these flags are also
applied when building examples as part of the main Qt build. This
is because qt_build_config loads qmodule.pri even for an example,
because qmake sees it as part of the overall Qt build.
The flags are not applied by qmake if the example is built in
a different standalone build dir not part of the Qt buil dir.

We don't do that in the CMake build, and thus examples will never
have those flags.

Task-number: QTBUG-83929
Change-Id: If653a669b4835aadd1de84acb477c375ab523909
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-06-12 22:34:16 +02:00
Alexandru Croitor
e189126f1a CMake: Use -fapplication-extension when building Qt libraries on macOS
Needed to avoid linker warnings transformed into errors, when linking
QtWebEngine with qmake mixing.

ld: warning: linking against a dylib which is not safe for use in
application extensions:

The flag is added to libraries and plugins, unless opted out.

CMake equivalent of 944110089d

Task-number: QTBUG-83929
Task-number: QTBUG-75666
Change-Id: I3e9acca4712c9a266bf54c6e35e2fd2c0096692b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-05-28 15:13:27 +02:00
Alexandru Croitor
0cdcbb40a1 CMake: Enable default usage of utf8 sources for Qt consumers
And enable the same default when building Qt itself (it's implicit).

Allow opting out on a target-by-target basis, by using the public
qt_disable_utf8_sources() API call.

Change-Id: Ifc19a744d57b96b1c74a6926a0c6628c2a820464
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-05-15 11:47:09 +02:00
Alexandru Croitor
27aeb30b5d CMake: Limit warnings_are_errors flags to C++ and Objective-C++
Otherwise when applied to bundled 3rd party library C files,
the MinGW build fails when compiling src/3rdparty/md4c/md4c.c.

Change-Id: Ia522b10aa69aa15f239d20c65e31c84edbccee6d
Reviewed-by: Simon Hausmann <hausmann@gmail.com>
2020-05-01 19:11:37 +02:00
Alexandru Croitor
c571cb71a7 CMake: Fix 32 bit Qt builds like our MinGW config in Coin
Enable sse2 and fpmath for modules when appropriate, the logic
is a port of the code in mkspecs/features/qt_module.prf.

Fix qdrawhelper.cpp to always be compiled when using GCC with a
special case. pro2cmake.py failed to handle the source subtraction
correctly.

Fixes: QTBUG-83791
Task-number: QTBUG-75578
Change-Id: Ibe32a250b266d580ad21f6c55f09fd03a14ceb82
Reviewed-by: Simon Hausmann <hausmann@gmail.com>
2020-05-01 19:11:17 +02:00
Joerg Bornemann
da6f021b52 CMake: Fix build with WARNINGS_ARE_ERRORS=ON and gcc 9.3.0
Add -Wno-error=format-overflow. This is similar to what is done in
qt_common.prf, however we don't turn the warning off completely.
For now at least.

Change-Id: I93c20064759dea43309c3a17de4d733ede9ca2cb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-04-06 17:21:45 +02: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
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
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
Leander Beernaert
a99d7cf372 CMake: Add missing compile flags for msvc
This patch adds a couple of missing compile flags that are defined in
mkspecs/common/msvc-version.conf and mkspecs/common/msvc-desktop.conf
that were not yet ported to CMake.

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

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

Change-Id: I16a911d15217a62093c68ba2b4c2545cdb8df1e6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-20 16:11:01 +01:00
Alexandru Croitor
55a15a1c1b Add initial support for cross-building to iOS
Tested locally with the following configurations:
- iOS device builds (arm64)
- iOS simulator builds (x86_64)
- iOS simulator_and_device builds (fat arm64 and x86_64 archives)

All iOS builds currently require a custom vcpkg fork which contains
fixes for building the required 3rd party libraries.

qtsvg, qtdeclarative, qtgraphicaleffects and qtquickcontrols2
have also been tested to build successfully.

simulator_and_device builds are also supported, but require an umerged
patch in upstream CMake as well as further patches to vcpkg.

Task-number: QTBUG-75576
Change-Id: Icd29913fbbd52a60e07ea5253fd9c7af7f8ce44c
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2019-12-03 13:35:59 +00:00
Alexandru Croitor
f000685612 Add support for skipping warnings are errors
Unfortunately not all repositories are marked as warning_clean
in their .qmake.conf files. For instance qtconnectivity and
qttools are not warning clean. Therefore we need to skip
warnings_are_errors flags on all targets created in that repository.

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

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

Change-Id: Ib5a487af6601ae1519a0988a89f8083f94f92267
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-12 17:30:35 +00:00
Alexandru Croitor
a37771ebc5 Check for the correct apple clang version with warnings_are_errors
The current state of qtbase is confirmed to be built with no warnings
when using up to Xcode 9.2, as per the check in
mkspecs/features/qt_common.prf. Add the same check for the CMake
build.

Change-Id: I0c2409ece048e93fba29c41a8bd053dd112949bd
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-06-24 14:52:59 +00:00
Alexandru Croitor
1a2a3b72bf Add PlatformCommonInternal target and QT_NO_DEBUG definition
All the other PlatformModuleInternal, PlatformPluginInternal,
PlatformToolInternal target will depend on the common one.

Also add the QT_NO_DEBUG definition when the build type is not Debug.
This fixes the lookup of the Qt platform plugin on macOS, which
uses a "_debug" prefix in the plugin name depending on if the
QT_NO_DEBUG definition is present or not.
This is the same as it is done in mkspecs/features/qt.prf.

Change-Id: I82cf461d44b8a3b3c5dc2b2d9f25baa246fc1e4b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-06-24 13:30:14 +00:00
Alexandru Croitor
c09e770a5d Add appropriate MSVC version check for warnings are errors feature
In qmake land warnings_are_errors is only enabled for specific
MSVC versions, ending with MSVC2015. Presumably the warnings have not
yet been fixed for newer MSVC versions, so we stick with the same
status quo for now.

Change-Id: Idc3741d39c888f77ed324a5eb8c654416591785f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-06-11 09:43:25 +00:00
Alexandru Croitor
449eee2d10 Don't add _LARGEFILE64_SOURCE define on Windows
In qmake land, the largefile.prf feature is automatically loaded due
to 'largefile' being added to CONFIG via the equivalent feature.
The prf file is in the 'unix' subfolder though, which means that qmake
doesn't load it on Windows.

We need to do the same, otherwise we get build errors due to the
define being checked in ZLIB headers, and selecting an invalid code
branch on Windows.

Change-Id: Ibe9202a639754927262bb8aaa28289934f2e23ef
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-06-11 09:41:54 +00:00
Simon Hausmann
abe12f600b Simplify per-module option handling
Move flags/options that we use for modules from add_module to the new
platform module target.

Change-Id: I89e414690336dcd37253432fe5116226d1c8dd82
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-06-06 14:10:26 +00:00
Albert Astals Cid
f5a494f3c1 Introduce Platform*Internal targets
Link to them from add_qt_module/plugin/tool

This way we set the warnings_are_errors flags just once
and also non-qtbase modules get them

Change-Id: I2b65a81694aaebdd7c886249f217c11f79492bad
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-06-05 15:43:23 +00:00