[Cmake-commits] CMake branch, next, updated. v2.8.7-2814-g52d9d34

David Cole david.cole at kitware.com
Wed Feb 22 15:35:28 EST 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  52d9d34ad13bf52ec3ce790823c1f7460a600e62 (commit)
       via  8233636dbe531ccf36510242e7c997dfa6529bde (commit)
       via  d899eb71b52616c9e3f3f5987f229619605e632b (commit)
       via  c21db870a5912015a3fe64753a7df49318ceff1e (commit)
       via  22021f07f80163979e8dedfcefccee53f4693fae (commit)
       via  9106b564ae5bf0bf1c1ff4a3fca484bcfd40e183 (commit)
       via  840509babb2d1c8fc5167c4580fef58546c06700 (commit)
       via  a4d5f7b9b270d3fa85e8a0a1608c4205dff744d9 (commit)
       via  8adaee2b0b2651cfd93bb4a915d11bdd4cba1b51 (commit)
       via  7620932d8259572dc737d97cec83779efadab5a3 (commit)
       via  97a5faa85895ca77679d794788731cf76b8704ce (commit)
       via  edd5303949f9d0e1b4b11e83aecd34bfdb2700ce (commit)
      from  0a8634a82fd914adb1d2c3907438c1cfc97b7b43 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=52d9d34ad13bf52ec3ce790823c1f7460a600e62
commit 52d9d34ad13bf52ec3ce790823c1f7460a600e62
Merge: 0a8634a 8233636
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Wed Feb 22 15:35:19 2012 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Feb 22 15:35:19 2012 -0500

    Merge topic 'target-include-directories' into next
    
    8233636 Update the documentation regarding INCLUDE_DIRECTORIES.
    d899eb7 Call ExpandVariablesInString for each target's INCLUDE_DIRECTORIES
    c21db87 Make search paths ordered and unique
    22021f0 Remove cmMakefile::GetIncludeDirectories
    9106b56 Extract and use the INCLUDE_DIRECTORIES target properties.
    840509b Keep the INCLUDE_DIRECTORIES target property up to date.
    a4d5f7b Add API to get the ordered includes for a target.
    8adaee2 CMake: Eliminate cmMakefile::IncludeDirectories
    7620932 Remove include flags memoization.
    97a5faa Make it safe to call this method without creating duplicates.
    edd5303 Refactor GetIncludeFlags to take includes instead of fetching them


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8233636dbe531ccf36510242e7c997dfa6529bde
commit 8233636dbe531ccf36510242e7c997dfa6529bde
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Wed Feb 22 14:30:00 2012 -0500
Commit:     David Cole <david.cole at kitware.com>
CommitDate: Wed Feb 22 15:22:03 2012 -0500

    Update the documentation regarding INCLUDE_DIRECTORIES.
    
    It is now a target property and is affected by the use
    of the include_directories command.

diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h
index 3b35d55..cbe344f 100644
--- a/Source/cmIncludeDirectoryCommand.h
+++ b/Source/cmIncludeDirectoryCommand.h
@@ -58,13 +58,21 @@ public:
     {
     return
       "  include_directories([AFTER|BEFORE] [SYSTEM] dir1 dir2 ...)\n"
-      "Add the given directories to those searched by the compiler for "
-      "include files. By default the directories are appended onto "
-      "the current list of directories. This default behavior can be "
-      "changed by setting CMAKE_INCLUDE_DIRECTORIES_BEFORE to ON. "
-      "By using BEFORE or AFTER you can select between appending and "
-      "prepending, independent from the default. "
-      "If the SYSTEM option is given the compiler will be told that the "
+      "Add the given directories to those the compiler uses to search "
+      "for include files. "
+      "These directories are added to the directory property "
+      "INCLUDE_DIRECTORIES for the current CMakeLists file. "
+      "They are also added to the target property INCLUDE_DIRECTORIES "
+      "for each target in the current CMakeLists file. "
+      "The target property values are the ones used by the generators."
+      "\n"
+      "By default the directories are appended onto the current list of "
+      "directories. "
+      "This default behavior can be changed by setting "
+      "CMAKE_INCLUDE_DIRECTORIES_BEFORE to ON. "
+      "By using AFTER or BEFORE explicitly, you can select between "
+      "appending and prepending, independent of the default. "
+      "If the SYSTEM option is given, the compiler will be told the "
       "directories are meant as system include directories on some "
       "platforms.";
     }
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 84dc872..d206d32 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -3860,9 +3860,22 @@ void cmMakefile::DefineProperties(cmake *cm)
   cm->DefineProperty
     ("INCLUDE_DIRECTORIES", cmProperty::DIRECTORY,
      "List of preprocessor include file search directories.",
-     "This read-only property specifies the list of directories given "
-     "so far to the include_directories command.  "
-     "It is intended for debugging purposes.", false);
+     "This property specifies the list of directories given "
+     "so far to the include_directories command. "
+     "This property exists on directories and targets. "
+     "In addition to accepting values from the include_directories "
+     "command, values may be set directly on any directory or any "
+     "target using the set_property command. "
+     "A target gets its initial value for this property from the value "
+     "of the directory property. "
+     "A directory gets its initial value from its parent directory if "
+     "it has one. "
+     "Both directory and target property values are adjusted by calls "
+     "to the include_directories command."
+     "\n"
+     "The target property values are used by the generators to set "
+     "the include paths for the compiler. "
+     "See also the include_directories command.");
 
   cm->DefineProperty
     ("LINK_DIRECTORIES", cmProperty::DIRECTORY,
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index cd816a6..e618bee 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -486,6 +486,26 @@ void cmTarget::DefineProperties(cmake *cm)
      "undefined behavior.");
 
   cm->DefineProperty
+    ("INCLUDE_DIRECTORIES", cmProperty::TARGET,
+     "List of preprocessor include file search directories.",
+     "This property specifies the list of directories given "
+     "so far to the include_directories command. "
+     "This property exists on directories and targets. "
+     "In addition to accepting values from the include_directories "
+     "command, values may be set directly on any directory or any "
+     "target using the set_property command. "
+     "A target gets its initial value for this property from the value "
+     "of the directory property. "
+     "A directory gets its initial value from its parent directory if "
+     "it has one. "
+     "Both directory and target property values are adjusted by calls "
+     "to the include_directories command."
+     "\n"
+     "The target property values are used by the generators to set "
+     "the include paths for the compiler. "
+     "See also the include_directories command.");
+
+  cm->DefineProperty
     ("INSTALL_NAME_DIR", cmProperty::TARGET,
      "Mac OSX directory name for installed targets.",
      "INSTALL_NAME_DIR is a string specifying the "

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d899eb71b52616c9e3f3f5987f229619605e632b
commit d899eb71b52616c9e3f3f5987f229619605e632b
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Wed Feb 22 07:14:11 2012 -0500
Commit:     David Cole <david.cole at kitware.com>
CommitDate: Wed Feb 22 07:29:32 2012 -0500

    Call ExpandVariablesInString for each target's INCLUDE_DIRECTORIES
    
    For strict backwards compatibility only. This should be unnecessary at
    this point, but introducing a policy to deprecate it properly is a
    whole different topic branch...

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 818bb1b..84dc872 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2127,6 +2127,20 @@ void cmMakefile::ExpandVariables()
     this->SetProperty("INCLUDE_DIRECTORIES", dirs.c_str());
     }
 
