mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-21 05:38:24 -05:00
@@ -1764,6 +1764,7 @@ bool cmGlobalGenerator::AddAutomaticSources()
|
||||
if (!gt->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM")) {
|
||||
lg->AddPchDependencies(gt.get());
|
||||
}
|
||||
lg->AddXCConfigSources(gt.get());
|
||||
}
|
||||
}
|
||||
for (const auto& lg : this->LocalGenerators) {
|
||||
|
||||
@@ -616,6 +616,16 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
|
||||
cmTarget* allbuild =
|
||||
root->AddUtilityCommand("ALL_BUILD", true, std::move(cc));
|
||||
|
||||
// Add xcconfig files to ALL_BUILD sources
|
||||
for (auto& config : this->CurrentConfigurationTypes) {
|
||||
auto xcconfig = cmGeneratorExpression::Evaluate(
|
||||
this->CurrentMakefile->GetSafeDefinition("CMAKE_XCODE_XCCONFIG"),
|
||||
this->CurrentLocalGenerator, config);
|
||||
if (!xcconfig.empty()) {
|
||||
allbuild->AddSource(xcconfig);
|
||||
}
|
||||
}
|
||||
|
||||
root->AddGeneratorTarget(cm::make_unique<cmGeneratorTarget>(allbuild, root));
|
||||
|
||||
// Add XCODE depend helper
|
||||
@@ -1142,6 +1152,9 @@ std::string GetSourcecodeValueFromFileExtension(
|
||||
} else if (ext == "xcassets") {
|
||||
keepLastKnownFileType = true;
|
||||
sourcecode = "folder.assetcatalog";
|
||||
} else if (ext == "xcconfig") {
|
||||
keepLastKnownFileType = true;
|
||||
sourcecode = "text.xcconfig";
|
||||
}
|
||||
// else
|
||||
// {
|
||||
@@ -3045,6 +3058,8 @@ std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target,
|
||||
config->AddAttribute("name", this->CreateString(i));
|
||||
config->SetComment(i);
|
||||
config->AddAttribute("buildSettings", buildSettings);
|
||||
|
||||
this->CreateTargetXCConfigSettings(gtgt, config, i);
|
||||
}
|
||||
if (!configVector.empty()) {
|
||||
configlist->AddAttribute("defaultConfigurationName",
|
||||
@@ -3056,6 +3071,67 @@ std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target,
|
||||
return "";
|
||||
}
|
||||
|
||||
void cmGlobalXCodeGenerator::CreateGlobalXCConfigSettings(
|
||||
cmLocalGenerator* root, cmXCodeObject* config, const std::string& configName)
|
||||
{
|
||||
auto xcconfig = cmGeneratorExpression::Evaluate(
|
||||
this->CurrentMakefile->GetSafeDefinition("CMAKE_XCODE_XCCONFIG"),
|
||||
this->CurrentLocalGenerator, configName);
|
||||
if (xcconfig.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto sf = this->CurrentMakefile->GetSource(xcconfig);
|
||||
if (!sf) {
|
||||
cmSystemTools::Error(
|
||||
cmStrCat("sources for ALL_BUILD do not contain xcconfig file: '",
|
||||
xcconfig, "' (configuration: ", configName, ")"));
|
||||
return;
|
||||
}
|
||||
|
||||
cmXCodeObject* fileRef = this->CreateXCodeFileReferenceFromPath(
|
||||
sf->ResolveFullPath(), root->FindGeneratorTargetToUse("ALL_BUILD"), "",
|
||||
sf);
|
||||
|
||||
if (!fileRef) {
|
||||
// error is already reported by CreateXCodeFileReferenceFromPath
|
||||
return;
|
||||
}
|
||||
|
||||
config->AddAttribute("baseConfigurationReference",
|
||||
this->CreateObjectReference(fileRef));
|
||||
}
|
||||
|
||||
void cmGlobalXCodeGenerator::CreateTargetXCConfigSettings(
|
||||
cmGeneratorTarget* target, cmXCodeObject* config,
|
||||
const std::string& configName)
|
||||
{
|
||||
auto xcconfig =
|
||||
cmGeneratorExpression::Evaluate(target->GetSafeProperty("XCODE_XCCONFIG"),
|
||||
this->CurrentLocalGenerator, configName);
|
||||
if (xcconfig.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto sf = target->Makefile->GetSource(xcconfig);
|
||||
if (!sf) {
|
||||
cmSystemTools::Error(cmStrCat("target sources for target ",
|
||||
target->Target->GetName(),
|
||||
" do not contain xcconfig file: '", xcconfig,
|
||||
"' (configuration: ", configName, ")"));
|
||||
return;
|
||||
}
|
||||
|
||||
cmXCodeObject* fileRef = this->CreateXCodeFileReferenceFromPath(
|
||||
sf->ResolveFullPath(), target, "", sf);
|
||||
if (!fileRef) {
|
||||
// error is already reported by CreateXCodeFileReferenceFromPath
|
||||
return;
|
||||
}
|
||||
config->AddAttribute("baseConfigurationReference",
|
||||
this->CreateObjectReference(fileRef));
|
||||
}
|
||||
|
||||
const char* cmGlobalXCodeGenerator::GetTargetLinkFlagsVar(
|
||||
cmGeneratorTarget const* target) const
|
||||
{
|
||||
@@ -4245,6 +4321,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
|
||||
}
|
||||
|
||||
for (auto& config : configs) {
|
||||
CreateGlobalXCConfigSettings(root, config.second, config.first);
|
||||
|
||||
cmXCodeObject* buildSettingsForCfg = this->CreateFlatClone(buildSettings);
|
||||
|
||||
// Put this last so it can override existing settings
|
||||
|
||||
@@ -224,6 +224,12 @@ private:
|
||||
void AddPositionIndependentLinkAttribute(cmGeneratorTarget* target,
|
||||
cmXCodeObject* buildSettings,
|
||||
const std::string& configName);
|
||||
void CreateGlobalXCConfigSettings(cmLocalGenerator* root,
|
||||
cmXCodeObject* config,
|
||||
const std::string& configName);
|
||||
void CreateTargetXCConfigSettings(cmGeneratorTarget* target,
|
||||
cmXCodeObject* config,
|
||||
const std::string& configName);
|
||||
void CreateBuildSettings(cmGeneratorTarget* gtgt,
|
||||
cmXCodeObject* buildSettings,
|
||||
const std::string& buildType);
|
||||
|
||||
@@ -170,6 +170,7 @@ public:
|
||||
void AddISPCDependencies(cmGeneratorTarget* target);
|
||||
void AddPchDependencies(cmGeneratorTarget* target);
|
||||
void AddUnityBuild(cmGeneratorTarget* target);
|
||||
virtual void AddXCConfigSources(cmGeneratorTarget* /* target */) {}
|
||||
void AppendIPOLinkerFlags(std::string& flags, cmGeneratorTarget* target,
|
||||
const std::string& config,
|
||||
const std::string& lang);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <ostream>
|
||||
#include <utility>
|
||||
|
||||
#include "cmGeneratorExpression.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmGlobalXCodeGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
@@ -134,3 +135,22 @@ void cmLocalXCodeGenerator::ComputeObjectFilenames(
|
||||
si.second = objectName;
|
||||
}
|
||||
}
|
||||
|
||||
void cmLocalXCodeGenerator::AddXCConfigSources(cmGeneratorTarget* target)
|
||||
{
|
||||
auto xcconfig = target->GetProperty("XCODE_XCCONFIG");
|
||||
if (!xcconfig) {
|
||||
return;
|
||||
}
|
||||
auto configs = target->Makefile->GetGeneratorConfigs(
|
||||
cmMakefile::IncludeEmptyConfig);
|
||||
|
||||
for (auto& config : configs) {
|
||||
auto file = cmGeneratorExpression::Evaluate(
|
||||
xcconfig,
|
||||
this, config);
|
||||
if (!file.empty()) {
|
||||
target->AddSource(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,5 +38,7 @@ public:
|
||||
std::map<cmSourceFile const*, std::string>& mapping,
|
||||
cmGeneratorTarget const* gt = nullptr) override;
|
||||
|
||||
void AddXCConfigSources(cmGeneratorTarget* target) override;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user