[cmake-commits] king committed cmIncludeDirectoryCommand.cxx 1.22 1.23 cmIncludeDirectoryCommand.h 1.12 1.13 cmLocalGenerator.cxx 1.156 1.157 cmMakefile.cxx 1.359 1.360 cmMakefile.h 1.195 1.196

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Oct 5 08:56:01 EDT 2006


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv29297/Source

Modified Files:
	cmIncludeDirectoryCommand.cxx cmIncludeDirectoryCommand.h 
	cmLocalGenerator.cxx cmMakefile.cxx cmMakefile.h 
Log Message:
ENH: Adding SYSTEM option to INCLUDE_DIRECTORIES command.  This addresses bug #3462.


Index: cmLocalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v
retrieving revision 1.156
retrieving revision 1.157
diff -u -d -r1.156 -r1.157
--- cmLocalGenerator.cxx	4 Oct 2006 22:52:28 -0000	1.156
+++ cmLocalGenerator.cxx	5 Oct 2006 12:55:59 -0000	1.157
@@ -1044,6 +1044,17 @@
     // given once i.e.  -classpath a:b:c
     repeatFlag = false;
     }
+
+  // Support special system include flag if it is available and the
+  // normal flag is repeated for each directory.
+  std::string sysFlagVar = "CMAKE_INCLUDE_SYSTEM_FLAG_";
+  sysFlagVar += lang;
+  const char* sysIncludeFlag = 0;
+  if(repeatFlag)
+    {
+    sysIncludeFlag = this->Makefile->GetDefinition(sysFlagVar.c_str());
+    }
+
   bool flagUsed = false;
   std::set<cmStdString> emitted;
   for(i = includes.begin(); i != includes.end(); ++i)
@@ -1066,7 +1077,15 @@
     std::string include = *i;
     if(!flagUsed || repeatFlag)
       {
-      includeFlags << includeFlag;
+      if(sysIncludeFlag &&
+         this->Makefile->IsSystemIncludeDirectory(i->c_str()))
+        {
+        includeFlags << sysIncludeFlag;
+        }
+      else
+        {
+        includeFlags << includeFlag;
+        }
       flagUsed = true;
       }
     std::string includePath = this->ConvertToOutputForExisting(i->c_str());

Index: cmIncludeDirectoryCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIncludeDirectoryCommand.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- cmIncludeDirectoryCommand.h	4 Apr 2006 13:35:22 -0000	1.12
+++ cmIncludeDirectoryCommand.h	5 Oct 2006 12:55:59 -0000	1.13
@@ -61,13 +61,16 @@
   virtual const char* GetFullDocumentation()
     {
     return
-      "  INCLUDE_DIRECTORIES([AFTER|BEFORE] dir1 dir2 ...)\n"
+      "  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. ";
+      "prepending, independent from the default. "
+      "If the SYSTEM option is given the compiler will be told that the "
+      "directories are meant as system include directories on some "
+      "platforms.";
     }
   
   cmTypeMacro(cmIncludeDirectoryCommand, cmCommand);

Index: cmIncludeDirectoryCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIncludeDirectoryCommand.cxx,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cmIncludeDirectoryCommand.cxx	23 Aug 2006 14:21:31 -0000	1.22
+++ cmIncludeDirectoryCommand.cxx	5 Oct 2006 12:55:59 -0000	1.23
@@ -28,6 +28,7 @@
   std::vector<std::string>::const_iterator i = args.begin();
 
   bool before = this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_BEFORE");
+  bool system = false;
 
   if ((*i) == "BEFORE")
     {
@@ -42,6 +43,11 @@
 
   for(; i != args.end(); ++i)
     {
+    if(*i == "SYSTEM")
+      {
+      system = true;
+      continue;
+      }
     if(i->size() == 0)
       {
       cmSystemTools::Error
@@ -60,6 +66,10 @@
         }
       }
     this->Makefile->AddIncludeDirectory(unixPath.c_str(), before);
+    if(system)
+      {
+      this->Makefile->AddSystemIncludeDirectory(unixPath.c_str());
+      }
     }
   return true;
 }

Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.195
retrieving revision 1.196
diff -u -d -r1.195 -r1.196
--- cmMakefile.h	4 Oct 2006 22:10:29 -0000	1.195
+++ cmMakefile.h	5 Oct 2006 12:55:59 -0000	1.196
@@ -441,6 +441,12 @@
       this->IncludeDirectories = vec;
     }
 
+  /**
+   * Mark include directories as system directories.
+   */
+  void AddSystemIncludeDirectory(const char* dir);
+  bool IsSystemIncludeDirectory(const char* dir);
+
   /** Expand out any arguements in the vector that have ; separated
    *  strings into multiple arguements.  A new vector is created 
    *  containing the expanded versions of all arguments in argsIn.
@@ -739,7 +745,11 @@
   // dependency, so they must be vectors (not set).
   std::vector<std::string> IncludeDirectories;
   std::vector<std::string> LinkDirectories;
-  
+
+  // The set of include directories that are marked as system include
+  // directories.
+  std::set<cmStdString> SystemIncludeDirectories;
+
   std::vector<std::string> ListFiles; // list of command files loaded
   std::vector<std::string> OutputFiles; // list of command files loaded
   

Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.359
retrieving revision 1.360
diff -u -d -r1.359 -r1.360
--- cmMakefile.cxx	4 Oct 2006 22:10:29 -0000	1.359
+++ cmMakefile.cxx	5 Oct 2006 12:55:59 -0000	1.360
@@ -106,6 +106,7 @@
   this->Tests = mf.Tests;
   this->IncludeDirectories = mf.IncludeDirectories;
   this->LinkDirectories = mf.LinkDirectories;
+  this->SystemIncludeDirectories = mf.SystemIncludeDirectories;
   this->ListFiles = mf.ListFiles;
   this->OutputFiles = mf.OutputFiles;
   this->LinkLibraries = mf.LinkLibraries;
@@ -1025,6 +1026,7 @@
 
   // copy include paths
   this->IncludeDirectories = parent->IncludeDirectories;
+  this->SystemIncludeDirectories = parent->SystemIncludeDirectories;
   
   // define flags
   this->DefineFlags = parent->DefineFlags;
@@ -1150,6 +1152,19 @@
     }
 }
 
+//----------------------------------------------------------------------------
+void cmMakefile::AddSystemIncludeDirectory(const char* dir)
+{
+  this->SystemIncludeDirectories.insert(dir);
+}
+
+//----------------------------------------------------------------------------
+bool cmMakefile::IsSystemIncludeDirectory(const char* dir)
+{
+  return (this->SystemIncludeDirectories.find(dir) !=
+          this->SystemIncludeDirectories.end());
+}
+
 void cmMakefile::AddDefinition(const char* name, const char* value)
 {
   if (!value )



More information about the Cmake-commits mailing list