presets: CONFIGURE_PRESET_UNREACHABLE_FROM_FILE when the configuration preset is reachable
https://discourse.cmake.org/t/cmakepreset-include-behavior/8379
In Source/cmCMakePresetsGraph.cxx you can find the following code:
if (!it.second.Unexpanded.OriginFile->ReachableFiles.count(
configurePreset->second.Unexpanded.OriginFile)) {
cmCMakePresetErrors::CONFIGURE_PRESET_UNREACHABLE_FROM_FILE(
it.first, &this->parseState);
return false;
}
This seems fishy. Here is some code to illustrate my point.
auto foo = it.second.Unexpanded.OriginFile;
auto bar = configurePreset->second.Unexpanded.OriginFile;
auto counter1 = foo->ReachableFiles.count(bar);
auto counter2 = bar->ReachableFiles.count(foo);
if (!counter2) {
cmCMakePresetErrors::CONFIGURE_PRESET_UNREACHABLE_FROM_FILE(
it.first, &this->parseState);
return false;
}
In this code...
counter1 will be 0 unless the configurePreset
of foo (it.second.Unexpanded.OriginFile) is found in foo.
counter2 will be 1 if the configurePreset
of foo (it.second.Unexpanded.OriginFile) is found in bar (configurePreset->second.Unexpanded.OriginFile).
Specifically, the configurePreset->second.Unexpanded.OriginFile
has many (in my test case 73) reachable files; while the it.second.Unexpanded.OriginFile
only has one reachable file (itself).
I suspect what was intended may have been...
if (!configurePreset->second.Unexpanded.OriginFile->ReachableFiles.count(
it.second.Unexpanded.OriginFile)) {
cmCMakePresetErrors::CONFIGURE_PRESET_UNREACHABLE_FROM_FILE(
it.first, &this->parseState);
return false;
}
That being said, I think the error message should report both the preset and the configurePreset; currently only the current preset is included.
This fragment is repeated for build, test, and package presets.