mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-20 21:28:23 -05:00
cmCxxModuleMapper: give transitive usages to Clang as well
In the future, Clang plans to require transitive module usage to be specified on the command line. This is in order to keep BMI files more reproducible. Handily, MSVC has already required this, so the logic can be reused for Clang easily. See: https://github.com/llvm/llvm-project/commit/e22fa1d4c6152d36cf1342ab9029adc97c79a310 See: https://github.com/llvm/llvm-project/issues/62707 See: https://discourse.llvm.org/t/c-20-modules-should-the-bmis-contain-paths-to-their-dependent-bmis/70422
This commit is contained in:
@@ -128,7 +128,8 @@ std::vector<TransitiveUsage> GetTransitiveUsages(
|
||||
}
|
||||
|
||||
std::string CxxModuleMapContentClang(CxxModuleLocations const& loc,
|
||||
cmScanDepInfo const& obj)
|
||||
cmScanDepInfo const& obj,
|
||||
CxxModuleUsage const& usages)
|
||||
{
|
||||
std::stringstream mm;
|
||||
|
||||
@@ -151,12 +152,11 @@ std::string CxxModuleMapContentClang(CxxModuleLocations const& loc,
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (auto const& r : obj.Requires) {
|
||||
auto bmi_loc = loc.BmiGeneratorPathForModule(r.LogicalName);
|
||||
if (bmi_loc.IsKnown()) {
|
||||
mm << "-fmodule-file=" << r.LogicalName << "=" << bmi_loc.Location()
|
||||
<< '\n';
|
||||
}
|
||||
|
||||
auto all_usages = GetTransitiveUsages(loc, obj.Requires, usages);
|
||||
for (auto const& usage : all_usages) {
|
||||
mm << "-fmodule-file=" << usage.LogicalName << '=' << usage.Location
|
||||
<< '\n';
|
||||
}
|
||||
|
||||
return mm.str();
|
||||
@@ -420,7 +420,7 @@ std::string CxxModuleMapContent(CxxModuleMapFormat format,
|
||||
{
|
||||
switch (format) {
|
||||
case CxxModuleMapFormat::Clang:
|
||||
return CxxModuleMapContentClang(loc, obj);
|
||||
return CxxModuleMapContentClang(loc, obj, usages);
|
||||
case CxxModuleMapFormat::Gcc:
|
||||
return CxxModuleMapContentGcc(loc, obj);
|
||||
case CxxModuleMapFormat::Msvc:
|
||||
|
||||
Reference in New Issue
Block a user