VS: Fix regression in Fortran project generation

Since commit de2afc5d53 (cmMakeFile: Remove source groups argument from
`FindSourceGroup`, 2025-11-07, v4.3.0-rc1~414^2~2) we share source group
assignments across targets to avoid copying and repeated work.  Fix the
VS 7 generator, still used for Fortran, to avoid assuming that all
source group members are in the current target.

Fixes: #27707
This commit is contained in:
Brad King
2026-03-23 21:42:56 -04:00
parent 7178780043
commit 1146a66d60
+7 -6
View File
@@ -3,7 +3,6 @@
#include "cmLocalVisualStudio7Generator.h"
#include <algorithm>
#include <cassert>
#include <cstring>
#include <functional>
#include <sstream>
@@ -1681,17 +1680,19 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
// Loop through each source in the source group.
for (cmSourceFile const* sf : sourceFiles) {
// We only need source group members that are part of this target.
auto si = sources.Index.find(sf);
if (si == sources.Index.end()) {
continue;
}
std::string source = sf->GetFullPath();
if (source != libName || target->GetType() == cmStateEnums::UTILITY ||
target->GetType() == cmStateEnums::GLOBAL_TARGET ||
target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
// Look up the source kind and configs.
auto map_it = sources.Index.find(sf);
// The map entry must exist because we populated it earlier.
assert(map_it != sources.Index.end());
cmGeneratorTarget::AllConfigSource const& acs =
sources.Sources[map_it->second];
sources.Sources[si->second];
FCInfo fcinfo(this, target, acs, configs);