2016-09-27 15:01:08 -04:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2001-06-26 10:01:03 -04:00
|
|
|
#include "cmAddDependenciesCommand.h"
|
2016-04-29 09:40:20 -04:00
|
|
|
|
2007-02-07 11:49:42 -05:00
|
|
|
#include "cmGlobalGenerator.h"
|
2001-06-26 10:01:03 -04:00
|
|
|
|
|
|
|
// cmDependenciesCommand
|
2016-05-16 10:34:04 -04:00
|
|
|
bool cmAddDependenciesCommand::InitialPass(
|
|
|
|
std::vector<std::string> const& args, cmExecutionStatus&)
|
2001-06-26 10:01:03 -04:00
|
|
|
{
|
2016-05-16 10:34:04 -04:00
|
|
|
if (args.size() < 2) {
|
2001-06-26 10:01:03 -04:00
|
|
|
this->SetError("called with incorrect number of arguments");
|
|
|
|
return false;
|
2016-05-16 10:34:04 -04:00
|
|
|
}
|
2002-03-29 14:20:32 -05:00
|
|
|
|
2001-11-08 09:16:32 -05:00
|
|
|
std::string target_name = args[0];
|
2016-05-16 10:34:04 -04:00
|
|
|
if (this->Makefile->IsAlias(target_name)) {
|
2015-01-05 20:31:31 +01:00
|
|
|
std::ostringstream e;
|
2013-07-12 09:14:31 +02:00
|
|
|
e << "Cannot add target-level dependencies to alias target \""
|
|
|
|
<< target_name << "\".\n";
|
|
|
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
2016-05-16 10:34:04 -04:00
|
|
|
}
|
|
|
|
if (cmTarget* target = this->Makefile->FindTargetToUse(target_name)) {
|
2001-09-20 15:08:30 -04:00
|
|
|
std::vector<std::string>::const_iterator s = args.begin();
|
2007-02-07 11:49:42 -05:00
|
|
|
++s; // skip over target_name
|
2016-05-16 10:34:04 -04:00
|
|
|
for (; s != args.end(); ++s) {
|
2014-03-11 00:04:11 +01:00
|
|
|
target->AddUtility(*s, this->Makefile);
|
2001-06-26 10:01:03 -04:00
|
|
|
}
|
2016-05-16 10:34:04 -04:00
|
|
|
} else {
|
2015-01-05 20:31:31 +01:00
|
|
|
std::ostringstream e;
|
2013-03-29 14:53:36 -04:00
|
|
|
e << "Cannot add target-level dependencies to non-existent target \""
|
|
|
|
<< target_name << "\".\n"
|
|
|
|
<< "The add_dependencies works for top-level logical targets created "
|
|
|
|
<< "by the add_executable, add_library, or add_custom_target commands. "
|
|
|
|
<< "If you want to add file-level dependencies see the DEPENDS option "
|
|
|
|
<< "of the add_custom_target and add_custom_command commands.";
|
|
|
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
2016-05-16 10:34:04 -04:00
|
|
|
}
|
2006-03-10 13:06:26 -05:00
|
|
|
|
2001-06-26 10:01:03 -04:00
|
|
|
return true;
|
|
|
|
}
|