浏览代码

cmGeneratorTarget: Add AddIncludeDirectory method (experimental)

Sebastian Holtermann 9 年之前
父节点
当前提交
8f47a5f16a
共有 2 个文件被更改,包括 21 次插入0 次删除
  1. 15 0
      Source/cmGeneratorTarget.cxx
  2. 6 0
      Source/cmGeneratorTarget.h

+ 15 - 0
Source/cmGeneratorTarget.cxx

@@ -533,6 +533,21 @@ void cmGeneratorTarget::AddTracedSources(std::vector<std::string> const& srcs)
   }
 }
 
+void cmGeneratorTarget::AddIncludeDirectory(const std::string& src,
+                                            bool before)
+{
+  this->Target->InsertInclude(src, this->Makefile->GetBacktrace(), before);
+  cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+  cmGeneratorExpression ge(lfbt);
+  CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(src);
+  cge->SetEvaluateForBuildsystem(true);
+  // Insert before begin/end
+  std::vector<TargetPropertyEntry*>::iterator pos = before
+    ? this->IncludeDirectoriesEntries.begin()
+    : this->IncludeDirectoriesEntries.end();
+  this->IncludeDirectoriesEntries.insert(pos, new TargetPropertyEntry(cge));
+}
+
 std::vector<cmSourceFile*> const* cmGeneratorTarget::GetSourceDepends(
   cmSourceFile const* sf) const
 {

+ 6 - 0
Source/cmGeneratorTarget.h

@@ -395,6 +395,12 @@ public:
   void AddSource(const std::string& src);
   void AddTracedSources(std::vector<std::string> const& srcs);
 
+  /**
+   * Adds an entry to the INCLUDE_DIRECTORIES list.
+   * If before is true the entry is pushed at the front.
+   */
+  void AddIncludeDirectory(const std::string& src, bool before = false);
+
   /**
    * Flags for a given source file as used in this target. Typically assigned
    * via SET_TARGET_PROPERTIES when the property is a list of source files.