summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-02-25 16:44:46 (GMT)
committerBrad King <brad.king@kitware.com>2009-02-25 16:44:46 (GMT)
commitcb788e8f6dfeeb5a934679f671adc87116837834 (patch)
treeed5632df00a4633e58b95538345cac730db49f1b
parent261600bd090d1946c7c4fed80660b2ace216ddf8 (diff)
downloadCMake-cb788e8f6dfeeb5a934679f671adc87116837834.zip
CMake-cb788e8f6dfeeb5a934679f671adc87116837834.tar.gz
CMake-cb788e8f6dfeeb5a934679f671adc87116837834.tar.bz2
ENH: Re-enable system include dir suppression
This creates variable CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES to specify implicit include directories on a per-language basis. This replaces the previous platform-wide variable. It is necessary to avoid explicit specification of -I/usr/include on some compilers (such as HP aCC) because: 1.) It may break ordering among system include directories defined internally by the compiler, thus getting wrong system headers. 2.) It tells the compiler to treat the system include directory as a user include directory, enabling warnings in the headers. See issue #8598.
-rw-r--r--Modules/Platform/UnixPaths.cmake7
-rw-r--r--Source/cmDocumentVariables.cxx9
-rw-r--r--Source/cmLocalGenerator.cxx22
3 files changed, 38 insertions, 0 deletions
diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake
index 7ed85c0..584d334 100644
--- a/Modules/Platform/UnixPaths.cmake
+++ b/Modules/Platform/UnixPaths.cmake
@@ -53,5 +53,12 @@ LIST(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
/lib /usr/lib /usr/lib32 /usr/lib64
)
+LIST(APPEND CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES
+ /usr/include
+ )
+LIST(APPEND CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
+ /usr/include
+ )
+
# Enable use of lib64 search path variants by default.
SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx
index 02f1d6a..27afd92 100644
--- a/Source/cmDocumentVariables.cxx
+++ b/Source/cmDocumentVariables.cxx
@@ -1097,6 +1097,15 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
"This is a list of file extensions that may be "
"part of a project for a given language but are not compiled. ",false,
"Variables for Languages");
+
+ cm->DefineProperty
+ ("CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES", cmProperty::VARIABLE,
+ "Directories implicitly searched by the compiler for header files.",
+ "CMake does not explicitly specify these directories on compiler "
+ "command lines for language <LANG>. "
+ "This prevents system include directories from being treated as user "
+ "include directories on some compilers.", false,
+ "Variables for Languages");
cm->DefineProperty
("CMAKE_<LANG>_LINKER_PREFERENCE", cmProperty::VARIABLE,
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index b2788ae..70e5760 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1186,6 +1186,23 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang)
{
return this->LanguageToIncludeFlags[lang].c_str();
}
+
+ // Load implicit include directories for this language.
+ std::set<cmStdString> impDirs;
+ std::string impDirVar = "CMAKE_";
+ impDirVar += lang;
+ impDirVar += "_IMPLICIT_INCLUDE_DIRECTORIES";
+ if(const char* value = this->Makefile->GetDefinition(impDirVar.c_str()))
+ {
+ std::vector<std::string> impDirVec;
+ cmSystemTools::ExpandListArgument(value, impDirVec);
+ for(std::vector<std::string>::const_iterator i = impDirVec.begin();
+ i != impDirVec.end(); ++i)
+ {
+ impDirs.insert(*i);
+ }
+ }
+
cmOStringStream includeFlags;
std::vector<std::string> includes;
this->GetIncludeDirectories(includes);
@@ -1233,6 +1250,11 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang)
#endif
for(i = includes.begin(); i != includes.end(); ++i)
{
+ // Skip implicit include directories.
+ if(impDirs.find(*i) != impDirs.end())
+ {
+ continue;
+ }
#ifdef __APPLE__
if(cmSystemTools::IsPathToFramework(i->c_str()))
{