cmAddDependenciesCommand.cxx 2.0 KB

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