2016-09-27 19:01:08 +00:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2001-11-07 21:47:38 +00:00
|
|
|
#include "cmAddCustomCommandCommand.h"
|
2005-02-22 15:32:44 +00:00
|
|
|
|
2016-10-25 18:35:04 +00:00
|
|
|
#include <sstream>
|
2001-11-07 21:47:38 +00:00
|
|
|
|
2016-10-25 18:35:04 +00:00
|
|
|
#include "cmCustomCommand.h"
|
|
|
|
#include "cmCustomCommandLines.h"
|
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmPolicies.h"
|
2006-10-04 19:24:26 +00:00
|
|
|
#include "cmSourceFile.h"
|
2016-10-25 18:35:04 +00:00
|
|
|
#include "cmSystemTools.h"
|
|
|
|
#include "cmTarget.h"
|
|
|
|
#include "cmake.h"
|
2006-10-04 19:24:26 +00:00
|
|
|
|
2016-10-25 18:35:04 +00:00
|
|
|
class cmExecutionStatus;
|
2016-08-05 12:39:31 +00:00
|
|
|
|
2001-11-07 21:47:38 +00:00
|
|
|
// cmAddCustomCommandCommand
|
2016-05-16 14:34:04 +00:00
|
|
|
bool cmAddCustomCommandCommand::InitialPass(
|
|
|
|
std::vector<std::string> const& args, cmExecutionStatus&)
|
2001-11-07 21:47:38 +00:00
|
|
|
{
|
2001-11-09 15:42:16 +00:00
|
|
|
/* Let's complain at the end of this function about the lack of a particular
|
2003-06-03 14:30:23 +00:00
|
|
|
arg. For the moment, let's say that COMMAND, and either TARGET or SOURCE
|
|
|
|
are required.
|
2001-11-09 15:33:22 +00:00
|
|
|
*/
|
2016-05-16 14:34:04 +00:00
|
|
|
if (args.size() < 4) {
|
|
|
|
this->SetError("called with wrong number of arguments.");
|
|
|
|
return false;
|
|
|
|
}
|
2001-11-08 19:34:51 +00:00
|
|
|
|
2016-08-05 12:39:31 +00:00
|
|
|
std::string source, target, main_dependency, working, depfile;
|
2006-09-28 20:40:35 +00:00
|
|
|
std::string comment_buffer;
|
2016-06-27 20:44:16 +00:00
|
|
|
const char* comment = CM_NULLPTR;
|
2014-11-13 23:54:52 +00:00
|
|
|
std::vector<std::string> depends, outputs, output, byproducts;
|
2006-09-28 15:30:49 +00:00
|
|
|
bool verbatim = false;
|
2006-10-04 19:24:26 +00:00
|
|
|
bool append = false;
|
2014-11-05 20:37:52 +00:00
|
|
|
bool uses_terminal = false;
|
2007-09-17 14:50:46 +00:00
|
|
|
std::string implicit_depends_lang;
|
|
|
|
cmCustomCommand::ImplicitDependsList implicit_depends;
|
2005-02-22 15:32:44 +00:00
|
|
|
|
|
|
|
// Accumulate one command line at a time.
|
|
|
|
cmCustomCommandLine currentLine;
|
|
|
|
|
|
|
|
// Save all command lines.
|
|
|
|
cmCustomCommandLines commandLines;
|
2001-11-08 19:34:51 +00:00
|
|
|
|
2003-06-03 14:30:23 +00:00
|
|
|
cmTarget::CustomCommandType cctype = cmTarget::POST_BUILD;
|
2006-03-10 18:06:26 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
enum tdoing
|
|
|
|
{
|
2001-11-09 15:33:22 +00:00
|
|
|
doing_source,
|
|
|
|
doing_command,
|
|
|
|
doing_target,
|
|
|
|
doing_depends,
|
2007-09-17 14:50:46 +00:00
|
|
|
doing_implicit_depends_lang,
|
|
|
|
doing_implicit_depends_file,
|
2003-06-03 14:30:23 +00:00
|
|
|
doing_main_dependency,
|
|
|
|
doing_output,
|
2001-11-09 15:33:22 +00:00
|
|
|
doing_outputs,
|
2014-11-13 23:54:52 +00:00
|
|
|
doing_byproducts,
|
2002-12-10 21:47:37 +00:00
|
|
|
doing_comment,
|
2006-02-08 15:58:36 +00:00
|
|
|
doing_working_directory,
|
2016-08-05 12:39:31 +00:00
|
|
|
doing_depfile,
|
2001-11-09 15:33:22 +00:00
|
|
|
doing_nothing
|
|
|
|
};
|
|
|
|
|
|
|
|
tdoing doing = doing_nothing;
|
2001-11-08 19:34:51 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
for (unsigned int j = 0; j < args.size(); ++j) {
|
2002-03-05 23:41:24 +00:00
|
|
|
std::string const& copy = args[j];
|
2001-11-09 15:33:22 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (copy == "SOURCE") {
|
2001-11-09 15:33:22 +00:00
|
|
|
doing = doing_source;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (copy == "COMMAND") {
|
2001-11-09 15:33:22 +00:00
|
|
|
doing = doing_command;
|
2005-02-22 15:32:44 +00:00
|
|
|
|
|
|
|
// Save the current command before starting the next command.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!currentLine.empty()) {
|
2005-02-22 15:32:44 +00:00
|
|
|
commandLines.push_back(currentLine);
|
|
|
|
currentLine.clear();
|
2001-11-09 15:33:22 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (copy == "PRE_BUILD") {
|
2003-06-03 14:30:23 +00:00
|
|
|
cctype = cmTarget::PRE_BUILD;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (copy == "PRE_LINK") {
|
2003-06-03 14:30:23 +00:00
|
|
|
cctype = cmTarget::PRE_LINK;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (copy == "POST_BUILD") {
|
2003-06-03 14:30:23 +00:00
|
|
|
cctype = cmTarget::POST_BUILD;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (copy == "VERBATIM") {
|
2006-09-28 15:30:49 +00:00
|
|
|
verbatim = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (copy == "APPEND") {
|
2006-10-04 19:24:26 +00:00
|
|
|
append = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (copy == "USES_TERMINAL") {
|
2014-11-05 20:37:52 +00:00
|
|
|
uses_terminal = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (copy == "TARGET") {
|
2001-11-09 15:33:22 +00:00
|
|
|
doing = doing_target;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (copy == "ARGS") {
|
2005-02-22 15:32:44 +00:00
|
|
|
// Ignore this old keyword.
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (copy == "DEPENDS") {
|
2001-11-09 15:33:22 +00:00
|
|
|
doing = doing_depends;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (copy == "OUTPUTS") {
|
2001-11-09 15:33:22 +00:00
|
|
|
doing = doing_outputs;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (copy == "OUTPUT") {
|
2003-06-03 14:30:23 +00:00
|
|
|
doing = doing_output;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (copy == "BYPRODUCTS") {
|
2014-11-13 23:54:52 +00:00
|
|
|
doing = doing_byproducts;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (copy == "WORKING_DIRECTORY") {
|
2006-02-08 15:58:36 +00:00
|
|
|
doing = doing_working_directory;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (copy == "MAIN_DEPENDENCY") {
|
2003-06-03 14:30:23 +00:00
|
|
|
doing = doing_main_dependency;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (copy == "IMPLICIT_DEPENDS") {
|
2007-09-17 14:50:46 +00:00
|
|
|
doing = doing_implicit_depends_lang;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (copy == "COMMENT") {
|
2002-12-10 21:47:37 +00:00
|
|
|
doing = doing_comment;
|
2016-08-05 12:39:31 +00:00
|
|
|
} 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;
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
} else {
|
2005-07-08 15:51:21 +00:00
|
|
|
std::string filename;
|
2016-05-16 14:34:04 +00:00
|
|
|
switch (doing) {
|
2003-06-03 14:30:23 +00:00
|
|
|
case doing_output:
|
2001-11-09 15:33:22 +00:00
|
|
|
case doing_outputs:
|
2014-11-13 23:54:52 +00:00
|
|
|
case doing_byproducts:
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!cmSystemTools::FileIsFullPath(copy.c_str())) {
|
2008-01-30 16:22:10 +00:00
|
|
|
// This is an output to be generated, so it should be
|
|
|
|
// under the build tree. CMake 2.4 placed this under the
|
|
|
|
// source tree. However the only case that this change
|
|
|
|
// will break is when someone writes
|
|
|
|
//
|
|
|
|
// add_custom_command(OUTPUT out.txt ...)
|
|
|
|
//
|
|
|
|
// and later references "${CMAKE_CURRENT_SOURCE_DIR}/out.txt".
|
|
|
|
// This is fairly obscure so we can wait for someone to
|
|
|
|
// complain.
|
2015-04-16 19:33:09 +00:00
|
|
|
filename = this->Makefile->GetCurrentBinaryDirectory();
|
2005-07-08 15:51:21 +00:00
|
|
|
filename += "/";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-07-08 15:51:21 +00:00
|
|
|
filename += copy;
|
2010-12-15 13:44:57 +00:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(filename);
|
2002-12-10 21:47:37 +00:00
|
|
|
break;
|
2005-08-08 16:00:42 +00:00
|
|
|
case doing_source:
|
2016-05-16 14:34:04 +00:00
|
|
|
// We do not want to convert the argument to SOURCE because
|
|
|
|
// that option is only available for backward compatibility.
|
|
|
|
// Old-style use of this command may use the SOURCE==TARGET
|
|
|
|
// trick which we must preserve. If we convert the source
|
|
|
|
// to a full path then it will no longer equal the target.
|
2001-11-09 15:33:22 +00:00
|
|
|
default:
|
2005-07-08 15:51:21 +00:00
|
|
|
break;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-07-08 15:51:21 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (cmSystemTools::FileIsFullPath(filename.c_str())) {
|
2014-05-28 18:16:39 +00:00
|
|
|
filename = cmSystemTools::CollapseFullPath(filename);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
switch (doing) {
|
2016-08-05 12:39:31 +00:00
|
|
|
case doing_depfile:
|
|
|
|
depfile = copy;
|
|
|
|
break;
|
2016-05-16 14:34:04 +00:00
|
|
|
case doing_working_directory:
|
|
|
|
working = copy;
|
|
|
|
break;
|
|
|
|
case doing_source:
|
|
|
|
source = copy;
|
|
|
|
break;
|
|
|
|
case doing_output:
|
|
|
|
output.push_back(filename);
|
|
|
|
break;
|
|
|
|
case doing_main_dependency:
|
|
|
|
main_dependency = copy;
|
|
|
|
break;
|
|
|
|
case doing_implicit_depends_lang:
|
|
|
|
implicit_depends_lang = copy;
|
|
|
|
doing = doing_implicit_depends_file;
|
|
|
|
break;
|
|
|
|
case doing_implicit_depends_file: {
|
|
|
|
// An implicit dependency starting point is also an
|
|
|
|
// explicit dependency.
|
|
|
|
std::string dep = copy;
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(dep);
|
|
|
|
depends.push_back(dep);
|
2007-09-17 14:50:46 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
// Add the implicit dependency language and file.
|
|
|
|
cmCustomCommand::ImplicitDependsPair entry(implicit_depends_lang,
|
|
|
|
dep);
|
|
|
|
implicit_depends.push_back(entry);
|
2007-09-17 14:50:46 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
// Switch back to looking for a language.
|
|
|
|
doing = doing_implicit_depends_lang;
|
|
|
|
} break;
|
|
|
|
case doing_command:
|
|
|
|
currentLine.push_back(copy);
|
|
|
|
break;
|
|
|
|
case doing_target:
|
|
|
|
target = copy;
|
|
|
|
break;
|
|
|
|
case doing_depends: {
|
|
|
|
std::string dep = copy;
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(dep);
|
|
|
|
depends.push_back(dep);
|
|
|
|
} break;
|
|
|
|
case doing_outputs:
|
|
|
|
outputs.push_back(filename);
|
|
|
|
break;
|
|
|
|
case doing_byproducts:
|
|
|
|
byproducts.push_back(filename);
|
|
|
|
break;
|
|
|
|
case doing_comment:
|
|
|
|
comment_buffer = copy;
|
|
|
|
comment = comment_buffer.c_str();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
this->SetError("Wrong syntax. Unknown type of argument.");
|
|
|
|
return false;
|
2001-11-09 15:33:22 +00:00
|
|
|
}
|
2001-11-07 21:47:38 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2001-11-08 19:34:51 +00:00
|
|
|
|
2005-02-22 15:32:44 +00:00
|
|
|
// Store the last command line finished.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!currentLine.empty()) {
|
2005-02-22 15:32:44 +00:00
|
|
|
commandLines.push_back(currentLine);
|
|
|
|
currentLine.clear();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-02-22 15:32:44 +00:00
|
|
|
|
|
|
|
// At this point we could complain about the lack of arguments. For
|
|
|
|
// the moment, let's say that COMMAND, TARGET are always required.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (output.empty() && target.empty()) {
|
2003-06-03 14:30:23 +00:00
|
|
|
this->SetError("Wrong syntax. A TARGET or OUTPUT must be specified.");
|
2001-11-09 15:33:22 +00:00
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2003-07-15 16:52:16 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (source.empty() && !target.empty() && !output.empty()) {
|
2006-03-10 18:06:26 +00:00
|
|
|
this->SetError(
|
|
|
|
"Wrong syntax. A TARGET and OUTPUT can not both be specified.");
|
2003-07-15 16:52:16 +00:00
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (append && output.empty()) {
|
2006-10-04 19:24:26 +00:00
|
|
|
this->SetError("given APPEND option with no OUTPUT.");
|
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-02-22 15:32:44 +00:00
|
|
|
|
2006-04-11 15:06:19 +00:00
|
|
|
// Make sure the output names and locations are safe.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!this->CheckOutputs(output) || !this->CheckOutputs(outputs) ||
|
|
|
|
!this->CheckOutputs(byproducts)) {
|
2005-03-22 13:36:40 +00:00
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2006-03-22 19:40:36 +00:00
|
|
|
|
2006-10-04 19:24:26 +00:00
|
|
|
// Check for an append request.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (append) {
|
2006-10-04 19:24:26 +00:00
|
|
|
// Lookup an existing command.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (cmSourceFile* sf =
|
|
|
|
this->Makefile->GetSourceFileWithOutput(output[0])) {
|
|
|
|
if (cmCustomCommand* cc = sf->GetCustomCommand()) {
|
2006-10-04 19:24:26 +00:00
|
|
|
cc->AppendCommands(commandLines);
|
|
|
|
cc->AppendDepends(depends);
|
2007-09-17 14:50:46 +00:00
|
|
|
cc->AppendImplicitDepends(implicit_depends);
|
2006-10-04 19:24:26 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2006-10-04 19:24:26 +00:00
|
|
|
|
|
|
|
// No command for this output exists.
|
2015-01-05 19:31:31 +00:00
|
|
|
std::ostringstream e;
|
2016-09-07 23:20:35 +00:00
|
|
|
e << "given APPEND option with output\n\"" << output[0]
|
|
|
|
<< "\"\nwhich is not already a custom command output.";
|
2014-03-10 23:04:11 +00:00
|
|
|
this->SetError(e.str());
|
2006-10-04 19:24:26 +00:00
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2006-10-04 19:24:26 +00:00
|
|
|
|
2011-01-26 21:32:17 +00:00
|
|
|
// Convert working directory to a full path.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!working.empty()) {
|
2015-04-16 19:33:09 +00:00
|
|
|
const char* build_dir = this->Makefile->GetCurrentBinaryDirectory();
|
2014-10-15 12:54:05 +00:00
|
|
|
working = cmSystemTools::CollapseFullPath(working, build_dir);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2011-01-26 21:32:17 +00:00
|
|
|
|
2005-02-22 15:32:44 +00:00
|
|
|
// Choose which mode of the command to use.
|
2006-09-28 15:30:49 +00:00
|
|
|
bool escapeOldStyle = !verbatim;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (source.empty() && output.empty()) {
|
2005-02-22 15:32:44 +00:00
|
|
|
// Source is empty, use the target.
|
|
|
|
std::vector<std::string> no_depends;
|
2016-05-16 14:34:04 +00:00
|
|
|
this->Makefile->AddCustomCommandToTarget(
|
|
|
|
target, byproducts, no_depends, commandLines, cctype, comment,
|
2016-08-05 12:39:31 +00:00
|
|
|
working.c_str(), escapeOldStyle, uses_terminal, depfile);
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (target.empty()) {
|
2005-02-22 15:32:44 +00:00
|
|
|
// Target is empty, use the output.
|
2016-05-16 14:34:04 +00:00
|
|
|
this->Makefile->AddCustomCommandToOutput(
|
|
|
|
output, byproducts, depends, main_dependency, commandLines, comment,
|
2016-08-05 12:39:31 +00:00
|
|
|
working.c_str(), false, escapeOldStyle, uses_terminal, depfile);
|
2007-09-17 14:50:46 +00:00
|
|
|
|
2008-06-02 20:45:07 +00:00
|
|
|
// Add implicit dependency scanning requests if any were given.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!implicit_depends.empty()) {
|
2007-09-17 14:50:46 +00:00
|
|
|
bool okay = false;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (cmSourceFile* sf =
|
|
|
|
this->Makefile->GetSourceFileWithOutput(output[0])) {
|
|
|
|
if (cmCustomCommand* cc = sf->GetCustomCommand()) {
|
2007-09-17 14:50:46 +00:00
|
|
|
okay = true;
|
2008-06-02 20:45:07 +00:00
|
|
|
cc->SetImplicitDepends(implicit_depends);
|
2007-09-17 14:50:46 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (!okay) {
|
2015-01-05 19:31:31 +00:00
|
|
|
std::ostringstream e;
|
2007-09-17 14:50:46 +00:00
|
|
|
e << "could not locate source file with a custom command producing \""
|
|
|
|
<< output[0] << "\" even though this command tried to create it!";
|
2014-03-10 23:04:11 +00:00
|
|
|
this->SetError(e.str());
|
2007-09-17 14:50:46 +00:00
|
|
|
return false;
|
|
|
|
}
|
2005-02-22 15:32:44 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (!byproducts.empty()) {
|
2014-11-13 23:54:52 +00:00
|
|
|
this->SetError("BYPRODUCTS may not be specified with SOURCE signatures");
|
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (uses_terminal) {
|
2014-11-05 20:37:52 +00:00
|
|
|
this->SetError("USES_TERMINAL may not be used with SOURCE signatures");
|
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else {
|
2014-02-11 17:39:55 +00:00
|
|
|
bool issueMessage = true;
|
2015-01-05 19:31:31 +00:00
|
|
|
std::ostringstream e;
|
2014-02-11 17:39:55 +00:00
|
|
|
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
|
2016-05-16 14:34:04 +00:00
|
|
|
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0050)) {
|
|
|
|
case cmPolicies::WARN:
|
|
|
|
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0050) << "\n";
|
|
|
|
break;
|
|
|
|
case cmPolicies::OLD:
|
|
|
|
issueMessage = false;
|
|
|
|
break;
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
messageType = cmake::FATAL_ERROR;
|
|
|
|
break;
|
2014-02-11 17:39:55 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (issueMessage) {
|
2014-02-11 17:39:55 +00:00
|
|
|
e << "The SOURCE signatures of add_custom_command are no longer "
|
|
|
|
"supported.";
|
2014-03-10 23:04:11 +00:00
|
|
|
this->Makefile->IssueMessage(messageType, e.str());
|
2016-05-16 14:34:04 +00:00
|
|
|
if (messageType == cmake::FATAL_ERROR) {
|
2014-02-11 17:39:55 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2014-02-11 17:39:55 +00:00
|
|
|
|
2005-02-22 15:32:44 +00:00
|
|
|
// Use the old-style mode for backward compatibility.
|
2016-05-16 14:34:04 +00:00
|
|
|
this->Makefile->AddCustomCommandOldStyle(target, outputs, depends, source,
|
|
|
|
commandLines, comment);
|
|
|
|
}
|
2007-09-17 14:50:46 +00:00
|
|
|
|
2001-11-07 21:47:38 +00:00
|
|
|
return true;
|
|
|
|
}
|
2006-04-11 15:06:19 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
bool cmAddCustomCommandCommand::CheckOutputs(
|
|
|
|
const std::vector<std::string>& outputs)
|
2006-04-11 15:06:19 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
for (std::vector<std::string>::const_iterator o = outputs.begin();
|
|
|
|
o != outputs.end(); ++o) {
|
2006-04-11 15:06:19 +00:00
|
|
|
// Make sure the file will not be generated into the source
|
|
|
|
// directory during an out of source build.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!this->Makefile->CanIWriteThisFile(o->c_str())) {
|
2006-04-11 15:06:19 +00:00
|
|
|
std::string e = "attempted to have a file \"" + *o +
|
|
|
|
"\" in a source directory as an output of custom command.";
|
2014-03-10 23:04:11 +00:00
|
|
|
this->SetError(e);
|
2006-04-11 15:06:19 +00:00
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2006-04-11 15:06:19 +00:00
|
|
|
|
|
|
|
// Make sure the output file name has no invalid characters.
|
|
|
|
std::string::size_type pos = o->find_first_of("#<>");
|
2016-05-16 14:34:04 +00:00
|
|
|
if (pos != o->npos) {
|
2015-01-05 19:31:31 +00:00
|
|
|
std::ostringstream msg;
|
2006-04-11 15:06:19 +00:00
|
|
|
msg << "called with OUTPUT containing a \"" << (*o)[pos]
|
|
|
|
<< "\". This character is not allowed.";
|
2014-03-10 23:04:11 +00:00
|
|
|
this->SetError(msg.str());
|
2006-04-11 15:06:19 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2006-04-11 15:06:19 +00:00
|
|
|
return true;
|
|
|
|
}
|