+  // Also for each target's INCLUDE_DIRECTORIES property:
+  for (cmTargets::iterator l = this->Targets.begin();
+       l != this->Targets.end(); ++l)
+    {
+    cmTarget &t = l->second;
+    const char *includeDirs = t.GetProperty("INCLUDE_DIRECTORIES");
+    if (includeDirs)
+      {
+      std::string dirs = includeDirs;
+      this->ExpandVariablesInString(dirs, true, true);
+      t.SetProperty("INCLUDE_DIRECTORIES", dirs.c_str());
+      }
+    }
+
   for(std::vector<std::string>::iterator d = this->LinkDirectories.begin();
       d != this->LinkDirectories.end(); ++d)
     {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c21db870a5912015a3fe64753a7df49318ceff1e
commit c21db870a5912015a3fe64753a7df49318ceff1e
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Wed Feb 22 07:23:06 2012 -0500
Commit:     David Cole <david.cole at kitware.com>
CommitDate: Wed Feb 22 07:29:32 2012 -0500

    Make search paths ordered and unique
    
    Avoid duplicates. Same as before the introduction of the INCLUDE_DIRECTORIES
    target property.

diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx
index 03fe33d..6055c55 100644
--- a/Source/cmMakeDepend.cxx
+++ b/Source/cmMakeDepend.cxx
@@ -56,6 +56,8 @@ void cmMakeDepend::SetMakefile(cmMakefile* makefile)
     this->Makefile->ComplainFileRegularExpression.c_str());
 
   // Now extract any include paths from the targets
+  std::set<std::string> uniqueIncludes;
+  std::vector<std::string> orderedAndUniqueIncludes;
   cmTargets & targets = this->Makefile->GetTargets();
   for (cmTargets::iterator l = targets.begin(); l != targets.end(); ++l)
     {
@@ -66,9 +68,20 @@ void cmMakeDepend::SetMakefile(cmMakefile* makefile)
       {
       std::string path = *j;
       this->Makefile->ExpandVariablesInString(path);
-      this->AddSearchPath(path.c_str());
+      if(uniqueIncludes.insert(path).second)
+        {
+        orderedAndUniqueIncludes.push_back(path);
+        }
       }
     }
+
+  for(std::vector<std::string>::const_iterator
+    it = orderedAndUniqueIncludes.begin();
+    it != orderedAndUniqueIncludes.end();
+    ++it)
+    {
+    this->AddSearchPath(it->c_str());
+    }
 }
 
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=22021f07f80163979e8dedfcefccee53f4693fae
commit 22021f07f80163979e8dedfcefccee53f4693fae
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Wed Feb 22 07:25:43 2012 -0500
Commit:     David Cole <david.cole at kitware.com>
CommitDate: Wed Feb 22 07:29:32 2012 -0500

    Remove cmMakefile::GetIncludeDirectories
    
    After making the changes to use the new target level INCLUDE_DIRECTORIES
    property, there are no more callers of this method.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 6290412..818bb1b 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1660,30 +1660,6 @@ void cmMakefile::AddIncludeDirectory(const char* inc, bool before)
 }
 
 //----------------------------------------------------------------------------
