From 1146a66d6074078361de0203eeb2429ed60c4e25 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 23 Mar 2026 21:32:30 -0400 Subject: [PATCH 1/3] 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 --- Source/cmLocalVisualStudio7Generator.cxx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 3d44ae8626..567ce3b280 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -3,7 +3,6 @@ #include "cmLocalVisualStudio7Generator.h" #include -#include #include #include #include @@ -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); From e75e91260106d03af738c73671f8738796ed37f5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 23 Mar 2026 22:04:30 -0400 Subject: [PATCH 2/3] Tests: Fix FortranCInterface test with MSVC+IntelLLVM --- Tests/FortranC/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/FortranC/CMakeLists.txt b/Tests/FortranC/CMakeLists.txt index 0c7d9c3200..59493e71d0 100644 --- a/Tests/FortranC/CMakeLists.txt +++ b/Tests/FortranC/CMakeLists.txt @@ -3,7 +3,7 @@ project(FortranC C Fortran) # Skip this test for compilers not known to be compatible. if(NOT (CMAKE_C_COMPILER_ID STREQUAL CMAKE_Fortran_COMPILER_ID OR - "${CMAKE_C_COMPILER_ID}-${CMAKE_Fortran_COMPILER_ID}" MATCHES "^(MSVC-Intel|(GNU|Clang)-(LLVMFlang|LFortran))$")) + "${CMAKE_C_COMPILER_ID}-${CMAKE_Fortran_COMPILER_ID}" MATCHES "^(MSVC-(Intel|IntelLLVM)|(GNU|Clang)-(LLVMFlang|LFortran))$")) message(STATUS "${CMAKE_C_COMPILER_ID} C and ${CMAKE_Fortran_COMPILER_ID} Fortran not known to be compatible!") return() endif() From a3801792853491c30856ca511cc19fb2e52d1ef3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 24 Mar 2026 09:48:57 -0400 Subject: [PATCH 3/3] Tests: Fix FortranOnly test with Intel Fortran VS integration --- Tests/FortranOnly/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt index d181ad5f66..a0c299dc20 100644 --- a/Tests/FortranOnly/CMakeLists.txt +++ b/Tests/FortranOnly/CMakeLists.txt @@ -200,7 +200,9 @@ if(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_OFF AND endif() # Test that we are safe from infinite include recursion in dependency scanner -# (SunPro Fortran compiler does not support recursive inclusion) -if (NOT CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro") +if (# The SunPro Fortran compiler does not support recursive inclusion + NOT CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" + # The Intel Fortran VS integration overflows its stack. + AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") add_executable(test_include_loop test_include_loop.F) endif()