cmTargetSourcesCommand.cxx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmTargetSourcesCommand.h"
  4. #include <algorithm>
  5. #include <sstream>
  6. #include "cmAlgorithms.h"
  7. #include "cmMakefile.h"
  8. #include "cmTarget.h"
  9. #include "cmake.h"
  10. class cmExecutionStatus;
  11. bool cmTargetSourcesCommand::InitialPass(std::vector<std::string> const& args,
  12. cmExecutionStatus&)
  13. {
  14. return this->HandleArguments(args, "SOURCES");
  15. }
  16. void cmTargetSourcesCommand::HandleImportedTarget(const std::string& tgt)
  17. {
  18. std::ostringstream e;
  19. e << "Cannot specify sources for imported target \"" << tgt << "\".";
  20. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  21. }
  22. void cmTargetSourcesCommand::HandleMissingTarget(const std::string& name)
  23. {
  24. std::ostringstream e;
  25. e << "Cannot specify sources for target \"" << name
  26. << "\" "
  27. "which is not built by this project.";
  28. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  29. }
  30. std::string cmTargetSourcesCommand::Join(
  31. const std::vector<std::string>& content)
  32. {
  33. return cmJoin(content, ";");
  34. }
  35. bool cmTargetSourcesCommand::HandleDirectContent(
  36. cmTarget* tgt, const std::vector<std::string>& content, bool, bool)
  37. {
  38. tgt->AppendProperty("SOURCES", this->Join(content).c_str());
  39. return true;
  40. }