summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authornamniav <namniav@gmail.com>2023-12-04 04:28:33 (GMT)
committerBrad King <brad.king@kitware.com>2023-12-05 15:26:10 (GMT)
commite9b0dcbbfa51e26f0516c81d7ed3d4051cb539c0 (patch)
treedcf1d8102a5d7ea5a288fa8e2963bbc2c94d0056 /Source
parent3e8f0211378664665abc5e09503296eb4825b50a (diff)
downloadCMake-e9b0dcbbfa51e26f0516c81d7ed3d4051cb539c0.zip
CMake-e9b0dcbbfa51e26f0516c81d7ed3d4051cb539c0.tar.gz
CMake-e9b0dcbbfa51e26f0516c81d7ed3d4051cb539c0.tar.bz2
cmCxxModuleMapper: Fix transitive requirements computation
Previously CMake may generate incomplete transitive requirements in CMakeFiles/<target>.dir/CXXModules.json and therefore in module mapper for compiler, when source files were listed in CMakeList.txt in a certain order. This commit fixes the problem by correctly tracking unfinished transitive requirements computation of module units. There have been a simple circular test case whose circular dependency was reported by build system. Now with this correct implementation it's reported by CMake generating module mappers. Add two test cases for transitive requirements computation, one with adding source files in hardcoded order, and the other in randomized order. Fixes: #25465
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCxxModuleMapper.cxx13
1 files changed, 8 insertions, 5 deletions
diff --git a/Source/cmCxxModuleMapper.cxx b/Source/cmCxxModuleMapper.cxx
index e6c10c6..f45c011 100644
--- a/Source/cmCxxModuleMapper.cxx
+++ b/Source/cmCxxModuleMapper.cxx
@@ -346,13 +346,16 @@ std::set<std::string> CxxModuleUsageSeed(
// Add the direct usage.
this_usages.insert(r.LogicalName);
- // Add the transitive usage.
- if (transitive_usages != usages.Usage.end()) {
+ if (transitive_usages == usages.Usage.end() ||
+ internal_usages.find(r.LogicalName) != internal_usages.end()) {
+ // Mark that we need to update transitive usages later.
+ if (bmi_loc.IsKnown()) {
+ internal_usages[p.LogicalName].insert(r.LogicalName);
+ }
+ } else {
+ // Add the transitive usage.
this_usages.insert(transitive_usages->second.begin(),
transitive_usages->second.end());
- } else if (bmi_loc.IsKnown()) {
- // Mark that we need to update transitive usages later.
- internal_usages[p.LogicalName].insert(r.LogicalName);
}
}