cmTargetIncludeDirectoriesCommand.cxx 3.5 KB

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