add_custom_command: Add CODEGEN support

By specifying CODEGEN as an argument to add_custom_command the
custom command will be added to a codegen build target.

The intent is to provide a convenient way for users to get
their generated files without having to build the whole project.

This can be helpful for code analysis tools which can be useful
for IDEs and CI.
This commit is contained in:
Juan Ramos
2024-05-27 20:19:05 -07:00
committed by Brad King
parent 033713530a
commit 197cb419d1
64 changed files with 733 additions and 3 deletions

View File

@@ -1763,6 +1763,21 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
this->WriteMakeRule(ruleFileStream, "The main all target", "all", depends,
commands, true);
// Write the codegen rule.
if (this->GetGlobalGenerator()->CheckCMP0171()) {
recursiveTarget = cmStrCat(this->GetCurrentBinaryDirectory(), "/codegen");
depends.clear();
commands.clear();
if (regenerate) {
depends.emplace_back("cmake_check_build_system");
}
commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget));
AppendEcho(commands, "Finished generating code",
cmLocalUnixMakefileGenerator3::EchoColor::EchoGenerate);
this->WriteMakeRule(ruleFileStream, "The main codegen target", "codegen",
depends, commands, true);
}
// Write the clean rule.
recursiveTarget = cmStrCat(this->GetCurrentBinaryDirectory(), "/clean");
commands.clear();