cmTargetIncludeDirectoriesCommand.cxx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2013 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 "cmTargetIncludeDirectoriesCommand.h"
  11. #include "cmGeneratorExpression.h"
  12. //----------------------------------------------------------------------------
  13. bool cmTargetIncludeDirectoriesCommand
  14. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  15. {
  16. return this->HandleArguments(args, "INCLUDE_DIRECTORIES",
  17. ArgumentFlags(PROCESS_BEFORE | PROCESS_SYSTEM));
  18. }
  19. //----------------------------------------------------------------------------
  20. void cmTargetIncludeDirectoriesCommand
  21. ::HandleImportedTarget(const std::string &tgt)
  22. {
  23. cmOStringStream e;
  24. e << "Cannot specify include directories for imported target \""
  25. << tgt << "\".";
  26. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  27. }
  28. //----------------------------------------------------------------------------
  29. void cmTargetIncludeDirectoriesCommand
  30. ::HandleMissingTarget(const std::string &name)
  31. {
  32. cmOStringStream e;
  33. e << "Cannot specify include directories for target \"" << name << "\" "
  34. "which is not built by this project.";
  35. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  36. }
  37. //----------------------------------------------------------------------------
  38. std::string cmTargetIncludeDirectoriesCommand
  39. ::Join(const std::vector<std::string> &content)
  40. {
  41. std::string dirs;
  42. std::string sep;
  43. std::string prefix = this->Makefile->GetStartDirectory() + std::string("/");
  44. for(std::vector<std::string>::const_iterator it = content.begin();
  45. it != content.end(); ++it)
  46. {
  47. if (cmSystemTools::FileIsFullPath(it->c_str())
  48. || cmGeneratorExpression::Find(*it) == 0)
  49. {
  50. dirs += sep + *it;
  51. }
  52. else
  53. {
  54. dirs += sep + prefix + *it;
  55. }
  56. sep = ";";
  57. }
  58. return dirs;
  59. }
  60. //----------------------------------------------------------------------------
  61. void cmTargetIncludeDirectoriesCommand
  62. ::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
  63. bool prepend, bool system)
  64. {
  65. cmListFileBacktrace lfbt;
  66. this->Makefile->GetBacktrace(lfbt);
  67. cmValueWithOrigin entry(this->Join(content), lfbt);
  68. tgt->InsertInclude(entry, prepend);
  69. if (system)
  70. {
  71. tgt->AddSystemIncludeDirectories(content);
  72. }
  73. }
  74. //----------------------------------------------------------------------------
  75. void cmTargetIncludeDirectoriesCommand
  76. ::HandleInterfaceContent(cmTarget *tgt,
  77. const std::vector<std::string> &content,
  78. bool prepend, bool system)
  79. {
  80. cmTargetPropCommandBase::HandleInterfaceContent(tgt, content,
  81. prepend, system);
  82. if (system)
  83. {
  84. std::string joined;
  85. std::string sep;
  86. for(std::vector<std::string>::const_iterator it = content.begin();
  87. it != content.end(); ++it)
  88. {
  89. joined += sep;
  90. sep = ";";
  91. joined += *it;
  92. }
  93. tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES",
  94. joined.c_str());
  95. }
  96. }