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.
This commit is contained in:
parent
261600bd09
commit
cb788e8f6d
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue