Go to file
Craig Scott 257edbfa53 Prevent compiler and linker flags from growing every cmake run
Functions in QtFlagHandlingHelpers.cmake try to update the CMake cache
variables for compiler and linker flags. These were using the current
value of those variables and writing the modified ones back to the
cache every time CMake ran. If a toolchain file sets or modifies any of
these variables, that updated value is used and written back into the
cache instead of the original cache variable's value. The next time
CMake executes, the toolchain file re-applies the same change and the
variable grows longer each time with flags repeated. With Ninja, this
causes a complete rebuild every time CMake is re-run. The Android NDK
toolchain file is one example where this behavior is triggered (the
fault is shared, one could argue that the NDK should only be setting
..._INIT variables, but that's out of our control).

Another related bug in the previous implementation was that the flags
used to build after the first CMake execution could be different to
those used for all builds after the second and later CMake runs. This
is because the CMake cache was being updated, but not always the
calling scope of the functions that modified them. If a toolchain file
set any of the compiler or linker flag variables as non-cache
variables, then updating the cache variable would have no effect on
the calling scope. The non-cache variable would continue to take
precedence for that scope for that run. The next time CMake executes
though, the updated cache variable would now have been used by the
toolchain file and the change *will* be part of the non-cache
variable's value.

The above are examples of why you should try to avoid updating these
cache variables from project code. We could leave the cache alone and
always update only non-cache variables, but then a developer looking
at the cache may wonder why the values they see there don't match the
values being used in builds. Or worse, they think the cache values
are being used and don't realize the builds are using something
different. Ultimately, we have to choose which downside we are happy
to live with. The changes here preserve the previous intent of
updating the cache, but it's still a bit fragile.

Fixes: QTBUG-89821
Task-number: QTBUG-85992
Task-number: QTBUG-86866
Change-Id: I8a16753e159bde338e6d2e5dd2ce91fc8ac5c39d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-01-15 22:26:41 +11:00
.github/workflows GitHub Actions: Fix workflow file 2020-09-11 13:37:48 +02:00
bin CMake: Mark qt-cmake-standalone-test as an executable on Unix 2020-12-04 11:22:38 +01:00
cmake Prevent compiler and linker flags from growing every cmake run 2021-01-15 22:26:41 +11:00
coin Prepare QNX env for cmake build 2021-01-11 15:02:09 +02:00
config.tests Remove the qmake project files 2021-01-07 15:32:28 +01:00
dist Add Qt 6.0.0 changes file 2020-11-16 10:02:08 +02:00
doc Doc: Add partial documentation for CMake API (tech preview) 2021-01-11 16:58:28 +11:00
examples Remove QtDBus includes 2021-01-12 09:19:27 +01:00
lib Purge all fonts 2015-08-18 19:59:14 +00:00
mkspecs macOS: Don't hard-code x86_64 as the architecture when using qmake 2020-12-07 15:35:55 +01:00
qmake If available, use a version-specific qt<major-version>.conf 2021-01-14 23:30:47 +01:00
src Prevent compiler and linker flags from growing every cmake run 2021-01-15 22:26:41 +11:00
tests Fix the tips still show when cursor move to another action 2021-01-15 12:26:41 +01:00
util Replace QtTest headers with QTest 2020-12-22 15:20:30 +01:00
.cmake.conf Lower the CMake minimum required version for single-config builds 2021-01-14 17:00:55 +01:00
.gitattributes Give batch files CRLF line endings 2020-11-04 15:02:29 +00:00
.gitignore .gitignore: Qt Creator files cleanup 2020-09-25 07:50:15 +02:00
.lgtm.yml Skip LGTM analysis for the bootstrap library and tools 2020-07-16 01:04:34 +02:00
.prev_configure.cmake CMake: Add --enable-new-dtags flag support 2020-12-22 10:28:34 +00:00
.prev_qt_cmdline.cmake CMake: Regenerate configure.cmake files 2020-09-28 15:48:17 +02:00
.qmake.conf Bump version 2020-12-15 15:54:46 +01:00
.tag Update the git-archive export options 2012-09-07 15:39:31 +02:00
CMakeLists.txt CMake: Bail out if the build dir is symlinked 2020-12-21 13:22:26 +01:00
config_help.txt Doc: Add -qt-host-path to configure's help screen 2020-12-07 15:26:11 +01:00
configure Remove qmake-related code from configure 2020-12-21 10:33:33 +01:00
configure.bat Remove qmake-related code from configure 2020-12-21 10:33:33 +01:00
configure.cmake CMake: Add --enable-new-dtags flag support 2020-12-22 10:28:34 +00:00
configure.json macOS: Don't hard-code x86_64 as the architecture when using qmake 2020-12-07 15:35:55 +01:00
dependencies.yaml Re-add dependencies.yaml now that qt5.git wip/qt6 builds fine 2019-09-18 13:19:31 +02:00
INSTALL INSTALL: Remove outdated reference to Windows CE 2019-02-13 13:01:57 +00:00
LICENSE.FDL Initial import from the monolithic Qt. 2011-04-27 12:05:43 +02:00
LICENSE.GPL2 Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.GPL3 Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.GPL3-EXCEPT Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.LGPL3 Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.LGPLv3 Remove LICENSE.GPLv3, LICENSE.LGPLv21, LGPL_EXCEPTION.txt 2018-04-16 11:02:14 +00:00
LICENSE.QT-LICENSE-AGREEMENT Update enterprise license agreement v4.2.1 2019-12-18 13:07:19 +02:00
qt_cmdline.cmake CMake: Add extra targets to run single benchmark using CMake generator 2020-12-07 14:26:07 +00:00
sync.profile Generate QUtf8StringView header file from qutf8stringview.h 2020-11-07 08:35:11 +00:00