diff options
author | Craig Scott <craig.scott@qt.io> | 2021-01-07 16:53:43 +1100 |
---|---|---|
committer | Craig Scott <craig.scott@qt.io> | 2021-01-15 22:26:41 +1100 |
commit | 257edbfa5363a3d35e66d342ae43e5994b297f97 (patch) | |
tree | 32c03c75fa0ed00fabafaadf4cd06f863307e0ea /src/gui/CMakeLists.txt | |
parent | 77350b7a71d564e930edbc2c1b3965f4879b5872 (diff) |
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>
Diffstat (limited to 'src/gui/CMakeLists.txt')
-rw-r--r-- | src/gui/CMakeLists.txt | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 30e28cfd0e..404387c125 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -1030,5 +1030,5 @@ qt_internal_add_docs(Gui ) # special case begin -qt_internal_add_optimize_full_flags(IN_CURRENT_SCOPE) +qt_internal_add_optimize_full_flags() # special case end |