cmTargetSourcesCommand.cxx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2014 Stephen Kelly <[email protected]>
  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 "cmTargetSourcesCommand.h"
  11. #include "cmGeneratorExpression.h"
  12. //----------------------------------------------------------------------------
  13. bool cmTargetSourcesCommand
  14. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  15. {
  16. return this->HandleArguments(args, "SOURCES");
  17. }
  18. //----------------------------------------------------------------------------
  19. void cmTargetSourcesCommand
  20. ::HandleImportedTarget(const std::string &tgt)
  21. {
  22. cmOStringStream e;
  23. e << "Cannot specify sources for imported target \""
  24. << tgt << "\".";
  25. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  26. }
  27. //----------------------------------------------------------------------------
  28. void cmTargetSourcesCommand
  29. ::HandleMissingTarget(const std::string &name)
  30. {
  31. cmOStringStream e;
  32. e << "Cannot specify sources for target \"" << name << "\" "
  33. "which is not built by this project.";
  34. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  35. }
  36. //----------------------------------------------------------------------------
  37. std::string cmTargetSourcesCommand
  38. ::Join(const std::vector<std::string> &content)
  39. {
  40. std::string srcs;
  41. std::string sep;
  42. for(std::vector<std::string>::const_iterator it = content.begin();
  43. it != content.end(); ++it)
  44. {
  45. srcs += sep + *it;
  46. sep = ";";
  47. }
  48. return srcs;
  49. }
  50. //----------------------------------------------------------------------------
  51. void cmTargetSourcesCommand
  52. ::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
  53. bool, bool)
  54. {
  55. tgt->AppendProperty("SOURCES", this->Join(content).c_str());
  56. }