diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-08-21 08:40:54 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-08-23 11:04:42 +0200 |
commit | 48cf015906e34ea0f8a388fd3a0e53ec082546f2 (patch) | |
tree | 44160036aa348732dadadd7a865b56d4c6df6e6d | |
parent | c8fda317ea12914ee51c20fe8bd256454cdb6cfe (diff) |
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>
-rw-r--r-- | cmake/QtFlagHandlingHelpers.cmake | 5 | ||||
-rw-r--r-- | cmake/configure-cmake-mapping.md | 2 | ||||
-rw-r--r-- | configure.cmake | 6 | ||||
-rwxr-xr-x | util/cmake/configurejson2cmake.py | 1 |
4 files changed, 12 insertions, 2 deletions
diff --git a/cmake/QtFlagHandlingHelpers.cmake b/cmake/QtFlagHandlingHelpers.cmake index 29453e2943..b305bc6b2f 100644 --- a/cmake/QtFlagHandlingHelpers.cmake +++ b/cmake/QtFlagHandlingHelpers.cmake @@ -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) diff --git a/cmake/configure-cmake-mapping.md b/cmake/configure-cmake-mapping.md index d792642a63..c113f4bceb 100644 --- a/cmake/configure-cmake-mapping.md +++ b/cmake/configure-cmake-mapping.md @@ -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 | | diff --git a/configure.cmake b/configure.cmake index 283bb94ed4..f6863d01fe 100644 --- a/configure.cmake +++ b/configure.cmake @@ -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 diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py index 4edd6cc3d3..ffe2dd11b7 100755 --- a/util/cmake/configurejson2cmake.py +++ b/util/cmake/configurejson2cmake.py @@ -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"}, |