-std::vector<std::string> cmMakefile::GetIncludeDirectories()
-{
-  std::vector<std::string> includes;
-  const char *val = this->GetProperty("INCLUDE_DIRECTORIES");
-  if(val)
-    {
-    cmSystemTools::ExpandListArgument(val, 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;
-}
-
-//----------------------------------------------------------------------------
 void cmMakefile::AddSystemIncludeDirectory(const char* dir)
 {
   this->SystemIncludeDirectories.insert(dir);
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 5e5310f..c2939fb 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -522,11 +522,6 @@ public:
   cmTarget* FindTargetToUse(const char* name);
 
   /**
-   * Get a list of include directories in the build.
-   */
-  std::vector<std::string> GetIncludeDirectories();
-
-  /**
    * Mark include directories as system directories.
    */
   void AddSystemIncludeDirectory(const char* dir);

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9106b564ae5bf0bf1c1ff4a3fca484bcfd40e183
commit 9106b564ae5bf0bf1c1ff4a3fca484bcfd40e183
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Nov 5 16:17:49 2011 +0100
Commit:     David Cole <david.cole at kitware.com>
CommitDate: Wed Feb 22 06:31:50 2012 -0500

    Extract and use the INCLUDE_DIRECTORIES target properties.
    
    Eliminate callers of cmMakefile::GetIncludeDirectories.
    
    All callers of GetIncludeDirectories should go through the local generator
    object.
    
    Only the local generator calls cmTarget::GetIncludeDirectories directly.

diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index 19558fa..94ff471 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -260,12 +260,24 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends,
 //----------------------------------------------------------------------------
 void cmDepends::SetIncludePathFromLanguage(const char* lang)
 {
+  // Look for the new per "TARGET_" variant first:
   std::string includePathVar = "CMAKE_";
   includePathVar += lang;
-  includePathVar += "_INCLUDE_PATH";
+  includePathVar += "_TARGET_INCLUDE_PATH";
   cmMakefile* mf = this->LocalGenerator->GetMakefile();
   if(const char* includePath = mf->GetDefinition(includePathVar.c_str()))
     {
     cmSystemTools::ExpandListArgument(includePath, this->IncludePath);
     }
+  else
+    {
+    // Fallback to the old directory level variable if no per-target var:
+    includePathVar = "CMAKE_";
+    includePathVar += lang;
+    includePathVar += "_INCLUDE_PATH";
+    if(const char* includePath = mf->GetDefinition(includePathVar.c_str()))
+      {
+      cmSystemTools::ExpandListArgument(includePath, this->IncludePath);
+      }
+    }
 }
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index 38002ec..b5cba8e 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -600,16 +600,17 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
 
       // the include directories for this target
       std::set<std::string> uniqIncludeDirs;
-      const std::vector<std::string>& incDirs =
-          target->GetMakefile()->GetIncludeDirectories();
-      for(std::vector<std::string>::const_iterator dirIt=incDirs.begin();
-          dirIt != incDirs.end();
+
+      std::vector<std::string> includes;
+      target->GetMakefile()->GetLocalGenerator()->
+        GetIncludeDirectories(includes, target);
+      for(std::vector<std::string>::const_iterator dirIt=includes.begin();
+          dirIt != includes.end();
           ++dirIt)
         {
         uniqIncludeDirs.insert(*dirIt);
         }
 
-
       std::string systemIncludeDirs = makefile->GetSafeDefinition(
                                 "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS");
       if (!systemIncludeDirs.empty())
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index 07549e9..19372c8 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -893,9 +893,13 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
        it != this->GlobalGenerator->GetLocalGenerators().end();
        ++it)
     {
-    const std::vector<std::string>& includeDirs
-      = (*it)->GetMakefile()->GetIncludeDirectories();
-    this->AppendIncludeDirectories(fout, includeDirs, emmited);
+    cmTargets & targets = (*it)->GetMakefile()->GetTargets();
+    for (cmTargets::iterator l = targets.begin(); l != targets.end(); ++l)
+      {
+      std::vector<std::string> includeDirs;
+      (*it)->GetIncludeDirectories(includeDirs, &l->second);
+      this->AppendIncludeDirectories(fout, includeDirs, emmited);
+      }
     }
   // now also the system include directories, in case we found them in
   // CMakeSystemSpecificInformation.cmake. This makes Eclipse find the
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 8dce053..a988844 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1067,9 +1067,9 @@ void cmGlobalGenerator::CheckLocalGenerators()
     {
     manager = this->LocalGenerators[i]->GetMakefile()->GetCacheManager();
     this->LocalGenerators[i]->ConfigureFinalPass();
-    const cmTargets & targets =
+    cmTargets & targets =
       this->LocalGenerators[i]->GetMakefile()->GetTargets();
-    for (cmTargets::const_iterator l = targets.begin();
+    for (cmTargets::iterator l = targets.begin();
          l != targets.end(); l++)
       {
       const cmTarget::LinkLibraryVectorType& libs =
@@ -1095,27 +1095,28 @@ void cmGlobalGenerator::CheckLocalGenerators()
           notFoundMap[varName] = text;
           }
         }
-      }
-    const std::vector<std::string>& incs =
-      this->LocalGenerators[i]->GetMakefile()->GetIncludeDirectories();
+      std::vector<std::string> incs;
+      this->LocalGenerators[i]->GetIncludeDirectories(incs, &l->second);
 
-    for( std::vector<std::string>::const_iterator incDir = incs.begin();
-          incDir != incs.end(); ++incDir)
-      {
-      if(incDir->size() > 9 &&
-          cmSystemTools::IsNOTFOUND(incDir->c_str()))
+      for( std::vector<std::string>::const_iterator incDir = incs.begin();
+            incDir != incs.end(); ++incDir)
         {
-        std::string varName = incDir->substr(0, incDir->size()-9);
-        cmCacheManager::CacheIterator it =
-          manager->GetCacheIterator(varName.c_str());
-        if(it.GetPropertyAsBool("ADVANCED"))
+        if(incDir->size() > 9 &&
+            cmSystemTools::IsNOTFOUND(incDir->c_str()))
           {
-          varName += " (ADVANCED)";
+          std::string varName = incDir->substr(0, incDir->size()-9);
+          cmCacheManager::CacheIterator it =
+            manager->GetCacheIterator(varName.c_str());
+          if(it.GetPropertyAsBool("ADVANCED"))
+            {
+            varName += " (ADVANCED)";
+            }
+          std::string text = notFoundMap[varName];
+          text += "\n   used as include directory in directory ";
+          text += this->LocalGenerators[i]
+                      ->GetMakefile()->GetCurrentDirectory();
+          notFoundMap[varName] = text;
           }
-        std::string text = notFoundMap[varName];
-        text += "\n   used as include directory in directory ";
-        text += this->LocalGenerators[i]->GetMakefile()->GetCurrentDirectory();
-        notFoundMap[varName] = text;
         }
       }
     this->CMakeInstance->UpdateProgress
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 859503f..cb74746 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1811,7 +1811,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
   BuildObjectListOrString dirs(this, this->XcodeVersion >= 30);
   BuildObjectListOrString fdirs(this, this->XcodeVersion >= 30);
   std::vector<std::string> includes;
-  this->CurrentLocalGenerator->GetIncludeDirectories(includes);
+  this->CurrentLocalGenerator->GetIncludeDirectories(includes, &target);
   std::set<cmStdString> emitted;
   emitted.insert("/System/Library/Frameworks");
   for(std::vector<std::string>::iterator i = includes.begin();
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 27b1b1b..4f5af0a 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -556,7 +556,7 @@ void cmLocalGenerator::GenerateTargetManifest()
 void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
                                                       const char* lang,
                                                       cmSourceFile& source,
-                                                      cmTarget& )
+                                                      cmTarget& target)
 {
   std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname));
   objectDir = this->Convert(objectDir.c_str(),START_OUTPUT,SHELL);
@@ -576,7 +576,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
   flags += " ";
     {
     std::vector<std::string> includes;
-    this->GetIncludeDirectories(includes, lang);
+    this->GetIncludeDirectories(includes, &target, lang);
     flags += this->GetIncludeFlags(includes, lang);
     }
   flags += this->Makefile->GetDefineFlags();
@@ -1313,6 +1313,7 @@ std::string cmLocalGenerator::GetIncludeFlags(
 
 //----------------------------------------------------------------------------
 void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
+                                             cmTarget* target,
                                              const char* lang)
 {
   // Need to decide whether to automatically include the source and
@@ -1398,9 +1399,12 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
       }
     }
 
-  // Get the project-specified include directories.
-  const std::vector<std::string>& includes =
-    this->Makefile->GetIncludeDirectories();
+  // Get the target-specific include directories.
+  std::vector<std::string> includes;
+  if(target)
+    {
+    includes = target->GetIncludeDirectories();
+    }
 
   // Support putting all the in-project include directories first if
   // it is requested by the project.
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 77ffd09..77c8862 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -195,6 +195,7 @@ public:
 
   /** Get the include flags for the current makefile and language.  */
   void GetIncludeDirectories(std::vector<std::string>& dirs,
+                             cmTarget* target,
                              const char* lang = "C");
 
   /** Compute the language used to compile the given source file.  */
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index dd313ca..75226b5 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -452,28 +452,6 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile()
       << "\n";
     }
 
