From 07b6d3367debd8f15974abf0f5cdf48f0fe3a536 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 2 Oct 2020 15:38:47 +0200 Subject: 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__FLAGS_ and CMAKE__LINKER_FLAGS_ 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 --- src/winmain/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/winmain') diff --git a/src/winmain/CMakeLists.txt b/src/winmain/CMakeLists.txt index 1a74a1e3ae..3f3e6f0f1c 100644 --- a/src/winmain/CMakeLists.txt +++ b/src/winmain/CMakeLists.txt @@ -16,8 +16,10 @@ qt_internal_add_module(WinMain if (MSVC) # Store debug information inside the static lib - string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") + qt_internal_replace_compiler_flags( + "/Zi" "/Z7" + CONFIGS DEBUG RELWITHDEBINFO + IN_CURRENT_SCOPE) endif() set_property(TARGET WinMain PROPERTY OUTPUT_NAME qtmain) -- cgit v1.2.3