diff options
author | Brad King <brad.king@kitware.com> | 2024-02-16 14:40:07 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-02-16 14:40:07 (GMT) |
commit | fb0988a276438f68f0d4d6b17a1ed381a050d6d0 (patch) | |
tree | d0b3091970b3a44f529940885ffcf9c913e475f2 | |
parent | d713896171114d6c43b06e9345ced6e40101edd6 (diff) | |
parent | 3f8a59a05c7d2c65020bd2a756d2c6d5a196bec2 (diff) | |
download | CMake-fb0988a276438f68f0d4d6b17a1ed381a050d6d0.zip CMake-fb0988a276438f68f0d4d6b17a1ed381a050d6d0.tar.gz CMake-fb0988a276438f68f0d4d6b17a1ed381a050d6d0.tar.bz2 |
Merge topic 'cxxmodules-dyndep-error-on-private-usage' into release-3.28
3f8a59a05c cxxmodules: return failure from the collator when private usage is found
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9257
-rw-r--r-- | Source/cmCxxModuleMapper.cxx | 3 | ||||
-rw-r--r-- | Source/cmCxxModuleMapper.h | 2 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 8 |
3 files changed, 10 insertions, 3 deletions
diff --git a/Source/cmCxxModuleMapper.cxx b/Source/cmCxxModuleMapper.cxx index f45c011..b6b9540 100644 --- a/Source/cmCxxModuleMapper.cxx +++ b/Source/cmCxxModuleMapper.cxx @@ -305,7 +305,7 @@ cm::static_string_view CxxModuleMapExtension( std::set<std::string> CxxModuleUsageSeed( CxxModuleLocations const& loc, std::vector<cmScanDepInfo> const& objects, - CxxModuleUsage& usages) + CxxModuleUsage& usages, bool& private_usage_found) { // Track inner usages to populate usages from internal bits. // @@ -334,6 +334,7 @@ std::set<std::string> CxxModuleUsageSeed( cmStrCat("Unable to use module '", r.LogicalName, "' as it is 'PRIVATE' and therefore not accessible outside " "of its owning target.")); + private_usage_found = true; continue; } diff --git a/Source/cmCxxModuleMapper.h b/Source/cmCxxModuleMapper.h index 34111f7..c785099 100644 --- a/Source/cmCxxModuleMapper.h +++ b/Source/cmCxxModuleMapper.h @@ -93,7 +93,7 @@ cm::static_string_view CxxModuleMapExtension( // import cycle). std::set<std::string> CxxModuleUsageSeed( CxxModuleLocations const& loc, std::vector<cmScanDepInfo> const& objects, - CxxModuleUsage& usages); + CxxModuleUsage& usages, bool& private_usage_found); // Return the contents of the module map in the given format for the // object file. diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 4fa5032..6acdc34 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -2719,7 +2719,9 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( // Insert information about the current target's modules. if (modmap_fmt) { - auto cycle_modules = CxxModuleUsageSeed(locs, objects, usages); + bool private_usage_found = false; + auto cycle_modules = + CxxModuleUsageSeed(locs, objects, usages, private_usage_found); if (!cycle_modules.empty()) { cmSystemTools::Error( cmStrCat("Circular dependency detected in the C++ module import " @@ -2727,6 +2729,10 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( cmJoin(cycle_modules, R"(", ")"_s), '"')); return false; } + if (private_usage_found) { + // Already errored in the function. + return false; + } } cmNinjaBuild build("dyndep"); |