diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-10-02 15:38:47 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-10-06 10:07:05 +0200 |
commit | 07b6d3367debd8f15974abf0f5cdf48f0fe3a536 (patch) | |
tree | 9785c58624928e0aab42c7f49b6dbc02e0bf9d69 /CMakeLists.txt | |
parent | e6fd92816dcbddcd9c28676815cf134b31291ea9 (diff) | |
download | qtbase-07b6d3367debd8f15974abf0f5cdf48f0fe3a536.tar.gz |
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>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b089814803..d0014b5363 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,6 +83,13 @@ if(NOT QT_BUILD_STANDALONE_TESTS) # Needed when building qtbase for android. include(src/corelib/Qt6AndroidMacros.cmake) + # Set up optimization flags like in qmake. + # This function must be called after the global QT_FEATURE_xxx variables have been set up, + # aka after QtBaseGlobalTargets is processed. + # It also has to be called /before/ adding add_subdirectory(src), so that per-directory + # modifications can still be applied if necessary (like in done in Core and Gui). + qt_internal_set_up_config_optimizations_like_in_qmake() + ## Setup documentation add_subdirectory(doc) @@ -122,9 +129,6 @@ endif() qt_build_repo_end() -# This function must be called after the QT_FEATURE_xxx variables have been set up. -qt_internal_set_up_config_optimizations_like_in_qmake() - if(NOT QT_BUILD_STANDALONE_TESTS AND BUILD_EXAMPLES) add_subdirectory(examples) if(QT_NO_MAKE_EXAMPLES) |