diff options
author | Brad King <brad.king@kitware.com> | 2023-03-21 12:58:16 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-03-21 12:58:43 (GMT) |
commit | ca8c171021369f535fa18013796cc0b8f9cbd4fc (patch) | |
tree | fe86b75fd9f168720d40c29d0763af751ddba1ab /Source/cmGlobalNinjaGenerator.cxx | |
parent | 5f8929f721966f7560d18811126d74553af3df5f (diff) | |
parent | 1b7c26da49e7e1a337f66951424bda8d3f4067fc (diff) | |
download | CMake-ca8c171021369f535fa18013796cc0b8f9cbd4fc.zip CMake-ca8c171021369f535fa18013796cc0b8f9cbd4fc.tar.gz CMake-ca8c171021369f535fa18013796cc0b8f9cbd4fc.tar.bz2 |
Merge topic 'clang-windows-cxx-modules'
1b7c26da49 Ninja: Wrap rules using '>' shell redirection with 'cmd /C' on Windows
ffd8537acf Clang: Record Clang 16.0 C++ modules flags only for GNU-like front-end
6013227230 cmGlobalNinjaGenerator: Use forward slashes in clang modmap format on Windows
d9d74b5e8a cmDyndepCollation: Drop outdated mentions of CXX_MODULE_INTERNAL_PARTITIONS
edab56d29a cmLocalNinjaGenerator: De-duplicate condition for using 'cmd /C' on Windows
8ebe3f92b3 cmGlobalNinjaGenerator: Detect GNU-like command-line for dyndep collator
f3ca199c9b cmGlobalNinjaGenerator: Factor out GNU-like command-line detection on Windows
f79817fcf0 cmCxxModuleMapper: Use value semantics in path conversion callback
...
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8346
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 650d0aa..37856d9 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -63,6 +63,19 @@ std::string const cmGlobalNinjaGenerator::SHELL_NOOP = "cd ."; std::string const cmGlobalNinjaGenerator::SHELL_NOOP = ":"; #endif +namespace { +#ifdef _WIN32 +bool DetectGCCOnWindows(cm::string_view compilerId, cm::string_view simulateId, + cm::string_view compilerFrontendVariant) +{ + return ((compilerId == "Clang"_s && compilerFrontendVariant == "GNU"_s) || + (simulateId != "MSVC"_s && + (compilerId == "GNU"_s || compilerId == "QCC"_s || + cmHasLiteralSuffix(compilerId, "Clang")))); +} +#endif +} + bool operator==( const cmGlobalNinjaGenerator::ByConfig::TargetDependsClosureKey& lhs, const cmGlobalNinjaGenerator::ByConfig::TargetDependsClosureKey& rhs) @@ -936,12 +949,8 @@ void cmGlobalNinjaGenerator::EnableLanguage( mf->GetSafeDefinition(cmStrCat("CMAKE_", l, "_SIMULATE_ID")); std::string const& compilerFrontendVariant = mf->GetSafeDefinition( cmStrCat("CMAKE_", l, "_COMPILER_FRONTEND_VARIANT")); - if ((compilerId == "Clang" && compilerFrontendVariant == "GNU") || - (simulateId != "MSVC" && - (compilerId == "GNU" || compilerId == "QCC" || - cmHasLiteralSuffix(compilerId, "Clang")))) { - this->UsingGCCOnWindows = true; - } + this->SetUsingGCCOnWindows( + DetectGCCOnWindows(compilerId, simulateId, compilerFrontendVariant)); #endif } } @@ -2629,8 +2638,14 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( { CxxModuleLocations locs; locs.RootDirectory = "."; - locs.PathForGenerator = [this](std::string const& path) -> std::string { - return this->ConvertToNinjaPath(path); + locs.PathForGenerator = [this](std::string path) -> std::string { + path = this->ConvertToNinjaPath(path); +# ifdef _WIN32 + if (this->IsGCCOnWindows()) { + std::replace(path.begin(), path.end(), '\\', '/'); + } +# endif + return path; }; locs.BmiLocationForModule = [&mod_files](std::string const& logical) -> cm::optional<std::string> { @@ -2811,6 +2826,10 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg, linked_target_dirs.push_back(tdi_linked_target_dir.asString()); } } + std::string const compilerId = tdi["compiler-id"].asString(); + std::string const simulateId = tdi["compiler-simulate-id"].asString(); + std::string const compilerFrontendVariant = + tdi["compiler-frontend-variant"].asString(); auto export_info = cmDyndepCollation::ParseExportInfo(tdi); @@ -2818,14 +2837,20 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg, cm.SetHomeDirectory(dir_top_src); cm.SetHomeOutputDirectory(dir_top_bld); auto ggd = cm.CreateGlobalGenerator("Ninja"); - if (!ggd || - !cm::static_reference_cast<cmGlobalNinjaGenerator>(ggd).WriteDyndepFile( - dir_top_src, dir_top_bld, dir_cur_src, dir_cur_bld, arg_dd, arg_ddis, - module_dir, linked_target_dirs, arg_lang, arg_modmapfmt, - *export_info)) { + if (!ggd) { return 1; } - return 0; + cmGlobalNinjaGenerator& gg = + cm::static_reference_cast<cmGlobalNinjaGenerator>(ggd); +# ifdef _WIN32 + gg.SetUsingGCCOnWindows( + DetectGCCOnWindows(compilerId, simulateId, compilerFrontendVariant)); +# endif + return gg.WriteDyndepFile(dir_top_src, dir_top_bld, dir_cur_src, dir_cur_bld, + arg_dd, arg_ddis, module_dir, linked_target_dirs, + arg_lang, arg_modmapfmt, *export_info) + ? 0 + : 1; } #endif |