CMake: Implement configure -optimize-size

This configure switch controls the feature 'optimize_size'.

This isn't merely a mapping to CMAKE_BUILD_TYPE=MinSizeRel, because
we potentially want to combine -optimize-size with -force-debug-info,
which maps to CMAKE_BUILD_CONFIG=RelWithDebInfo.

Task-number: QTBUG-85373
Change-Id: I1a9343ebc54816f52e90e9d33ea3df4c99b1ec9f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2020-08-21 08:40:54 +02:00
parent c8fda317ea
commit 48cf015906
4 changed files with 12 additions and 2 deletions

View File

@ -361,6 +361,11 @@ function(qt_internal_set_up_config_optimizations_like_in_qmake)
string(APPEND "${flag_var_name}" " ${QT_CFLAGS_OPTIMIZE_DEBUG}")
endif()
set(configs_for_optimize_size RELEASE RELWITHDEBINFO)
if(QT_FEATURE_optimize_size AND config IN_LIST configs_for_optimize_size)
string(APPEND "${flag_var_name}" " ${QT_CFLAGS_OPTIMIZE_SIZE}")
endif()
# Assign value to the cache entry.
get_property(help_text CACHE "${flag_var_name}" PROPERTY HELPSTRING)
set("${flag_var_name}" "${${flag_var_name}}" CACHE STRING "${help_text}" FORCE)

View File

@ -28,7 +28,7 @@ The effort of this is tracked in QTBUG-85373 and QTBUG-85349.
| -debug-and-release | -G "Ninja Multi-Config" | |
| | -DCMAKE_CONFIGURATION_TYPES=Release;Debug | |
| -optimize-debug | -DFEATURE_optimize_debug=ON | |
| -optimize-size | | |
| -optimize-size | -DFEATURE_optimize_size=ON | |
| -optimized-tools | n/a | This affects only host tools. |
| -force-debug-info | Use the RelWithDebInfo build config. | |
| -separate-debug-info | -DFEATURE_separate_debug_info=ON | |

View File

@ -415,6 +415,12 @@ qt_feature("optimize_debug"
CONDITION NOT MSVC AND NOT CLANG AND ( QT_FEATURE_debug OR QT_FEATURE_debug_and_release ) AND TEST_optimize_debug
)
qt_feature_config("optimize_debug" QMAKE_PRIVATE_CONFIG)
qt_feature("optimize_size"
LABEL "Optimize release build for size"
AUTODETECT OFF
CONDITION NOT QT_FEATURE_debug OR QT_FEATURE_debug_and_release
)
qt_feature_config("optimize_size" QMAKE_PRIVATE_CONFIG)
qt_feature("pkg-config" PUBLIC
LABEL "Using pkg-config"
AUTODETECT NOT APPLE AND NOT WIN32

View File

@ -897,7 +897,6 @@ def get_feature_mapping():
"incredibuild_xge": None,
"ltcg": {"autoDetect": "1", "condition": "CMAKE_INTERPROCEDURAL_OPTIMIZATION"},
"msvc_mp": None,
"optimize_size": None,
"simulator_and_device": {"condition": "UIKIT AND NOT QT_UIKIT_SDK"},
"pkg-config": {"condition": "PKG_CONFIG_FOUND"},
"precompile_header": {"condition": "BUILD_WITH_PCH"},