CMake: Implement configure -optimize-debug

Task-number: QTBUG-85373
Change-Id: I3aba1fcf96e36544dd75a5e6adc5f770a9a45726
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2020-08-20 10:19:32 +02:00
parent 2f1a55c0b1
commit 729d102b1c
5 changed files with 17 additions and 2 deletions

View File

@ -118,6 +118,9 @@ endif()
qt_build_repo_end() 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) if(NOT QT_BUILD_STANDALONE_TESTS AND BUILD_EXAMPLES)
add_subdirectory(examples) add_subdirectory(examples)
if(QT_NO_MAKE_EXAMPLES) if(QT_NO_MAKE_EXAMPLES)

View File

@ -180,7 +180,9 @@ macro(qt_enable_cmake_languages)
endif() endif()
endforeach() endforeach()
qt_internal_set_up_config_optimizations_like_in_qmake() if(NOT PROJECT_NAME STREQUAL "QtBase")
qt_internal_set_up_config_optimizations_like_in_qmake()
endif()
endmacro() endmacro()
# Minimum setup required to have any CMakeList.txt build as as a standalone # Minimum setup required to have any CMakeList.txt build as as a standalone

View File

@ -356,6 +356,11 @@ function(qt_internal_set_up_config_optimizations_like_in_qmake)
endif() endif()
endif() endif()
# Debug should get the OPTIMIZE_DEBUG flag if the respective feature is ON.
if(config STREQUAL "DEBUG" AND QT_FEATURE_optimize_debug)
string(APPEND "${flag_var_name}" " ${QT_CFLAGS_OPTIMIZE_DEBUG}")
endif()
# Assign value to the cache entry. # Assign value to the cache entry.
get_property(help_text CACHE "${flag_var_name}" PROPERTY HELPSTRING) get_property(help_text CACHE "${flag_var_name}" PROPERTY HELPSTRING)
set("${flag_var_name}" "${${flag_var_name}}" CACHE STRING "${help_text}" FORCE) set("${flag_var_name}" "${${flag_var_name}}" CACHE STRING "${help_text}" FORCE)

View File

@ -409,6 +409,12 @@ qt_feature("use_lld_linker"
DISABLE INPUT_linker STREQUAL 'bfd' OR INPUT_linker STREQUAL 'gold' DISABLE INPUT_linker STREQUAL 'bfd' OR INPUT_linker STREQUAL 'gold'
) )
qt_feature_config("use_lld_linker" QMAKE_PRIVATE_CONFIG) qt_feature_config("use_lld_linker" QMAKE_PRIVATE_CONFIG)
qt_feature("optimize_debug"
LABEL "Optimize debug build"
AUTODETECT NOT QT_FEATURE_developer_build
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("pkg-config" PUBLIC qt_feature("pkg-config" PUBLIC
LABEL "Using pkg-config" LABEL "Using pkg-config"
AUTODETECT NOT APPLE AND NOT WIN32 AUTODETECT NOT APPLE AND NOT WIN32

View File

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