diff options
author | Gregor Jasny <gjasny@googlemail.com> | 2015-08-31 20:33:37 (GMT) |
---|---|---|
committer | Gregor Jasny <gjasny@googlemail.com> | 2016-08-09 18:30:07 (GMT) |
commit | 93ac2a78d5e0dbb6607105cc8d2a3f19ebdd8583 (patch) | |
tree | 0534a5c5a6241ca5dc5f75338ab3d1fc3028cd7d /Source/cmGlobalXCodeGenerator.cxx | |
parent | 4689d16e8aa90e57a8456357251b6575131529d7 (diff) | |
download | CMake-93ac2a78d5e0dbb6607105cc8d2a3f19ebdd8583.zip CMake-93ac2a78d5e0dbb6607105cc8d2a3f19ebdd8583.tar.gz CMake-93ac2a78d5e0dbb6607105cc8d2a3f19ebdd8583.tar.bz2 |
Xcode: Obey SYSTEM keyword for includes (#15687)
CMake used to put all header search paths into HEADER_SEARCH_PATHS
attribute. Unfortunately this attribute does not support to declare
a search path as a system include.
As a hack one could add a -isystem /path to the cflags but then include
ordering is not deterministic. A better approach was chosen with this
patch by not filling HEADER_SEARCH_PATHS at all and to populate
the C, C++, and Fortran flags directly. The include paths used by
Xcode should be now identical to the ones used by Unix Makefiles and
Ninja generator.
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b396ea1..780ca90 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1907,23 +1907,40 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, BuildObjectListOrString dirs(this, this->XcodeVersion >= 30); BuildObjectListOrString fdirs(this, this->XcodeVersion >= 30); - std::vector<std::string> includes; - this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, "C", - configName); std::set<std::string> emitted; emitted.insert("/System/Library/Frameworks"); - for (std::vector<std::string>::iterator i = includes.begin(); - i != includes.end(); ++i) { - if (this->NameResolvesToFramework(i->c_str())) { - std::string frameworkDir = *i; - frameworkDir += "/../"; - frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); - if (emitted.insert(frameworkDir).second) { - fdirs.Add(this->XCodeEscapePath(frameworkDir)); + + if (this->XcodeVersion < 60) { + std::vector<std::string> includes; + this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, "C", + configName); + for (std::vector<std::string>::iterator i = includes.begin(); + i != includes.end(); ++i) { + if (this->NameResolvesToFramework(i->c_str())) { + std::string frameworkDir = *i; + frameworkDir += "/../"; + frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); + if (emitted.insert(frameworkDir).second) { + fdirs.Add(this->XCodeEscapePath(frameworkDir)); + } + } else { + std::string incpath = this->XCodeEscapePath(*i); + dirs.Add(incpath); + } + } + } else { + for (std::set<std::string>::iterator li = languages.begin(); + li != languages.end(); ++li) { + std::vector<std::string> includes; + this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, *li, + configName); + std::string includeFlags = this->CurrentLocalGenerator->GetIncludeFlags( + includes, gtgt, *li, true, false, configName); + + std::string& flags = cflags[*li]; + if (!includeFlags.empty()) { + flags += " " + includeFlags; } - } else { - std::string incpath = this->XCodeEscapePath(*i); - dirs.Add(incpath); } } // Add framework search paths needed for linking. @@ -2008,6 +2025,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, this->CreateString(flags)); } else if (*li == "C") { buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString(flags)); + } else if (*li == "Swift") { + buildSettings->AddAttribute("OTHER_SWIFT_FLAGS", + this->CreateString(flags)); } } |