1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
12 #include "cmAddDependenciesCommand.h"
13 #include "cmLocalGenerator.h"
14 #include "cmGlobalGenerator.h"
16 // cmDependenciesCommand
17 bool cmAddDependenciesCommand
18 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
22 this->SetError("called with incorrect number of arguments");
26 std::string target_name = args[0];
27 if(this->Makefile->IsAlias(target_name.c_str()))
30 e << "Cannot add target-level dependencies to alias target \""
31 << target_name << "\".\n";
32 this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
34 if(cmTarget* target = this->Makefile->FindTargetToUse(target_name.c_str()))
36 std::vector<std::string>::const_iterator s = args.begin();
37 ++s; // skip over target_name
38 for (; s != args.end(); ++s)
40 target->AddUtility(s->c_str());
46 e << "Cannot add target-level dependencies to non-existent target \""
47 << target_name << "\".\n"
48 << "The add_dependencies works for top-level logical targets created "
49 << "by the add_executable, add_library, or add_custom_target commands. "
50 << "If you want to add file-level dependencies see the DEPENDS option "
51 << "of the add_custom_target and add_custom_command commands.";
52 this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());