diff options
author | Kulla Christoph <christoph.kulla@de.bosch.com> | 2016-08-05 12:39:31 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-08-30 13:05:18 (GMT) |
commit | 048d1adb4ede50e49dce00873a5961e424e149f9 (patch) | |
tree | 2f7ec3c0e5a773820c8cd74efa90c12124bbcce3 /Source/cmAddCustomCommandCommand.cxx | |
parent | 98caa14cc84cc659c2c5b51f84c6547b57c89c30 (diff) | |
download | CMake-048d1adb4ede50e49dce00873a5961e424e149f9.zip CMake-048d1adb4ede50e49dce00873a5961e424e149f9.tar.gz CMake-048d1adb4ede50e49dce00873a5961e424e149f9.tar.bz2 |
add_custom_command: Add DEPFILE option for Ninja
Provide a way for custom commands to inform the ninja build tool about
their implicit dependencies. For now simply make use of the option an
error on other generators.
Closes: #15479
Diffstat (limited to 'Source/cmAddCustomCommandCommand.cxx')
-rw-r--r-- | Source/cmAddCustomCommandCommand.cxx | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 400be77..2c4a4ca 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -15,6 +15,8 @@ #include "cmSourceFile.h" +#include "cmGlobalGenerator.h" + // cmAddCustomCommandCommand bool cmAddCustomCommandCommand::InitialPass( std::vector<std::string> const& args, cmExecutionStatus&) @@ -28,7 +30,7 @@ bool cmAddCustomCommandCommand::InitialPass( return false; } - std::string source, target, main_dependency, working; + std::string source, target, main_dependency, working, depfile; std::string comment_buffer; const char* comment = CM_NULLPTR; std::vector<std::string> depends, outputs, output, byproducts; @@ -60,6 +62,7 @@ bool cmAddCustomCommandCommand::InitialPass( doing_byproducts, doing_comment, doing_working_directory, + doing_depfile, doing_nothing }; @@ -110,6 +113,13 @@ bool cmAddCustomCommandCommand::InitialPass( doing = doing_implicit_depends_lang; } else if (copy == "COMMENT") { doing = doing_comment; + } else if (copy == "DEPFILE") { + doing = doing_depfile; + if (this->Makefile->GetGlobalGenerator()->GetName() != "Ninja") { + this->SetError("Option DEPFILE not supported by " + + this->Makefile->GetGlobalGenerator()->GetName()); + return false; + } } else { std::string filename; switch (doing) { @@ -147,6 +157,9 @@ bool cmAddCustomCommandCommand::InitialPass( filename = cmSystemTools::CollapseFullPath(filename); } switch (doing) { + case doing_depfile: + depfile = copy; + break; case doing_working_directory: working = copy; break; @@ -269,12 +282,12 @@ bool cmAddCustomCommandCommand::InitialPass( std::vector<std::string> no_depends; this->Makefile->AddCustomCommandToTarget( target, byproducts, no_depends, commandLines, cctype, comment, - working.c_str(), escapeOldStyle, uses_terminal); + working.c_str(), escapeOldStyle, uses_terminal, depfile); } else if (target.empty()) { // Target is empty, use the output. this->Makefile->AddCustomCommandToOutput( output, byproducts, depends, main_dependency, commandLines, comment, - working.c_str(), false, escapeOldStyle, uses_terminal); + working.c_str(), false, escapeOldStyle, uses_terminal, depfile); // Add implicit dependency scanning requests if any were given. if (!implicit_depends.empty()) { |