BUG: Fix generation of Xcode 2.0 and earlier projects to use CMAKE_BUILD_TYPE.

This commit is contained in:
Brad King 2006-02-24 11:13:31 -05:00
parent f437c8e888
commit 576f0b65c7
6 changed files with 42 additions and 31 deletions

View File

@ -1031,27 +1031,18 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
std::string cflags;
if(lang)
{
// Temporarily set the CMAKE_BUILD_TYPE so the local generator can use
// it. TODO: The local generator methods should take the configuration
// name as input.
if(configName)
{
m_CurrentMakefile->AddDefinition("CMAKE_BUILD_TYPE", configName);
}
// for c++ projects get the c flags as well
if(strcmp(lang, "CXX") == 0)
{
m_CurrentLocalGenerator->AddLanguageFlags(cflags, "C");
m_CurrentLocalGenerator->AddLanguageFlags(cflags, "C", configName);
m_CurrentLocalGenerator->AddSharedFlags(cflags, lang, shared);
}
// Add language-specific flags.
m_CurrentLocalGenerator->AddLanguageFlags(flags, lang);
m_CurrentLocalGenerator->AddLanguageFlags(flags, lang, configName);
// Add shared-library flags if needed.
m_CurrentLocalGenerator->AddSharedFlags(flags, lang, shared);
// Remove the temporary CMAKE_BUILD_TYPE definition.
m_CurrentMakefile->AddDefinition("CMAKE_BUILD_TYPE", "");
}
// Add define flags
@ -1364,13 +1355,18 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget)
std::string fileTypeString;
std::string productTypeString;
std::string productName;
this->CreateBuildSettings(cmtarget,
buildSettings, fileTypeString,
productTypeString, productName, 0);
const char* globalConfig = 0;
if(m_XcodeVersion > 20)
{
this->AddConfigurations(target, cmtarget);
}
else
{
globalConfig = m_CurrentMakefile->GetDefinition("CMAKE_BUILD_TYPE");
}
this->CreateBuildSettings(cmtarget,
buildSettings, fileTypeString,
productTypeString, productName, globalConfig);
target->AddAttribute("buildSettings", buildSettings);
cmXCodeObject* dependencies = this->CreateObject(cmXCodeObject::OBJECT_LIST);
target->AddAttribute("dependencies", dependencies);
@ -1441,13 +1437,18 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget,
std::string fileTypeString;
std::string productTypeString;
std::string productName;
const char* globalConfig = 0;
if(m_XcodeVersion > 20)
{
this->AddConfigurations(target, cmtarget);
}
else
{
globalConfig = m_CurrentMakefile->GetDefinition("CMAKE_BUILD_TYPE");
}
this->CreateBuildSettings(cmtarget,
buildSettings, fileTypeString,
productTypeString, productName, 0);
productTypeString, productName, globalConfig);
target->AddAttribute("buildSettings", buildSettings);
cmXCodeObject* dependencies = this->CreateObject(cmXCodeObject::OBJECT_LIST);
target->AddAttribute("dependencies", dependencies);

View File

@ -1349,13 +1349,14 @@ cmLocalGenerator::ComputeLinkInformation(cmTarget& target,
//----------------------------------------------------------------------------
void cmLocalGenerator::AddLanguageFlags(std::string& flags,
const char* lang)
const char* lang,
const char* config)
{
// Add language-specific flags.
std::string flagsVar = "CMAKE_";
flagsVar += lang;
flagsVar += "_FLAGS";
this->AddConfigVariableFlags(flags, flagsVar.c_str());
this->AddConfigVariableFlags(flags, flagsVar.c_str(), config);
}
//----------------------------------------------------------------------------
@ -1443,18 +1444,18 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags,
//----------------------------------------------------------------------------
void cmLocalGenerator::AddConfigVariableFlags(std::string& flags,
const char* var)
const char* var,
const char* config)
{
// Add the flags from the variable itself.
std::string flagsVar = var;
this->AppendFlags(flags, m_Makefile->GetDefinition(flagsVar.c_str()));
// Add the flags from the build-type specific variable.
const char* buildType = m_Makefile->GetDefinition("CMAKE_BUILD_TYPE");
if(buildType && *buildType)
if(config && *config)
{
flagsVar += "_";
flagsVar += cmSystemTools::UpperCase(buildType);
flagsVar += cmSystemTools::UpperCase(config);
this->AppendFlags(flags, m_Makefile->GetDefinition(flagsVar.c_str()));
}
}

View File

@ -127,9 +127,11 @@ public:
std::vector<cmLocalGenerator*>& GetChildren() { return this->Children; };
void AddLanguageFlags(std::string& flags, const char* lang);
void AddLanguageFlags(std::string& flags, const char* lang,
const char* config);
void AddSharedFlags(std::string& flags, const char* lang, bool shared);
void AddConfigVariableFlags(std::string& flags, const char* var);
void AddConfigVariableFlags(std::string& flags, const char* var,
const char* config);
void AppendFlags(std::string& flags, const char* newFlags);
///! Get the include flags for the current makefile and language
const char* GetIncludeFlags(const char* lang);

View File

@ -187,7 +187,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Add flags to create an executable.
this->LocalGenerator->
AddConfigVariableFlags(linkFlags, "CMAKE_EXE_LINKER_FLAGS");
AddConfigVariableFlags(linkFlags, "CMAKE_EXE_LINKER_FLAGS",
this->LocalGenerator->m_ConfigurationName.c_str());
if(this->Target->GetPropertyAsBool("WIN32_EXECUTABLE"))
@ -202,7 +203,9 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
}
// Add language-specific flags.
this->LocalGenerator->AddLanguageFlags(flags, linkLanguage);
this->LocalGenerator
->AddLanguageFlags(flags, linkLanguage,
this->LocalGenerator->m_ConfigurationName.c_str());
// Add target-specific linker flags.
this->LocalGenerator->AppendFlags(linkFlags, this->Target->GetProperty("LINK_FLAGS"));

View File

@ -109,7 +109,8 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
std::string extraFlags;
this->LocalGenerator->AppendFlags(extraFlags, this->Target->GetProperty("LINK_FLAGS"));
this->LocalGenerator->AddConfigVariableFlags(extraFlags, "CMAKE_SHARED_LINKER_FLAGS");
this->LocalGenerator->AddConfigVariableFlags(extraFlags, "CMAKE_SHARED_LINKER_FLAGS",
this->LocalGenerator->m_ConfigurationName.c_str());
if(this->Makefile->IsOn("WIN32") && !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW")))
{
const std::vector<cmSourceFile*>& sources = this->Target->GetSourceFiles();
@ -142,7 +143,8 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
std::string extraFlags;
this->LocalGenerator->AppendFlags(extraFlags, this->Target->GetProperty("LINK_FLAGS"));
this->LocalGenerator->AddConfigVariableFlags(extraFlags, "CMAKE_MODULE_LINKER_FLAGS");
this->LocalGenerator->AddConfigVariableFlags(extraFlags, "CMAKE_MODULE_LINKER_FLAGS",
this->LocalGenerator->m_ConfigurationName.c_str());
// TODO: .def files should be supported here also.
this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
}

View File

@ -219,7 +219,9 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
}
// Add language-specific flags.
this->LocalGenerator->AddLanguageFlags(flags, lang);
this->LocalGenerator
->AddLanguageFlags(flags, lang,
this->LocalGenerator->m_ConfigurationName.c_str());
// Add shared-library flags if needed.
this->LocalGenerator->AddSharedFlags(flags, lang, shared);