From 0429a37e482219480ce7426b035d3abd822d99d3 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Sat, 18 Feb 2023 21:57:39 +0100 Subject: Kate: enable the ninja multiconfig generator for kate Kate can work as well with the multi-config version of ninja. Additionally, add the "/fast" targets only for make, not for ninja. --- Source/cmExtraKateGenerator.cxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index a128a8b..2707e09 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -35,6 +35,7 @@ cmExternalMakefileProjectGeneratorFactory* cmExtraKateGenerator::GetFactory() // factory.AddSupportedGlobalGenerator("MSYS Makefiles"); #endif factory.AddSupportedGlobalGenerator("Ninja"); + factory.AddSupportedGlobalGenerator("Ninja Multi-Config"); factory.AddSupportedGlobalGenerator("Unix Makefiles"); } @@ -48,7 +49,9 @@ void cmExtraKateGenerator::Generate() this->ProjectName = this->GenerateProjectName( lg->GetProjectName(), mf->GetSafeDefinition("CMAKE_BUILD_TYPE"), this->GetPathBasename(lg->GetBinaryDirectory())); - this->UseNinja = (this->GlobalGenerator->GetName() == "Ninja"); + this->UseNinja = + ((this->GlobalGenerator->GetName() == "Ninja") || + (this->GlobalGenerator->GetName() == "Ninja Multi-Config")); this->CreateKateProjectFile(*lg); this->CreateDummyKateProjectFile(*lg); @@ -164,9 +167,11 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator& lg, case cmStateEnums::OBJECT_LIBRARY: { this->AppendTarget(fout, targetName, make, makeArgs, currentDir, homeOutputDir); - std::string fastTarget = cmStrCat(targetName, "/fast"); - this->AppendTarget(fout, fastTarget, make, makeArgs, currentDir, - homeOutputDir); + if (!this->UseNinja) { + std::string fastTarget = cmStrCat(targetName, "/fast"); + this->AppendTarget(fout, fastTarget, make, makeArgs, currentDir, + homeOutputDir); + } } break; default: -- cgit v0.12 From f6f8f89e6cc03da0c423a239f47a161dab3c7cb2 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Sat, 18 Feb 2023 23:23:11 +0100 Subject: Kate: support for the targets of multi config ninja With this patch, cmake now generates the targets once for each config into the kate project file, so users can build the targets for all configs with this generator. --- Source/cmExtraKateGenerator.cxx | 58 +++++++++++++++++++++++------------------ Source/cmExtraKateGenerator.h | 1 + 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index 2707e09..6e6d009 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -85,6 +85,7 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator& lg, const std::string& makeArgs = mf->GetSafeDefinition("CMAKE_KATE_MAKE_ARGUMENTS"); std::string const& homeOutputDir = lg.GetBinaryDirectory(); + const auto configs = mf->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); /* clang-format off */ fout << @@ -108,16 +109,16 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator& lg, // this is for kate >= 4.13: fout << "\t\t\"targets\":[\n"; - this->AppendTarget(fout, "all", make, makeArgs, homeOutputDir, + this->AppendTarget(fout, "all", configs, make, makeArgs, homeOutputDir, homeOutputDir); - this->AppendTarget(fout, "clean", make, makeArgs, homeOutputDir, + this->AppendTarget(fout, "clean", configs, make, makeArgs, homeOutputDir, homeOutputDir); // add all executable and library targets and some of the GLOBAL // and UTILITY targets for (const auto& localGen : this->GlobalGenerator->GetLocalGenerators()) { const auto& targets = localGen->GetGeneratorTargets(); - std::string currentDir = localGen->GetCurrentBinaryDirectory(); + const std::string currentDir = localGen->GetCurrentBinaryDirectory(); bool topLevel = (currentDir == localGen->GetBinaryDirectory()); for (const auto& target : targets) { @@ -141,8 +142,8 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator& lg, } } if (insertTarget) { - this->AppendTarget(fout, targetName, make, makeArgs, currentDir, - homeOutputDir); + this->AppendTarget(fout, targetName, configs, make, makeArgs, + currentDir, homeOutputDir); } } break; case cmStateEnums::UTILITY: @@ -157,20 +158,20 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator& lg, break; } - this->AppendTarget(fout, targetName, make, makeArgs, currentDir, - homeOutputDir); + this->AppendTarget(fout, targetName, configs, make, makeArgs, + currentDir, homeOutputDir); break; case cmStateEnums::EXECUTABLE: case cmStateEnums::STATIC_LIBRARY: case cmStateEnums::SHARED_LIBRARY: case cmStateEnums::MODULE_LIBRARY: case cmStateEnums::OBJECT_LIBRARY: { - this->AppendTarget(fout, targetName, make, makeArgs, currentDir, - homeOutputDir); + this->AppendTarget(fout, targetName, configs, make, makeArgs, + currentDir, homeOutputDir); if (!this->UseNinja) { std::string fastTarget = cmStrCat(targetName, "/fast"); - this->AppendTarget(fout, fastTarget, make, makeArgs, currentDir, - homeOutputDir); + this->AppendTarget(fout, fastTarget, configs, make, makeArgs, + currentDir, homeOutputDir); } } break; @@ -184,29 +185,36 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator& lg, std::vector objectFileTargets; localGen->GetIndividualFileTargets(objectFileTargets); for (std::string const& f : objectFileTargets) { - this->AppendTarget(fout, f, make, makeArgs, currentDir, homeOutputDir); + this->AppendTarget(fout, f, configs, make, makeArgs, currentDir, + homeOutputDir); } } fout << "\t] }\n"; } -void cmExtraKateGenerator::AppendTarget(cmGeneratedFileStream& fout, - const std::string& target, - const std::string& make, - const std::string& makeArgs, - const std::string& path, - const std::string& homeOutputDir) const +void cmExtraKateGenerator::AppendTarget( + cmGeneratedFileStream& fout, const std::string& target, + const std::vector& configs, const std::string& make, + const std::string& makeArgs, const std::string& path, + const std::string& homeOutputDir) const { static char JsonSep = ' '; - fout << "\t\t\t" << JsonSep << R"({"name":")" << target - << "\", " - "\"build_cmd\":\"" - << make << " -C \\\"" << (this->UseNinja ? homeOutputDir : path) - << "\\\" " << makeArgs << " " << target << "\"}\n"; - - JsonSep = ','; + for (const std::string& conf : configs) { + fout << "\t\t\t" << JsonSep << R"({"name":")" << target + << ((configs.size() > 1) ? (std::string(":") + conf) : std::string()) + << "\", " + "\"build_cmd\":\"" + << make << " -C \\\"" << (this->UseNinja ? homeOutputDir : path) + << "\\\" " + << ((this->UseNinja && configs.size() > 1) + ? std::string(" -f build-") + conf + ".ninja" + : std::string()) + << makeArgs << " " << target << "\"}\n"; + + JsonSep = ','; + } } void cmExtraKateGenerator::CreateDummyKateProjectFile( diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h index c66ddbf..9ffcac4 100644 --- a/Source/cmExtraKateGenerator.h +++ b/Source/cmExtraKateGenerator.h @@ -29,6 +29,7 @@ private: void WriteTargets(const cmLocalGenerator& lg, cmGeneratedFileStream& fout) const; void AppendTarget(cmGeneratedFileStream& fout, const std::string& target, + const std::vector& configs, const std::string& make, const std::string& makeArgs, const std::string& path, const std::string& homeOutputDir) const; -- cgit v0.12 From 2b713b0f9590831e24c8771768ffd0710c7198ce Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Sat, 18 Feb 2023 23:34:09 +0100 Subject: Kate: mention Ninja Multiconfig in the docs --- Help/generator/Kate.rst | 3 +++ Source/cmExtraKateGenerator.h | 1 + 2 files changed, 4 insertions(+) diff --git a/Help/generator/Kate.rst b/Help/generator/Kate.rst index d12723b..11354f2 100644 --- a/Help/generator/Kate.rst +++ b/Help/generator/Kate.rst @@ -28,5 +28,8 @@ This "extra" generator may be specified as: ``Kate - Ninja`` Generate with :generator:`Ninja`. +``Kate - Ninja Multi-Config`` + Generate with :generator:`Ninja Multi-Config`. + ``Kate - Unix Makefiles`` Generate with :generator:`Unix Makefiles`. diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h index 9ffcac4..203fa2f 100644 --- a/Source/cmExtraKateGenerator.h +++ b/Source/cmExtraKateGenerator.h @@ -5,6 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep #include +#include #include "cmExternalMakefileProjectGenerator.h" -- cgit v0.12