Add use of EFFECTIVE_PLATFORM_NAME to generated Xcode projects.

Facilitates building iOS projects, enabling switching back and forth
between simulator and device builds at development time.
This commit is contained in:
David Cole 2011-07-18 15:25:30 -04:00
parent fefaaa09d9
commit 0c030ef72c
3 changed files with 30 additions and 9 deletions

View File

@ -1480,7 +1480,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
BuildObjectListOrString ppDefs(this, this->XcodeVersion >= 30); BuildObjectListOrString ppDefs(this, this->XcodeVersion >= 30);
if(this->XcodeVersion > 15) if(this->XcodeVersion > 15)
{ {
this->AppendDefines(ppDefs, "CMAKE_INTDIR=\"$(CONFIGURATION)\""); this->AppendDefines(ppDefs,
"CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"");
} }
if(const char* exportMacro = target.GetExportMacro()) if(const char* exportMacro = target.GetExportMacro())
{ {
@ -1597,9 +1598,12 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
{ {
if(this->XcodeVersion >= 21) if(this->XcodeVersion >= 21)
{ {
std::string pncdir = target.GetDirectory(configName); if(!target.UsesDefaultOutputDir(configName, false))
buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR", {
this->CreateString(pncdir.c_str())); std::string pncdir = target.GetDirectory(configName);
buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
this->CreateString(pncdir.c_str()));
}
} }
else else
{ {
@ -2399,10 +2403,10 @@ void cmGlobalXCodeGenerator
{ {
if(this->XcodeVersion > 15) if(this->XcodeVersion > 15)
{ {
// now add the same one but append $(CONFIGURATION) to it: // now add the same one but append $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to it:
linkDirs += " "; linkDirs += " ";
linkDirs += this->XCodeEscapePath( linkDirs += this->XCodeEscapePath(
(*libDir + "/$(CONFIGURATION)").c_str()); (*libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)").c_str());
} }
linkDirs += " "; linkDirs += " ";
linkDirs += this->XCodeEscapePath(libDir->c_str()); linkDirs += this->XCodeEscapePath(libDir->c_str());
@ -3173,7 +3177,8 @@ cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const char* cmGlobalXCodeGenerator::GetCMakeCFGInitDirectory() const char* cmGlobalXCodeGenerator::GetCMakeCFGInitDirectory()
{ {
return this->XcodeVersion >= 21? "$(CONFIGURATION)" : "."; return this->XcodeVersion >= 21 ?
"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)" : ".";
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -3688,9 +3688,11 @@ const char* cmTarget::GetOutputTargetType(bool implib)
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::ComputeOutputDir(const char* config, bool cmTarget::ComputeOutputDir(const char* config,
bool implib, std::string& out) bool implib, std::string& out)
{ {
bool usesDefaultOutputDir = false;
// Look for a target property defining the target output directory // Look for a target property defining the target output directory
// based on the target type. // based on the target type.
std::string targetTypeName = this->GetOutputTargetType(implib); std::string targetTypeName = this->GetOutputTargetType(implib);
@ -3742,6 +3744,7 @@ void cmTarget::ComputeOutputDir(const char* config,
if(out.empty()) if(out.empty())
{ {
// Default to the current output directory. // Default to the current output directory.
usesDefaultOutputDir = true;
out = "."; out = ".";
} }
@ -3757,6 +3760,15 @@ void cmTarget::ComputeOutputDir(const char* config,
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()-> this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->
AppendDirectoryForConfig("/", config, "", out); AppendDirectoryForConfig("/", config, "", out);
} }
return usesDefaultOutputDir;
}
//----------------------------------------------------------------------------
bool cmTarget::UsesDefaultOutputDir(const char* config, bool implib)
{
std::string dir;
return this->ComputeOutputDir(config, implib, dir);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -446,6 +446,10 @@ public:
/** Get a build-tree directory in which to place target support files. */ /** Get a build-tree directory in which to place target support files. */
std::string GetSupportDirectory() const; std::string GetSupportDirectory() const;
/** Return whether this target uses the default value for its output
directory. */
bool UsesDefaultOutputDir(const char* config, bool implib);
private: private:
/** /**
* A list of direct dependencies. Use in conjunction with DependencyMap. * A list of direct dependencies. Use in conjunction with DependencyMap.
@ -558,7 +562,7 @@ private:
// Cache target output paths for each configuration. // Cache target output paths for each configuration.
struct OutputInfo; struct OutputInfo;
OutputInfo const* GetOutputInfo(const char* config); OutputInfo const* GetOutputInfo(const char* config);
void ComputeOutputDir(const char* config, bool implib, std::string& out); bool ComputeOutputDir(const char* config, bool implib, std::string& out);
// Cache import information from properties for each configuration. // Cache import information from properties for each configuration.
struct ImportInfo; struct ImportInfo;