Просмотр исходного кода

Add API to get the ordered includes for a target.

Stephen Kelly 14 лет назад
Родитель
Сommit
a4d5f7b9b2
2 измененных файлов с 27 добавлено и 0 удалено
  1. 24 0
      Source/cmTarget.cxx
  2. 3 0
      Source/cmTarget.h

+ 24 - 0
Source/cmTarget.cxx

@@ -4675,6 +4675,30 @@ cmTarget::GetLinkInformation(const char* config)
   return i->second;
 }
 
+//----------------------------------------------------------------------------
+std::vector<std::string> cmTarget::GetIncludeDirectories()
+{
+  std::vector<std::string> includes;
+  const char *prop = this->GetProperty("INCLUDE_DIRECTORIES");
+  if(prop)
+    {
+    cmSystemTools::ExpandListArgument(prop, includes);
+    }
+
+  std::set<std::string> uniqueIncludes;
+  std::vector<std::string> orderedAndUniqueIncludes;
+  for(std::vector<std::string>::const_iterator
+      li = includes.begin(); li != includes.end(); ++li)
+    {
+    if(uniqueIncludes.insert(*li).second)
+      {
+      orderedAndUniqueIncludes.push_back(*li);
+      }
+    }
+
+  return orderedAndUniqueIncludes;
+}
+
 //----------------------------------------------------------------------------
 cmTargetLinkInformationMap
 ::cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r): derived()

+ 3 - 0
Source/cmTarget.h

@@ -458,6 +458,9 @@ public:
       directory.  */
   bool UsesDefaultOutputDir(const char* config, bool implib);
 
+  /** Get the include directories for this target.  */
+  std::vector<std::string> GetIncludeDirectories();
+
 private:
   /**
    * A list of direct dependencies. Use in conjunction with DependencyMap.