summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-12-17 16:53:21 (GMT)
committerBrad King <brad.king@kitware.com>2020-12-22 13:56:26 (GMT)
commit5115e8b2b669f09419f895a1375df285b675e9e7 (patch)
tree34bada11111fc504e212698df392816b8b71d3a7 /Source
parent6b6230b23b290694aad4c05d7a32fd8241f93ca5 (diff)
downloadCMake-5115e8b2b669f09419f895a1375df285b675e9e7.zip
CMake-5115e8b2b669f09419f895a1375df285b675e9e7.tar.gz
CMake-5115e8b2b669f09419f895a1375df285b675e9e7.tar.bz2
Xcode: Generalize inheritance of project-level search paths
Generalize the change from commit bffb17be3d (Xcode: Inherit target library and framework search paths from project, 2020-11-04, v3.19.0-rc3~4^2) to apply to framework and other kinds of search paths added either for include directories or for linking. Issue: #21617
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx45
-rw-r--r--Source/cmGlobalXCodeGenerator.h2
2 files changed, 37 insertions, 10 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 1ad611a..d59d382 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -3272,6 +3272,24 @@ void cmGlobalXCodeGenerator::AppendBuildSettingAttribute(
}
}
+void cmGlobalXCodeGenerator::InheritBuildSettingAttribute(
+ cmXCodeObject* target, const char* attribute)
+{
+ cmXCodeObject* configurationList =
+ target->GetAttribute("buildConfigurationList")->GetObject();
+ cmXCodeObject* buildConfigs =
+ configurationList->GetAttribute("buildConfigurations");
+ for (auto obj : buildConfigs->GetObjectList()) {
+ cmXCodeObject* settings = obj->GetAttribute("buildSettings");
+ if (cmXCodeObject* attr = settings->GetAttribute(attribute)) {
+ BuildObjectListOrString inherited(this, true);
+ inherited.Add("$(inherited)");
+ this->AppendBuildSettingAttribute(settings, attribute, attr,
+ inherited.CreateList());
+ }
+ }
+}
+
void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
{
cmGeneratorTarget* gt = target->GetTarget();
@@ -3588,11 +3606,11 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
for (auto& libDir : linkSearchPaths) {
libSearchPaths.Add(this->XCodeEscapePath(libDir));
}
- // Add paths defined in project-wide build settings
- libSearchPaths.Add("$(inherited)");
- this->AppendBuildSettingAttribute(target, "LIBRARY_SEARCH_PATHS",
- libSearchPaths.CreateList(),
- configName);
+ if (!libSearchPaths.IsEmpty()) {
+ this->AppendBuildSettingAttribute(target, "LIBRARY_SEARCH_PATHS",
+ libSearchPaths.CreateList(),
+ configName);
+ }
}
// add framework search paths
@@ -3603,11 +3621,11 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
for (auto& fwDir : frameworkSearchPaths) {
fwSearchPaths.Add(this->XCodeEscapePath(fwDir));
}
- // Add paths defined in project-wide build settings
- fwSearchPaths.Add("$(inherited)");
- this->AppendBuildSettingAttribute(target, "FRAMEWORK_SEARCH_PATHS",
- fwSearchPaths.CreateList(),
- configName);
+ if (!fwSearchPaths.IsEmpty()) {
+ this->AppendBuildSettingAttribute(target, "FRAMEWORK_SEARCH_PATHS",
+ fwSearchPaths.CreateList(),
+ configName);
+ }
}
// now add the left-over link libraries
@@ -4161,6 +4179,13 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
for (auto t : targets) {
this->AddDependAndLinkInformation(t);
this->AddEmbeddedFrameworks(t);
+ // Inherit project-wide values for any target-specific search paths.
+ this->InheritBuildSettingAttribute(t, "HEADER_SEARCH_PATHS");
+ this->InheritBuildSettingAttribute(t, "SYSTEM_HEADER_SEARCH_PATHS");
+ this->InheritBuildSettingAttribute(t, "FRAMEWORK_SEARCH_PATHS");
+ this->InheritBuildSettingAttribute(t, "SYSTEM_FRAMEWORK_SEARCH_PATHS");
+ this->InheritBuildSettingAttribute(t, "LIBRARY_SEARCH_PATHS");
+ this->InheritBuildSettingAttribute(t, "LD_RUNPATH_SEARCH_PATHS");
}
if (this->XcodeBuildSystem == BuildSystem::One) {
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 115fb61..14db1dc 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -188,6 +188,8 @@ private:
void AppendBuildSettingAttribute(cmXCodeObject* target, const char* attr,
cmXCodeObject* value,
const std::string& configName);
+ void InheritBuildSettingAttribute(cmXCodeObject* target,
+ const char* attribute);
cmXCodeObject* CreateUtilityTarget(cmGeneratorTarget* gtgt);
void AddDependAndLinkInformation(cmXCodeObject* target);
void AddEmbeddedFrameworks(cmXCodeObject* target);