-  // Store the include search path for this directory.
-  infoFileStream
-    << "# The C and CXX include file search paths:\n";
-  infoFileStream
-    << "SET(CMAKE_C_INCLUDE_PATH\n";
-  std::vector<std::string> includeDirs;
-  this->GetIncludeDirectories(includeDirs);
-  for(std::vector<std::string>::iterator i = includeDirs.begin();
-      i != includeDirs.end(); ++i)
-    {
-    infoFileStream
-      << "  \"" << this->Convert(i->c_str(),HOME_OUTPUT).c_str() << "\"\n";
-    }
-  infoFileStream
-    << "  )\n";
-  infoFileStream
-    << "SET(CMAKE_CXX_INCLUDE_PATH ${CMAKE_C_INCLUDE_PATH})\n";
-  infoFileStream
-    << "SET(CMAKE_Fortran_INCLUDE_PATH ${CMAKE_C_INCLUDE_PATH})\n";
-  infoFileStream
-    << "SET(CMAKE_ASM_INCLUDE_PATH ${CMAKE_C_INCLUDE_PATH})\n";
-
   // Store the include regular expressions for this directory.
   infoFileStream
     << "\n"
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index 1dfcbea..c846d6b 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -103,52 +103,9 @@ void cmLocalVisualStudio6Generator::OutputDSPFile()
       }
     }
 
-  // Setup /I and /LIBPATH options for the resulting DSP file.  VS 6
-  // truncates long include paths so make it as short as possible if
-  // the length threatens this problem.
-  unsigned int maxIncludeLength = 3000;
-  bool useShortPath = false;
-  for(int j=0; j < 2; ++j)
-    {
-    std::vector<std::string> includes;
-    this->GetIncludeDirectories(includes);
-    std::vector<std::string>::iterator i;
-    for(i = includes.begin(); i != includes.end(); ++i)
-      {
-      std::string tmp = 
-        this->ConvertToOptionallyRelativeOutputPath(i->c_str());
-      if(useShortPath)
-        {
-        cmSystemTools::GetShortPath(tmp.c_str(), tmp);
-        }
-      this->IncludeOptions +=  " /I ";
-
-      // quote if not already quoted
-      if (tmp[0] != '"')
-        {
-        this->IncludeOptions += "\"";
-        this->IncludeOptions += tmp;
-        this->IncludeOptions += "\"";
-        }
-      else
-        {
-        this->IncludeOptions += tmp;
-        }
-      }
-    if(j == 0 && this->IncludeOptions.size() > maxIncludeLength)
-      {
-      this->IncludeOptions = "";
-      useShortPath = true;
-      }
-    else
-      {
-      break;
-      }
-    }
-  
   // Create the DSP or set of DSP's for libraries and executables
 
-  cmTargets &tgts = this->Makefile->GetTargets(); 
+  cmTargets &tgts = this->Makefile->GetTargets();
   for(cmTargets::iterator l = tgts.begin(); 
       l != tgts.end(); l++)
     {
@@ -895,6 +852,61 @@ inline std::string removeQuotes(const std::string& s)
   return s;
 }
 
+
+std::string
+cmLocalVisualStudio6Generator::GetTargetIncludeOptions(cmTarget &target)
+{
+  std::string includeOptions;
+
+  // Setup /I and /LIBPATH options for the resulting DSP file.  VS 6
+  // truncates long include paths so make it as short as possible if
+  // the length threatens this problem.
+  unsigned int maxIncludeLength = 3000;
+  bool useShortPath = false;
+  for(int j=0; j < 2; ++j)
+    {
+    std::vector<std::string> includes;
+    this->GetIncludeDirectories(includes, &target);
+
+    std::vector<std::string>::iterator i;
+    for(i = includes.begin(); i != includes.end(); ++i)
+      {
+      std::string tmp =
+        this->ConvertToOptionallyRelativeOutputPath(i->c_str());
+      if(useShortPath)
+        {
+        cmSystemTools::GetShortPath(tmp.c_str(), tmp);
+        }
+      includeOptions +=  " /I ";
+
+      // quote if not already quoted
+      if (tmp[0] != '"')
+        {
+        includeOptions += "\"";
+        includeOptions += tmp;
+        includeOptions += "\"";
+        }
+      else
+        {
+        includeOptions += tmp;
+        }
+      }
+
+    if(j == 0 && includeOptions.size() > maxIncludeLength)
+      {
+      includeOptions = "";
+      useShortPath = true;
+      }
+    else
+      {
+      break;
+      }
+    }
+
+  return includeOptions;
+}
+
+
 // Code in blocks surrounded by a test for this definition is needed
 // only for compatibility with user project's replacement DSP
 // templates.  The CMake templates no longer use them.
@@ -1132,6 +1144,9 @@ void cmLocalVisualStudio6Generator
     }
 #endif
 
+  // Get include options for this target.
+  std::string includeOptions = this->GetTargetIncludeOptions(target);
+
   // Get extra linker options for this target type.
   std::string extraLinkOptions;
   std::string extraLinkOptionsDebug;
@@ -1510,7 +1525,7 @@ void cmLocalVisualStudio6Generator
                                  optionsRelWithDebInfo.c_str());
 
     cmSystemTools::ReplaceString(line, "BUILD_INCLUDES",
-                                 this->IncludeOptions.c_str());
+                                 includeOptions.c_str());
     cmSystemTools::ReplaceString(line, "TARGET_VERSION_FLAG",
                                  targetVersionFlag.c_str());
     cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_DEBUG",
diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h
index 195d654..c9c5dd1 100644
--- a/Source/cmLocalVisualStudio6Generator.h
+++ b/Source/cmLocalVisualStudio6Generator.h
@@ -89,7 +89,7 @@ private:
   void ComputeLinkOptions(cmTarget& target, const char* configName,
                           const std::string extraOptions,
                           std::string& options);
-  std::string IncludeOptions;
+  std::string GetTargetIncludeOptions(cmTarget &target);
   std::vector<std::string> Configurations;
 
   std::string GetConfigName(std::string const& configuration) const;
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 11a0387..1743517 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -807,7 +807,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
   targetOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n");
   fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
   std::vector<std::string> includes;
-  this->GetIncludeDirectories(includes);
+  this->GetIncludeDirectories(includes, &target);
   std::vector<std::string>::iterator i = includes.begin();
   for(;i != includes.end(); ++i)
     {
diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx
index 0b4eea5..03fe33d 100644
--- a/Source/cmMakeDepend.cxx
+++ b/Source/cmMakeDepend.cxx
@@ -54,16 +54,20 @@ void cmMakeDepend::SetMakefile(cmMakefile* makefile)
     this->Makefile->IncludeFileRegularExpression.c_str());
   this->ComplainFileRegularExpression.compile(
     this->Makefile->ComplainFileRegularExpression.c_str());
-  
-  // Now extract any include paths from the makefile flags
-  const std::vector<std::string>& includes =
-    this->Makefile->GetIncludeDirectories();
-  for(std::vector<std::string>::const_iterator j = includes.begin();
-      j != includes.end(); ++j)
+
+  // Now extract any include paths from the targets
+  cmTargets & targets = this->Makefile->GetTargets();
+  for (cmTargets::iterator l = targets.begin(); l != targets.end(); ++l)
     {
-    std::string path = *j;
-    this->Makefile->ExpandVariablesInString(path);
-    this->AddSearchPath(path.c_str());
+    const std::vector<std::string>& includes =
+      l->second.GetIncludeDirectories();
+    for(std::vector<std::string>::const_iterator j = includes.begin();
+        j != includes.end(); ++j)
+      {
+      std::string path = *j;
+      this->Makefile->ExpandVariablesInString(path);
+      this->AddSearchPath(path.c_str());
+      }
     }
 }
 
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index dd982fb..e5be4aa 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1069,6 +1069,35 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
       << "SET(CMAKE_Fortran_TARGET_MODULE_DIR \"" << mdir << "\")\n";
     }
 
