diff --git a/CMakeLists.txt b/CMakeLists.txt index 10df970dff4..e31224ee4ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,9 @@ 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) diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake index 3c8692a903f..63cb264d329 100644 --- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -180,7 +180,9 @@ macro(qt_enable_cmake_languages) endif() 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() # Minimum setup required to have any CMakeList.txt build as as a standalone diff --git a/cmake/QtFlagHandlingHelpers.cmake b/cmake/QtFlagHandlingHelpers.cmake index cddaa0da39f..29453e29434 100644 --- a/cmake/QtFlagHandlingHelpers.cmake +++ b/cmake/QtFlagHandlingHelpers.cmake @@ -356,6 +356,11 @@ function(qt_internal_set_up_config_optimizations_like_in_qmake) 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. 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/configure.cmake b/configure.cmake index d870e3a7590..283bb94ed4e 100644 --- a/configure.cmake +++ b/configure.cmake @@ -409,6 +409,12 @@ qt_feature("use_lld_linker" DISABLE INPUT_linker STREQUAL 'bfd' OR INPUT_linker STREQUAL 'gold' ) 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 LABEL "Using pkg-config" AUTODETECT NOT APPLE AND NOT WIN32 diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py index 81181135aca..4edd6cc3d36 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_debug": None, "optimize_size": None, "simulator_and_device": {"condition": "UIKIT AND NOT QT_UIKIT_SDK"}, "pkg-config": {"condition": "PKG_CONFIG_FOUND"},