Presets: Add missing VisitPresetInherit for configure debug/trace fields

Add inheritance support for configure preset fields that were missing
from ConfigurePreset::VisitPresetInherit: debugOutput, debugTryCompile,
debugFind, trace mode, trace format, trace source, and trace redirect.

Add tests verifying that these fields propagate correctly from parent
to child presets, including override cases.

Fixes: #27766
This commit is contained in:
Mickaël Germain
2026-04-22 15:50:39 -07:00
parent e99fbf4100
commit 975bd69c34
16 changed files with 72 additions and 0 deletions
+7
View File
@@ -896,6 +896,13 @@ bool cmCMakePresetsGraph::ConfigurePreset::VisitPresetInherit(
InheritMap(preset.Errors, parent.Errors);
InheritOptionalValue(preset.WarnSystemVars, parent.WarnSystemVars);
InheritMap(preset.CacheVariables, parent.CacheVariables);
InheritOptionalValue(preset.DebugOutput, parent.DebugOutput);
InheritOptionalValue(preset.DebugTryCompile, parent.DebugTryCompile);
InheritOptionalValue(preset.DebugFind, parent.DebugFind);
InheritOptionalValue(preset.TraceMode, parent.TraceMode);
InheritOptionalValue(preset.TraceFormat, parent.TraceFormat);
InheritVector(preset.TraceSource, parent.TraceSource);
InheritString(preset.TraceRedirect, parent.TraceRedirect);
return true;
}
+13
View File
@@ -14,6 +14,19 @@
"find": true,
"tryCompile": true
}
},
{
"name": "DebugInherit",
"inherits": "Debug"
},
{
"name": "DebugInheritOverride",
"inherits": "Debug",
"debug": {
"output": false,
"find": false,
"tryCompile": false
}
}
]
}
@@ -0,0 +1,2 @@
find_package considered the following locations for
ThisPackageHopefullyDoesNotExist's Config module:
@@ -0,0 +1,4 @@
-- Generating [^
]*/Tests/RunCMake/CMakePresets/DebugInherit/build
Called from: \[1\][^
]*/Tests/RunCMake/CMakePresets/DebugInherit/CMakeLists\.txt
@@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/Debug.cmake)
@@ -0,0 +1,2 @@
-- Configuring done \([0-9]+\.[0-9]s\)
-- Generating done \([0-9]+\.[0-9]s\)
@@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/NoDebug.cmake)
@@ -371,6 +371,8 @@ unset(CMakePresets_WARN_UNUSED_CLI)
set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/Debug.json.in")
run_cmake_presets(NoDebug)
run_cmake_presets(Debug)
run_cmake_presets(DebugInherit)
run_cmake_presets(DebugInheritOverride)
# Test trace
set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/Trace.json.in")
@@ -383,6 +385,11 @@ run_cmake_presets(TraceFormatHuman)
run_cmake_presets(TraceSource)
run_cmake_presets(TraceRedirect)
run_cmake_presets(TraceAll)
run_cmake_presets(TraceInherit)
run_cmake_presets(TraceInheritOverride)
run_cmake_presets(TraceFormatInherit)
run_cmake_presets(TraceSourceInherit)
run_cmake_presets(TraceRedirectInherit)
# Test ${hostSystemName} macro
set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/HostSystemName.json.in")
+23
View File
@@ -64,6 +64,29 @@
"source": "TraceSourceFile.txt",
"redirect": "TraceRedirectFile.json"
}
},
{
"name": "TraceInherit",
"inherits": "Trace"
},
{
"name": "TraceInheritOverride",
"inherits": "Trace",
"trace": {
"mode": "off"
}
},
{
"name": "TraceFormatInherit",
"inherits": "TraceFormatJSON"
},
{
"name": "TraceSourceInherit",
"inherits": "TraceSource"
},
{
"name": "TraceRedirectInherit",
"inherits": "TraceRedirect"
}
]
}
@@ -0,0 +1,3 @@
^{"version":{"major":1,"minor":2}}
{"args":\["VERSION","3\.18"\],"cmd":"cmake_minimum_required","file":"[^"]*/Tests/RunCMake/CMakePresets/TraceFormatInherit/CMakeLists\.txt","frame":1,"global_frame":1,"line":1,"time":[0-9\.]+}
{"args":\["\${RunCMake_TEST}","NONE"\],"cmd":"project","file":"[^"]*/Tests/RunCMake/CMakePresets/TraceFormatInherit/CMakeLists\.txt","frame":1,"global_frame":1,"line":2,"time":[0-9\.]+}
@@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/TraceFormatJSON.cmake)
@@ -0,0 +1,4 @@
^[^
]*/Tests/RunCMake/CMakePresets/TraceInherit/CMakeLists\.txt\(1\): cmake_minimum_required\(VERSION 3\.18 \)
[^
]*/Tests/RunCMake/CMakePresets/TraceInherit/CMakeLists\.txt\(2\): project\(\${RunCMake_TEST} NONE \)
@@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/Trace.cmake)
@@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/NoTrace.cmake)
@@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/TraceRedirect.cmake)
@@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/TraceSource.cmake)