+  // Target-specific include directories:
+  *this->InfoFileStream
+    << "\n"
+    << "# The include file search paths:\n";
+  *this->InfoFileStream
+    << "SET(CMAKE_C_TARGET_INCLUDE_PATH\n";
+  std::vector<std::string> includes;
+  this->LocalGenerator->GetIncludeDirectories(includes, this->Target);
+  for(std::vector<std::string>::iterator i = includes.begin();
+      i != includes.end(); ++i)
+    {
+    *this->InfoFileStream
+      << "  \""
+      << this->LocalGenerator->Convert(i->c_str(),
+                                       cmLocalGenerator::HOME_OUTPUT)
+      << "\"\n";
+    }
+  *this->InfoFileStream
+    << "  )\n";
+  *this->InfoFileStream
+    << "SET(CMAKE_CXX_TARGET_INCLUDE_PATH "
+    << "${CMAKE_C_TARGET_INCLUDE_PATH})\n";
+  *this->InfoFileStream
+    << "SET(CMAKE_Fortran_TARGET_INCLUDE_PATH "
+    << "${CMAKE_C_TARGET_INCLUDE_PATH})\n";
+  *this->InfoFileStream
+    << "SET(CMAKE_ASM_TARGET_INCLUDE_PATH "
+    << "${CMAKE_C_TARGET_INCLUDE_PATH})\n";
+
   // and now write the rule to use it
   std::vector<std::string> depends;
   std::vector<std::string> commands;
@@ -1534,7 +1563,7 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags()
   emitted.insert("/System/Library/Frameworks");
 #endif
   std::vector<std::string> includes;
-  this->LocalGenerator->GetIncludeDirectories(includes);
+  this->LocalGenerator->GetIncludeDirectories(includes, this->Target);
   std::vector<std::string>::iterator i;
   // check all include directories for frameworks as this
   // will already have added a -F for the framework
@@ -1831,7 +1860,7 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
 
 
   std::vector<std::string> includes;
-  this->LocalGenerator->GetIncludeDirectories(includes, lang);
+  this->LocalGenerator->GetIncludeDirectories(includes, this->Target, lang);
 
   std::string includeFlags =
     this->LocalGenerator->GetIncludeFlags(includes, lang, useResponseFile);
