mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-03 12:49:50 -05:00
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.
This commit is contained in:
@@ -85,6 +85,7 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator& lg,
|
|||||||
const std::string& makeArgs =
|
const std::string& makeArgs =
|
||||||
mf->GetSafeDefinition("CMAKE_KATE_MAKE_ARGUMENTS");
|
mf->GetSafeDefinition("CMAKE_KATE_MAKE_ARGUMENTS");
|
||||||
std::string const& homeOutputDir = lg.GetBinaryDirectory();
|
std::string const& homeOutputDir = lg.GetBinaryDirectory();
|
||||||
|
const auto configs = mf->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
|
||||||
|
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
fout <<
|
fout <<
|
||||||
@@ -108,16 +109,16 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator& lg,
|
|||||||
// this is for kate >= 4.13:
|
// this is for kate >= 4.13:
|
||||||
fout << "\t\t\"targets\":[\n";
|
fout << "\t\t\"targets\":[\n";
|
||||||
|
|
||||||
this->AppendTarget(fout, "all", make, makeArgs, homeOutputDir,
|
this->AppendTarget(fout, "all", configs, make, makeArgs, homeOutputDir,
|
||||||
homeOutputDir);
|
homeOutputDir);
|
||||||
this->AppendTarget(fout, "clean", make, makeArgs, homeOutputDir,
|
this->AppendTarget(fout, "clean", configs, make, makeArgs, homeOutputDir,
|
||||||
homeOutputDir);
|
homeOutputDir);
|
||||||
|
|
||||||
// add all executable and library targets and some of the GLOBAL
|
// add all executable and library targets and some of the GLOBAL
|
||||||
// and UTILITY targets
|
// and UTILITY targets
|
||||||
for (const auto& localGen : this->GlobalGenerator->GetLocalGenerators()) {
|
for (const auto& localGen : this->GlobalGenerator->GetLocalGenerators()) {
|
||||||
const auto& targets = localGen->GetGeneratorTargets();
|
const auto& targets = localGen->GetGeneratorTargets();
|
||||||
std::string currentDir = localGen->GetCurrentBinaryDirectory();
|
const std::string currentDir = localGen->GetCurrentBinaryDirectory();
|
||||||
bool topLevel = (currentDir == localGen->GetBinaryDirectory());
|
bool topLevel = (currentDir == localGen->GetBinaryDirectory());
|
||||||
|
|
||||||
for (const auto& target : targets) {
|
for (const auto& target : targets) {
|
||||||
@@ -141,8 +142,8 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator& lg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (insertTarget) {
|
if (insertTarget) {
|
||||||
this->AppendTarget(fout, targetName, make, makeArgs, currentDir,
|
this->AppendTarget(fout, targetName, configs, make, makeArgs,
|
||||||
homeOutputDir);
|
currentDir, homeOutputDir);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case cmStateEnums::UTILITY:
|
case cmStateEnums::UTILITY:
|
||||||
@@ -157,20 +158,20 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator& lg,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->AppendTarget(fout, targetName, make, makeArgs, currentDir,
|
this->AppendTarget(fout, targetName, configs, make, makeArgs,
|
||||||
homeOutputDir);
|
currentDir, homeOutputDir);
|
||||||
break;
|
break;
|
||||||
case cmStateEnums::EXECUTABLE:
|
case cmStateEnums::EXECUTABLE:
|
||||||
case cmStateEnums::STATIC_LIBRARY:
|
case cmStateEnums::STATIC_LIBRARY:
|
||||||
case cmStateEnums::SHARED_LIBRARY:
|
case cmStateEnums::SHARED_LIBRARY:
|
||||||
case cmStateEnums::MODULE_LIBRARY:
|
case cmStateEnums::MODULE_LIBRARY:
|
||||||
case cmStateEnums::OBJECT_LIBRARY: {
|
case cmStateEnums::OBJECT_LIBRARY: {
|
||||||
this->AppendTarget(fout, targetName, make, makeArgs, currentDir,
|
this->AppendTarget(fout, targetName, configs, make, makeArgs,
|
||||||
homeOutputDir);
|
currentDir, homeOutputDir);
|
||||||
if (!this->UseNinja) {
|
if (!this->UseNinja) {
|
||||||
std::string fastTarget = cmStrCat(targetName, "/fast");
|
std::string fastTarget = cmStrCat(targetName, "/fast");
|
||||||
this->AppendTarget(fout, fastTarget, make, makeArgs, currentDir,
|
this->AppendTarget(fout, fastTarget, configs, make, makeArgs,
|
||||||
homeOutputDir);
|
currentDir, homeOutputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
@@ -184,29 +185,36 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator& lg,
|
|||||||
std::vector<std::string> objectFileTargets;
|
std::vector<std::string> objectFileTargets;
|
||||||
localGen->GetIndividualFileTargets(objectFileTargets);
|
localGen->GetIndividualFileTargets(objectFileTargets);
|
||||||
for (std::string const& f : 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";
|
fout << "\t] }\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmExtraKateGenerator::AppendTarget(cmGeneratedFileStream& fout,
|
void cmExtraKateGenerator::AppendTarget(
|
||||||
const std::string& target,
|
cmGeneratedFileStream& fout, const std::string& target,
|
||||||
const std::string& make,
|
const std::vector<std::string>& configs, const std::string& make,
|
||||||
const std::string& makeArgs,
|
const std::string& makeArgs, const std::string& path,
|
||||||
const std::string& path,
|
const std::string& homeOutputDir) const
|
||||||
const std::string& homeOutputDir) const
|
|
||||||
{
|
{
|
||||||
static char JsonSep = ' ';
|
static char JsonSep = ' ';
|
||||||
|
|
||||||
fout << "\t\t\t" << JsonSep << R"({"name":")" << target
|
for (const std::string& conf : configs) {
|
||||||
<< "\", "
|
fout << "\t\t\t" << JsonSep << R"({"name":")" << target
|
||||||
"\"build_cmd\":\""
|
<< ((configs.size() > 1) ? (std::string(":") + conf) : std::string())
|
||||||
<< make << " -C \\\"" << (this->UseNinja ? homeOutputDir : path)
|
<< "\", "
|
||||||
<< "\\\" " << makeArgs << " " << target << "\"}\n";
|
"\"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 = ',';
|
JsonSep = ',';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmExtraKateGenerator::CreateDummyKateProjectFile(
|
void cmExtraKateGenerator::CreateDummyKateProjectFile(
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ private:
|
|||||||
void WriteTargets(const cmLocalGenerator& lg,
|
void WriteTargets(const cmLocalGenerator& lg,
|
||||||
cmGeneratedFileStream& fout) const;
|
cmGeneratedFileStream& fout) const;
|
||||||
void AppendTarget(cmGeneratedFileStream& fout, const std::string& target,
|
void AppendTarget(cmGeneratedFileStream& fout, const std::string& target,
|
||||||
|
const std::vector<std::string>& configs,
|
||||||
const std::string& make, const std::string& makeArgs,
|
const std::string& make, const std::string& makeArgs,
|
||||||
const std::string& path,
|
const std::string& path,
|
||||||
const std::string& homeOutputDir) const;
|
const std::string& homeOutputDir) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user