From cb788e8f6dfeeb5a934679f671adc87116837834 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 25 Feb 2009 11:44:46 -0500 Subject: ENH: Re-enable system include dir suppression This creates variable CMAKE__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. --- Modules/Platform/UnixPaths.cmake | 7 +++++++ Source/cmDocumentVariables.cxx | 9 +++++++++ Source/cmLocalGenerator.cxx | 22 ++++++++++++++++++++++ 3 files changed, 38 insertions(+) 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__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 . " + "This prevents system include directories from being treated as user " + "include directories on some compilers.", false, + "Variables for Languages"); cm->DefineProperty ("CMAKE__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 impDirs; + std::string impDirVar = "CMAKE_"; + impDirVar += lang; + impDirVar += "_IMPLICIT_INCLUDE_DIRECTORIES"; + if(const char* value = this->Makefile->GetDefinition(impDirVar.c_str())) + { + std::vector impDirVec; + cmSystemTools::ExpandListArgument(value, impDirVec); + for(std::vector::const_iterator i = impDirVec.begin(); + i != impDirVec.end(); ++i) + { + impDirs.insert(*i); + } + } + cmOStringStream includeFlags; std::vector 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())) { -- cgit v0.12