@@ -1934,7 +1963,7 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags)
      this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG"))
     {
     std::vector<std::string> includes;
-    this->LocalGenerator->GetIncludeDirectories(includes);
+    this->LocalGenerator->GetIncludeDirectories(includes, this->Target);
     for(std::vector<std::string>::const_iterator idi = includes.begin();
         idi != includes.end(); ++idi)
       {
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 9418761..f9148a1 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1586,7 +1586,7 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
     static_cast<cmGlobalVisualStudio7Generator *>
     (this->GlobalGenerator)->GetConfigurations();
   std::vector<std::string> includes;
-  this->LocalGenerator->GetIncludeDirectories(includes);
+  this->LocalGenerator->GetIncludeDirectories(includes, this->Target);
   for(std::vector<std::string>::iterator i = configs->begin();
       i != configs->end(); ++i)
     {
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 749caf5..fc530f9 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -598,16 +598,8 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
     std::string includes = mf->GetSafeDefinition("PACKAGE_INCLUDE_DIRS");
     std::vector<std::string> includeDirs;
     cmSystemTools::ExpandListArgument(includes, includeDirs);
-    for(std::vector<std::string>::const_iterator dirIt=includeDirs.begin();
-            dirIt != includeDirs.end();
-            ++dirIt)
-      {
-      mf->AddIncludeDirectory(dirIt->c_str(), false);
-      }
 
-    std::vector<std::string> includeDirectories;
-    lg->GetIncludeDirectories(includeDirectories, language.c_str());
-    std::string includeFlags = lg->GetIncludeFlags(includeDirectories,
+    std::string includeFlags = lg->GetIncludeFlags(includeDirs,
                                                    language.c_str(), false);
 
     std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS");
diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt
index 60b8c22..60f5e5e 100644
--- a/Tests/IncludeDirectories/CMakeLists.txt
+++ b/Tests/IncludeDirectories/CMakeLists.txt
@@ -45,3 +45,5 @@ else()
   set_target_properties(IncludeDirectories
     PROPERTIES COMPILE_FLAGS "-ITarProp")
 endif()
+
+add_subdirectory(TargetIncludeDirectories)
diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt
new file mode 100644
index 0000000..2cf36f5
--- /dev/null
+++ b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt
@@ -0,0 +1,26 @@
+
+cmake_minimum_required(VERSION 2.8)
+
+project(TargetIncludeDirectories)
+
+macro(create_header _name)
+  file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_name}")
+  file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_name}/${_name}.h"
+  "//${_name}.h
+  ")
+endmacro()
+
+create_header(bar)
+create_header(bat)
+create_header(foo)
+create_header(baz)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+include_directories("${CMAKE_CURRENT_BINARY_DIR}/bar")
+
+add_executable(TargetIncludeDirectories main.cpp)
+set_property(TARGET TargetIncludeDirectories APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/bat")
+set_property(TARGET TargetIncludeDirectories APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/foo")
+
+include_directories("${CMAKE_CURRENT_BINARY_DIR}/baz")
diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp
new file mode 100644
index 0000000..8aa3532
--- /dev/null
+++ b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp
@@ -0,0 +1,10 @@
+
+#include "bar.h"
+#include "bat.h"
+#include "foo.h"
+#include "baz.h"
+
+int main(int, char**)
+{
+  return 0;
+}

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=840509babb2d1c8fc5167c4580fef58546c06700
commit 840509babb2d1c8fc5167c4580fef58546c06700
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Dec 4 16:40:39 2011 +0100
Commit:     David Cole <david.cole at kitware.com>
CommitDate: Wed Feb 22 06:31:50 2012 -0500

    Keep the INCLUDE_DIRECTORIES target property up to date.
    
    The directory level property changes need to be added to it.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index cdb699e..6290412 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1648,6 +1648,15 @@ void cmMakefile::AddIncludeDirectory(const char* inc, bool before)
   cmProperty *prop =
     this->GetProperties().GetOrCreateProperty("INCLUDE_DIRECTORIES");
   AddStringToProperty(prop, "INCLUDE_DIRECTORIES", inc, before);
+
+  // Property on each target:
+  for (cmTargets::iterator l = this->Targets.begin();
+       l != this->Targets.end(); ++l)
+    {
+    cmTarget &t = l->second;
+    prop = t.GetProperties().GetOrCreateProperty("INCLUDE_DIRECTORIES");
+    AddStringToProperty(prop, "INCLUDE_DIRECTORIES", inc, before);
+    }
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 5c902e1..cd816a6 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1279,6 +1279,11 @@ void cmTarget::SetMakefile(cmMakefile* mf)
   // Save the backtrace of target construction.
   this->Makefile->GetBacktrace(this->Internal->Backtrace);
 
+  // Initialize the INCLUDE_DIRECTORIES property based on the current value
+  // of the same directory property:
+  this->SetProperty("INCLUDE_DIRECTORIES",
+                    this->Makefile->GetProperty("INCLUDE_DIRECTORIES"));
+
   // Record current policies for later use.
   this->PolicyStatusCMP0003 =
     this->Makefile->GetPolicyStatus(cmPolicies::CMP0003);

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a4d5f7b9b270d3fa85e8a0a1608c4205dff744d9
commit a4d5f7b9b270d3fa85e8a0a1608c4205dff744d9
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Dec 4 16:32:13 2011 +0100
Commit:     David Cole <david.cole at kitware.com>
CommitDate: Wed Feb 22 06:31:49 2012 -0500

    Add API to get the ordered includes for a target.

diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 0c79b30..5c902e1 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -4676,6 +4676,30 @@ cmTarget::GetLinkInformation(const char* config)
 }
 
 //----------------------------------------------------------------------------
+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()
 {
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 59f0184..dfed499 100644
--- a/Source/cmTarget.h
+++ b/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.

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8adaee2b0b2651cfd93bb4a915d11bdd4cba1b51
commit 8adaee2b0b2651cfd93bb4a915d11bdd4cba1b51
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Tue Jan 24 11:54:46 2012 -0500
Commit:     David Cole <david.cole at kitware.com>
CommitDate: Wed Feb 22 06:31:49 2012 -0500

    CMake: Eliminate cmMakefile::IncludeDirectories
    
    Instead, re-implement it in terms of the directory property INCLUDE_DIRECTORIES.

diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index fe481fa..27b1b1b 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1399,7 +1399,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
     }
 
   // Get the project-specified include directories.
-  std::vector<std::string>& includes =
+  const std::vector<std::string>& includes =
     this->Makefile->GetIncludeDirectories();
 
   // Support putting all the in-project include directories first if
@@ -1408,7 +1408,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
     {
     const char* topSourceDir = this->Makefile->GetHomeDirectory();
     const char* topBinaryDir = this->Makefile->GetHomeOutputDirectory();
-    for(std::vector<std::string>::iterator i = includes.begin();
+    for(std::vector<std::string>::const_iterator i = includes.begin();
         i != includes.end(); ++i)
       {
       // Emit this directory only if it is a subdirectory of the
@@ -1427,7 +1427,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
     }
 
   // Construct the final ordered include directory list.
-  for(std::vector<std::string>::iterator i = includes.begin();
+  for(std::vector<std::string>::const_iterator i = includes.begin();
       i != includes.end(); ++i)
     {
     if(emitted.insert(*i).second)
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index fdf5b31..cdb699e 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -116,7 +116,6 @@ cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals)
   this->Targets = mf.Targets;
   this->SourceFiles = mf.SourceFiles;
   this->Tests = mf.Tests;
-  this->IncludeDirectories = mf.IncludeDirectories;
   this->LinkDirectories = mf.LinkDirectories;
   this->SystemIncludeDirectories = mf.SystemIncludeDirectories;
   this->ListFiles = mf.ListFiles;
@@ -278,8 +277,6 @@ void cmMakefile::Print()
     this->cmHomeDirectory.c_str() << std::endl;
   std::cout << " this->ProjectName; "
             <<  this->ProjectName.c_str() << std::endl;
-  this->PrintStringVector("this->IncludeDirectories;",
-                          this->IncludeDirectories);
   this->PrintStringVector("this->LinkDirectories", this->LinkDirectories);
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   for( std::vector<cmSourceGroup>::const_iterator i =
@@ -1478,7 +1475,8 @@ void cmMakefile::InitializeFromParent()
   this->Internal->VarStack.top() = parent->Internal->VarStack.top().Closure();
 
   // copy include paths
-  this->IncludeDirectories = parent->IncludeDirectories;
+  this->SetProperty("INCLUDE_DIRECTORIES",
+                    parent->GetProperty("INCLUDE_DIRECTORIES"));
   this->SystemIncludeDirectories = parent->SystemIncludeDirectories;
 
   // define flags
@@ -1603,43 +1601,77 @@ void cmMakefile::AddSubDirectory(const char* srcPath, const char *binPath,
     }
 }
 
-void cmMakefile::AddIncludeDirectory(const char* inc, bool before)
+//----------------------------------------------------------------------------
+void AddStringToProperty(cmProperty *prop, const char* name, const char* s,
+                         bool before)
 {
-  // if there is a newline then break it into multiple arguments
-  if (!inc)
+  if (!prop)
     {
     return;
     }
 
-  // Don't add an include directory that is already present.  Yes,
-  // this linear search results in n^2 behavior, but n won't be
-  // getting much bigger than 20.  We cannot use a set because of
-  // order dependency of the include path.
-  std::vector<std::string>::iterator i =
-    std::find(this->IncludeDirectories.begin(),
-              this->IncludeDirectories.end(), inc);
-  if(i == this->IncludeDirectories.end())
+  // Don't worry about duplicates at this point. We eliminate them when
+  // we convert the property to a vector in GetIncludeDirectories.
+
+  if (before)
     {
-    if (before)
+    const char *val = prop->GetValue();
+    cmOStringStream oss;
+
+    if(val && *val)
       {
-      // WARNING: this *is* expensive (linear time) since it's a vector
-      this->IncludeDirectories.insert(this->IncludeDirectories.begin(), inc);
+      oss << s << ";" << val;
       }
     else
       {
-      this->IncludeDirectories.push_back(inc);
+      oss << s;
       }
+
+    std::string newVal = oss.str();
+    prop->Set(name, newVal.c_str());
     }
   else
     {
-    if(before)
+    prop->Append(name, s);
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmMakefile::AddIncludeDirectory(const char* inc, bool before)
+{
+  if (!inc)
+    {
+    return;
+    }
+
+  // Directory property:
+  cmProperty *prop =
+    this->GetProperties().GetOrCreateProperty("INCLUDE_DIRECTORIES");
+  AddStringToProperty(prop, "INCLUDE_DIRECTORIES", inc, before);
+}
+
+//----------------------------------------------------------------------------
+std::vector<std::string> cmMakefile::GetIncludeDirectories()
+{
+  std::vector<std::string> includes;
+  const char *val = this->GetProperty("INCLUDE_DIRECTORIES");
+  if(val)
+    {
+    cmSystemTools::ExpandListArgument(val, 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)
       {
-      // if this before and already in the path then remove it
-      this->IncludeDirectories.erase(i);
-      // WARNING: this *is* expensive (linear time) since it's a vector
-      this->IncludeDirectories.insert(this->IncludeDirectories.begin(), inc);
+      orderedAndUniqueIncludes.push_back(*li);
       }
     }
+
+  return orderedAndUniqueIncludes;
 }
 
 //----------------------------------------------------------------------------
@@ -2093,17 +2125,23 @@ void cmMakefile::AddExtraDirectory(const char* dir)
 }
 
 
-// expance CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR in the
+// expand CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR in the
 // include and library directories.
 
 void cmMakefile::ExpandVariables()
 {
   // Now expand variables in the include and link strings
-  for(std::vector<std::string>::iterator d = this->IncludeDirectories.begin();
-      d != this->IncludeDirectories.end(); ++d)
+
+  // May not be necessary anymore... But may need a policy for strict
+  // backwards compatibility
+  const char *includeDirs = this->GetProperty("INCLUDE_DIRECTORIES");
+  if (includeDirs)
     {
-    this->ExpandVariablesInString(*d, true, true);
+    std::string dirs = includeDirs;
+    this->ExpandVariablesInString(dirs, true, true);
+    this->SetProperty("INCLUDE_DIRECTORIES", dirs.c_str());
     }
+
   for(std::vector<std::string>::iterator d = this->LinkDirectories.begin();
       d != this->LinkDirectories.end(); ++d)
     {
@@ -3317,16 +3355,6 @@ void cmMakefile::SetProperty(const char* prop, const char* value)
 
   // handle special props
   std::string propname = prop;
-  if ( propname == "INCLUDE_DIRECTORIES" )
-    {
-    std::vector<std::string> varArgsExpanded;
-    if(value)
-      {
-      cmSystemTools::ExpandListArgument(value, varArgsExpanded);
-      }
-    this->SetIncludeDirectories(varArgsExpanded);
-    return;
-    }
 
   if ( propname == "LINK_DIRECTORIES" )
     {
@@ -3368,17 +3396,6 @@ void cmMakefile::AppendProperty(const char* prop, const char* value,
 
   // handle special props
   std::string propname = prop;
-  if ( propname == "INCLUDE_DIRECTORIES" )
-    {
-    std::vector<std::string> varArgsExpanded;
-    cmSystemTools::ExpandListArgument(value, varArgsExpanded);
-    for(std::vector<std::string>::const_iterator vi = varArgsExpanded.begin();
-        vi != varArgsExpanded.end(); ++vi)
-      {
-      this->AddIncludeDirectory(vi->c_str());
-      }
-    return;
-    }
 
   if ( propname == "LINK_DIRECTORIES" )
     {
@@ -3474,23 +3491,6 @@ const char *cmMakefile::GetProperty(const char* prop,
     output += this->DefineFlagsOrig;
     return output.c_str();
     }
-  else if (!strcmp("INCLUDE_DIRECTORIES",prop) )
-    {
-    cmOStringStream str;
-    for (std::vector<std::string>::const_iterator
-         it = this->GetIncludeDirectories().begin();
-         it != this->GetIncludeDirectories().end();
-         ++ it )
-      {
-      if ( it != this->GetIncludeDirectories().begin())
-        {
-        str << ";";
-        }
-      str << it->c_str();
-      }
-    output = str.str();
-    return output.c_str();
-    }
   else if (!strcmp("LINK_DIRECTORIES",prop))
     {
     cmOStringStream str;
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 1c46a73..5e5310f 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -524,18 +524,7 @@ public:
   /**
    * Get a list of include directories in the build.
    */
-  std::vector<std::string>& GetIncludeDirectories()
-    {
-      return this->IncludeDirectories;
-    }
-  const std::vector<std::string>& GetIncludeDirectories() const
-    {
-      return this->IncludeDirectories;
-    }
-  void SetIncludeDirectories(const std::vector<std::string>& vec)
-    {
-      this->IncludeDirectories = vec;
-    }
+  std::vector<std::string> GetIncludeDirectories();
 
   /**
    * Mark include directories as system directories.
@@ -880,9 +869,7 @@ protected:
   // Tests
   std::map<cmStdString, cmTest*> Tests;
 
-  // The include and link-library paths.  These may have order
-  // dependency, so they must be vectors (not set).
-  std::vector<std::string> IncludeDirectories;
+  // The link-library paths.  Order matters, use std::vector (not std::set).
   std::vector<std::string> LinkDirectories;
 
   // The set of include directories that are marked as system include

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7620932d8259572dc737d97cec83779efadab5a3
commit 7620932d8259572dc737d97cec83779efadab5a3
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Mon Nov 7 11:49:33 2011 +0100
Commit:     David Cole <david.cole at kitware.com>
CommitDate: Wed Feb 22 06:31:49 2012 -0500

    Remove include flags memoization.

diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 961de37..fe481fa 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1196,7 +1196,7 @@ cmLocalGenerator::ConvertToIncludeReference(std::string const& path)
 }
 
 //----------------------------------------------------------------------------
-const char* cmLocalGenerator::GetIncludeFlags(
+std::string cmLocalGenerator::GetIncludeFlags(
                                      const std::vector<std::string> &includes,
                                      const char* lang, bool forResponseFile)
 {
@@ -1204,12 +1204,6 @@ const char* cmLocalGenerator::GetIncludeFlags(
     {
     return "";
     }
-  std::string key = lang;
-  key += forResponseFile? "@" : "";
-  if(this->LanguageToIncludeFlags.count(key))
-    {
-    return this->LanguageToIncludeFlags[key].c_str();
-    }
 
   cmOStringStream includeFlags;
 
@@ -1314,12 +1308,7 @@ const char* cmLocalGenerator::GetIncludeFlags(
     {
     flags[flags.size()-1] = ' ';
     }
-  this->LanguageToIncludeFlags[key] = flags;
-
-  // Use this temorary variable for the return value to work-around a
-  // bogus GCC 2.95 warning.
-  const char* ret = this->LanguageToIncludeFlags[key].c_str();
-  return ret;
+  return flags;
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 7e737ef..77ffd09 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -146,7 +146,7 @@ public:
   ///! Append flags to a string.
   virtual void AppendFlags(std::string& flags, const char* newFlags);
   ///! Get the include flags for the current makefile and language
-  const char* GetIncludeFlags(const std::vector<std::string> &includes,
+  std::string GetIncludeFlags(const std::vector<std::string> &includes,
                               const char* lang, bool forResponseFile = false);
 
   /**
@@ -392,7 +392,6 @@ protected:
   std::vector<std::string> StartOutputDirectoryComponents;
   cmLocalGenerator* Parent;
   std::vector<cmLocalGenerator*> Children;
-  std::map<cmStdString, cmStdString> LanguageToIncludeFlags;
   std::map<cmStdString, cmStdString> UniqueObjectNamesMap;
   std::string::size_type ObjectPathMax;
   std::set<cmStdString> ObjectMaxPathViolations;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=97a5faa85895ca77679d794788731cf76b8704ce
commit 97a5faa85895ca77679d794788731cf76b8704ce
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Dec 4 16:45:39 2011 +0100
Commit:     David Cole <david.cole at kitware.com>
CommitDate: Wed Feb 22 06:31:49 2012 -0500

    Make it safe to call this method without creating duplicates.

diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index b02fc36..961de37 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1378,8 +1378,12 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
   // Store the automatic include paths.
   if(includeBinaryDir)
     {
-    dirs.push_back(this->Makefile->GetStartOutputDirectory());
-    emitted.insert(this->Makefile->GetStartOutputDirectory());
+    if(emitted.find(
+                this->Makefile->GetStartOutputDirectory()) == emitted.end())
+      {
+      dirs.push_back(this->Makefile->GetStartOutputDirectory());
+      emitted.insert(this->Makefile->GetStartOutputDirectory());
+      }
     }
   if(includeSourceDir)
     {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=edd5303949f9d0e1b4b11e83aecd34bfdb2700ce
commit edd5303949f9d0e1b4b11e83aecd34bfdb2700ce
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Dec 4 16:36:48 2011 +0100
Commit:     David Cole <david.cole at kitware.com>
CommitDate: Wed Feb 22 06:31:49 2012 -0500

    Refactor GetIncludeFlags to take includes instead of fetching them

diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index ffbeb48..b02fc36 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -574,7 +574,11 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
   std::string flags;
   flags += this->Makefile->GetSafeDefinition(varString.c_str());
   flags += " ";
-  flags += this->GetIncludeFlags(lang);
+    {
+    std::vector<std::string> includes;
+    this->GetIncludeDirectories(includes, lang);
+    flags += this->GetIncludeFlags(includes, lang);
+    }
   flags += this->Makefile->GetDefineFlags();
 
   // Construct the command lines.
@@ -1192,8 +1196,9 @@ cmLocalGenerator::ConvertToIncludeReference(std::string const& path)
 }
 
 //----------------------------------------------------------------------------
-const char* cmLocalGenerator::GetIncludeFlags(const char* lang,
-                                              bool forResponseFile)
+const char* cmLocalGenerator::GetIncludeFlags(
+                                     const std::vector<std::string> &includes,
+                                     const char* lang, bool forResponseFile)
 {
   if(!lang)
     {
@@ -1207,9 +1212,6 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang,
     }
 
   cmOStringStream includeFlags;
-  std::vector<std::string> includes;
-  this->GetIncludeDirectories(includes, lang);
-  std::vector<std::string>::iterator i;
 
   std::string flagVar = "CMAKE_INCLUDE_FLAG_";
   flagVar += lang;
@@ -1251,6 +1253,7 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang,
 #ifdef __APPLE__
   emitted.insert("/System/Library/Frameworks");
 #endif
+  std::vector<std::string>::const_iterator i;
   for(i = includes.begin(); i != includes.end(); ++i)
     {
     if(this->Makefile->IsOn("APPLE")
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 0c5b9d0..7e737ef 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -146,8 +146,8 @@ public:
   ///! Append flags to a string.
   virtual void AppendFlags(std::string& flags, const char* newFlags);
   ///! Get the include flags for the current makefile and language
-  const char* GetIncludeFlags(const char* lang,
-                              bool forResponseFile = false);
+  const char* GetIncludeFlags(const std::vector<std::string> &includes,
+                              const char* lang, bool forResponseFile = false);
 
   /**
    * Encode a list of preprocessor definitions for the compiler
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index a3a832b..dd982fb 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1829,8 +1829,12 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
   responseVar += "_USE_RESPONSE_FILE_FOR_INCLUDES";
   bool useResponseFile = this->Makefile->IsOn(responseVar.c_str());
 
+
+  std::vector<std::string> includes;
+  this->LocalGenerator->GetIncludeDirectories(includes, lang);
+
   std::string includeFlags =
-    this->LocalGenerator->GetIncludeFlags(lang, useResponseFile);
+    this->LocalGenerator->GetIncludeFlags(includes, lang, useResponseFile);
   if(includeFlags.empty())
     {
     return;
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index cce5080..749caf5 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -605,7 +605,11 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
       mf->AddIncludeDirectory(dirIt->c_str(), false);
       }
 
-    std::string includeFlags = lg->GetIncludeFlags(language.c_str(), false);
+    std::vector<std::string> includeDirectories;
+    lg->GetIncludeDirectories(includeDirectories, language.c_str());
+    std::string includeFlags = lg->GetIncludeFlags(includeDirectories,
+                                                   language.c_str(), false);
+
     std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS");
     printf("%s %s\n", includeFlags.c_str(), definitions.c_str());
     }

-----------------------------------------------------------------------

Summary of changes:
 Source/cmDepends.cxx                               |   14 ++-
 Source/cmExtraCodeBlocksGenerator.cxx              |   11 +-
 Source/cmExtraEclipseCDT4Generator.cxx             |   10 +-
 Source/cmGlobalGenerator.cxx                       |   39 +++---
 Source/cmGlobalXCodeGenerator.cxx                  |    2 +-
 Source/cmIncludeDirectoryCommand.h                 |   22 ++-
 Source/cmLocalGenerator.cxx                        |   52 ++++----
 Source/cmLocalGenerator.h                          |    6 +-
 Source/cmLocalUnixMakefileGenerator3.cxx           |   22 ---
 Source/cmLocalVisualStudio6Generator.cxx           |  105 ++++++++------
 Source/cmLocalVisualStudio6Generator.h             |    2 +-
 Source/cmLocalVisualStudio7Generator.cxx           |    2 +-
 Source/cmMakeDepend.cxx                            |   35 ++++-
 Source/cmMakefile.cxx                              |  154 +++++++++++---------
 Source/cmMakefile.h                                |   20 +---
 Source/cmMakefileTargetGenerator.cxx               |   39 +++++-
 Source/cmTarget.cxx                                |   49 ++++++
 Source/cmTarget.h                                  |    3 +
 Source/cmVisualStudio10TargetGenerator.cxx         |    2 +-
 Source/cmake.cxx                                   |   10 +-
 Tests/IncludeDirectories/CMakeLists.txt            |    2 +
 .../TargetIncludeDirectories/CMakeLists.txt        |   26 ++++
 .../TargetIncludeDirectories/main.cpp              |   10 ++
 23 files changed, 393 insertions(+), 244 deletions(-)
 create mode 100644 Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt
 create mode 100644 Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list