mirror of
https://github.com/reactos/CMake.git
synced 2024-11-25 04:29:52 +00:00
Refactor exclusion of -I/usr/include to avoid per-language values
Add a `CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES` to contain the hard-coded list of paths to be excluded from `-I` arguments so that the values remain excluded even if the per-language `CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES` variants change. This is needed to preserve our historical exclusion of `-I/usr/include` even when it is not a real implicit include directory. A policy may be needed to remove it later.
This commit is contained in:
parent
a61c061b61
commit
15ad830062
@ -63,6 +63,13 @@ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
|
||||
/lib /lib32 /lib64 /usr/lib /usr/lib32 /usr/lib64
|
||||
)
|
||||
|
||||
# Platform-wide directories to avoid adding via -I<dir>.
|
||||
list(APPEND CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES
|
||||
/usr/include
|
||||
)
|
||||
|
||||
# Default per-language values. These may be later replaced after
|
||||
# parsing the implicit link directories from compiler output.
|
||||
list(APPEND CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES
|
||||
/usr/include
|
||||
)
|
||||
|
@ -947,21 +947,29 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories(
|
||||
rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT");
|
||||
}
|
||||
|
||||
std::vector<std::string> impDirVec;
|
||||
|
||||
// Get platform-wide implicit directories.
|
||||
if (const char* implicitIncludes = (this->Makefile->GetDefinition(
|
||||
"CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES"))) {
|
||||
cmSystemTools::ExpandListArgument(implicitIncludes, impDirVec);
|
||||
}
|
||||
|
||||
// Load implicit include directories for this language.
|
||||
std::string key = "CMAKE_";
|
||||
key += lang;
|
||||
key += "_IMPLICIT_INCLUDE_DIRECTORIES";
|
||||
if (const char* value = this->Makefile->GetDefinition(key)) {
|
||||
std::vector<std::string> impDirVec;
|
||||
cmSystemTools::ExpandListArgument(value, impDirVec);
|
||||
for (std::string const& i : impDirVec) {
|
||||
{
|
||||
std::string d = rootPath + i;
|
||||
cmSystemTools::ConvertToUnixSlashes(d);
|
||||
emitted.insert(std::move(d));
|
||||
}
|
||||
implicitDirs.push_back(i);
|
||||
}
|
||||
|
||||
for (std::string const& i : impDirVec) {
|
||||
{
|
||||
std::string d = rootPath + i;
|
||||
cmSystemTools::ConvertToUnixSlashes(d);
|
||||
emitted.insert(std::move(d));
|
||||
}
|
||||
implicitDirs.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user