Skip to content

Commit

Permalink
CMake: Implement configure -optimize-debug
Browse files Browse the repository at this point in the history
Task-number: QTBUG-85373
Change-Id: I3aba1fcf96e36544dd75a5e6adc5f770a9a45726
Reviewed-by: Alexandru Croitor <[email protected]>
  • Loading branch information
jobor committed Aug 20, 2020
1 parent 2f1a55c commit 729d102
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions cmake/QtFlagHandlingHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion util/cmake/configurejson2cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit 729d102

Please sign in to comment.