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