stringapi: Use strings for the languages
This commit is contained in:
parent
83a5e453f8
commit
ce5114354c
|
@ -268,7 +268,7 @@ cmComputeLinkInformation
|
|||
|
||||
// Get the language used for linking this target.
|
||||
this->LinkLanguage = this->Target->GetLinkerLanguage(config, headTarget);
|
||||
if(!this->LinkLanguage)
|
||||
if(this->LinkLanguage.empty())
|
||||
{
|
||||
// The Compute method will do nothing, so skip the rest of the
|
||||
// initialization.
|
||||
|
@ -496,7 +496,7 @@ bool cmComputeLinkInformation::Compute()
|
|||
}
|
||||
|
||||
// We require a link language for the target.
|
||||
if(!this->LinkLanguage)
|
||||
if(this->LinkLanguage.empty())
|
||||
{
|
||||
cmSystemTools::
|
||||
Error("CMake can not determine linker language for target: ",
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
std::vector<std::string> const& GetDirectories();
|
||||
std::vector<std::string> const& GetDepends();
|
||||
std::vector<std::string> const& GetFrameworkPaths();
|
||||
const char* GetLinkLanguage() const { return this->LinkLanguage; }
|
||||
std::string GetLinkLanguage() const { return this->LinkLanguage; }
|
||||
std::vector<std::string> const& GetRuntimeSearchPath();
|
||||
std::string const& GetRuntimeFlag() const { return this->RuntimeFlag; }
|
||||
std::string const& GetRuntimeSep() const { return this->RuntimeSep; }
|
||||
|
@ -83,7 +83,7 @@ private:
|
|||
|
||||
// Configuration information.
|
||||
const char* Config;
|
||||
const char* LinkLanguage;
|
||||
std::string LinkLanguage;
|
||||
bool LinkDependsNoShared;
|
||||
|
||||
// Modes for dealing with dependent shared libraries.
|
||||
|
|
|
@ -249,7 +249,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
|
|||
si != sources.end(); ++si)
|
||||
{
|
||||
std::string ext = cmSystemTools::GetFilenameLastExtension(*si);
|
||||
if(const char* lang = gg->GetLanguageFromExtension(ext.c_str()))
|
||||
std::string lang = gg->GetLanguageFromExtension(ext.c_str());
|
||||
if(!lang.empty())
|
||||
{
|
||||
testLangs.insert(lang);
|
||||
}
|
||||
|
|
|
@ -297,7 +297,7 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends,
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmDepends::SetIncludePathFromLanguage(const char* lang)
|
||||
void cmDepends::SetIncludePathFromLanguage(const std::string& lang)
|
||||
{
|
||||
// Look for the new per "TARGET_" variant first:
|
||||
const char * includePath = 0;
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
void SetLocalGenerator(cmLocalGenerator* lg) { this->LocalGenerator = lg; }
|
||||
|
||||
/** Set the specific language to be scanned. */
|
||||
void SetLanguage(const char* lang) { this->Language = lang; }
|
||||
void SetLanguage(const std::string& lang) { this->Language = lang; }
|
||||
|
||||
/** Set the target build directory. */
|
||||
void SetTargetDirectory(const char* dir) { this->TargetDirectory = dir; }
|
||||
|
@ -114,7 +114,7 @@ protected:
|
|||
// The include file search path.
|
||||
std::vector<std::string> IncludePath;
|
||||
|
||||
void SetIncludePathFromLanguage(const char* lang);
|
||||
void SetIncludePathFromLanguage(const std::string& lang);
|
||||
|
||||
private:
|
||||
cmDepends(cmDepends const&); // Purposely not implemented.
|
||||
|
|
|
@ -37,7 +37,7 @@ cmDependsC::cmDependsC()
|
|||
//----------------------------------------------------------------------------
|
||||
cmDependsC::cmDependsC(cmLocalGenerator* lg,
|
||||
const char* targetDir,
|
||||
const char* lang,
|
||||
const std::string& lang,
|
||||
const std::map<std::string, DependencyVector>* validDeps)
|
||||
: cmDepends(lg, targetDir)
|
||||
, ValidDeps(validDeps)
|
||||
|
|
|
@ -25,7 +25,8 @@ public:
|
|||
/** Checking instances need to know the build directory name and the
|
||||
relative path from the build directory to the target file. */
|
||||
cmDependsC();
|
||||
cmDependsC(cmLocalGenerator* lg, const char* targetDir, const char* lang,
|
||||
cmDependsC(cmLocalGenerator* lg, const char* targetDir,
|
||||
const std::string& lang,
|
||||
const std::map<std::string, DependencyVector>* validDeps);
|
||||
|
||||
/** Virtual destructor to cleanup subclasses properly. */
|
||||
|
|
|
@ -411,7 +411,8 @@ void cmExtraCodeBlocksGenerator
|
|||
|
||||
// check whether it is a C/C++ implementation file
|
||||
bool isCFile = false;
|
||||
if ((*si)->GetLanguage() && (*(*si)->GetLanguage() == 'C'))
|
||||
std::string lang = (*si)->GetLanguage();
|
||||
if (lang == "C" || lang == "CXX")
|
||||
{
|
||||
for(std::vector<std::string>::const_iterator
|
||||
ext = mf->GetSourceExtensions().begin();
|
||||
|
|
|
@ -220,7 +220,8 @@ void cmExtraCodeLiteGenerator
|
|||
{
|
||||
// check whether it is a C/C++ implementation file
|
||||
bool isCFile = false;
|
||||
if ((*si)->GetLanguage() && (*(*si)->GetLanguage() == 'C'))
|
||||
std::string lang = (*si)->GetLanguage();
|
||||
if (lang == "C" || lang == "CXX")
|
||||
{
|
||||
for(std::vector<std::string>::const_iterator
|
||||
ext = mf->GetSourceExtensions().begin();
|
||||
|
|
|
@ -369,8 +369,8 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
|
|||
std::string flags;
|
||||
|
||||
cmMakefile *makefile = lg->GetMakefile();
|
||||
const char* language = source->GetLanguage();
|
||||
if (language == NULL)
|
||||
std::string language = source->GetLanguage();
|
||||
if (language.empty())
|
||||
{
|
||||
language = "C";
|
||||
}
|
||||
|
@ -423,11 +423,7 @@ ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target,
|
|||
{
|
||||
std::set<std::string> defines;
|
||||
cmMakefile *makefile = lg->GetMakefile();
|
||||
const char* language = source->GetLanguage();
|
||||
if (language == NULL)
|
||||
{
|
||||
language = "";
|
||||
}
|
||||
const std::string& language = source->GetLanguage();
|
||||
const char* config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
|
||||
|
||||
// Add the export symbol definition for shared library objects.
|
||||
|
|
|
@ -990,8 +990,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
|||
"link libraries for a static library");
|
||||
return std::string();
|
||||
}
|
||||
const char *lang = target->GetLinkerLanguage(context->Config);
|
||||
return lang ? lang : "";
|
||||
return target->GetLinkerLanguage(context->Config);
|
||||
}
|
||||
|
||||
cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace,
|
||||
|
|
|
@ -168,7 +168,7 @@ struct TagVisitor
|
|||
this->BadObjLibFiles.push_back(sf);
|
||||
}
|
||||
}
|
||||
else if(sf->GetLanguage())
|
||||
else if(!sf->GetLanguage().empty())
|
||||
{
|
||||
DoAccept<IsSameTag<Tag, ObjectSourcesTag>::Result>::Do(this->Data, sf);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ bool cmGetSourceFilePropertyCommand
|
|||
{
|
||||
if(args[2] == "LANGUAGE")
|
||||
{
|
||||
this->Makefile->AddDefinition(var, sf->GetLanguage());
|
||||
this->Makefile->AddDefinition(var, sf->GetLanguage().c_str());
|
||||
return true;
|
||||
}
|
||||
const char *prop = sf->GetPropertyForUser(args[2].c_str());
|
||||
|
|
|
@ -722,7 +722,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os,
|
||||
std::string lang,
|
||||
std::string const& lang,
|
||||
const char* envVar) const
|
||||
{
|
||||
// Subclasses override this method if they do not support this advice.
|
||||
|
@ -744,7 +744,7 @@ void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os,
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
|
||||
std::string lang) const
|
||||
std::string const& lang) const
|
||||
{
|
||||
std::string compilerIdVar = "CMAKE_" + lang + "_COMPILER_ID";
|
||||
const char* compilerId = mf->GetDefinition(compilerIdVar.c_str());
|
||||
|
@ -817,17 +817,18 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const char*
|
||||
std::string
|
||||
cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) const
|
||||
{
|
||||
if(const char* lang = source.GetLanguage())
|
||||
const std::string& lang = source.GetLanguage();
|
||||
if(!lang.empty())
|
||||
{
|
||||
std::map<cmStdString, cmStdString>::const_iterator it =
|
||||
this->LanguageToOutputExtension.find(lang);
|
||||
|
||||
if(it != this->LanguageToOutputExtension.end())
|
||||
{
|
||||
return it->second.c_str();
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -840,7 +841,7 @@ cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) const
|
|||
{
|
||||
if(this->OutputExtensions.count(ext))
|
||||
{
|
||||
return ext.c_str();
|
||||
return ext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -848,7 +849,7 @@ cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) const
|
|||
}
|
||||
|
||||
|
||||
const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const
|
||||
std::string cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const
|
||||
{
|
||||
// if there is an extension and it starts with . then move past the
|
||||
// . because the extensions are not stored with a . in the map
|
||||
|
@ -860,9 +861,9 @@ const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const
|
|||
= this->ExtensionToLanguage.find(ext);
|
||||
if(it != this->ExtensionToLanguage.end())
|
||||
{
|
||||
return it->second.c_str();
|
||||
return it->second;
|
||||
}
|
||||
return 0;
|
||||
return "";
|
||||
}
|
||||
|
||||
/* SetLanguageEnabled() is now split in two parts:
|
||||
|
@ -877,13 +878,15 @@ files could change the object file extension
|
|||
(CMAKE_<LANG>_OUTPUT_EXTENSION) before the CMake variables were copied
|
||||
to the C++ maps.
|
||||
*/
|
||||
void cmGlobalGenerator::SetLanguageEnabled(const char* l, cmMakefile* mf)
|
||||
void cmGlobalGenerator::SetLanguageEnabled(const std::string& l,
|
||||
cmMakefile* mf)
|
||||
{
|
||||
this->SetLanguageEnabledFlag(l, mf);
|
||||
this->SetLanguageEnabledMaps(l, mf);
|
||||
}
|
||||
|
||||
void cmGlobalGenerator::SetLanguageEnabledFlag(const char* l, cmMakefile* mf)
|
||||
void cmGlobalGenerator::SetLanguageEnabledFlag(const std::string& l,
|
||||
cmMakefile* mf)
|
||||
{
|
||||
this->LanguageEnabled[l] = true;
|
||||
|
||||
|
@ -895,7 +898,8 @@ void cmGlobalGenerator::SetLanguageEnabledFlag(const char* l, cmMakefile* mf)
|
|||
this->FillExtensionToLanguageMap(l, mf);
|
||||
}
|
||||
|
||||
void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf)
|
||||
void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l,
|
||||
cmMakefile* mf)
|
||||
{
|
||||
// use LanguageToLinkerPreference to detect whether this functions has
|
||||
// run before
|
||||
|
@ -969,7 +973,7 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf)
|
|||
|
||||
}
|
||||
|
||||
void cmGlobalGenerator::FillExtensionToLanguageMap(const char* l,
|
||||
void cmGlobalGenerator::FillExtensionToLanguageMap(const std::string& l,
|
||||
cmMakefile* mf)
|
||||
{
|
||||
std::string extensionsVar = std::string("CMAKE_") +
|
||||
|
@ -986,14 +990,14 @@ void cmGlobalGenerator::FillExtensionToLanguageMap(const char* l,
|
|||
|
||||
bool cmGlobalGenerator::IgnoreFile(const char* l) const
|
||||
{
|
||||
if(this->GetLanguageFromExtension(l))
|
||||
if(!this->GetLanguageFromExtension(l).empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (this->IgnoreExtensions.count(l) > 0);
|
||||
}
|
||||
|
||||
bool cmGlobalGenerator::GetLanguageEnabled(const char* l) const
|
||||
bool cmGlobalGenerator::GetLanguageEnabled(const std::string& l) const
|
||||
{
|
||||
return (this->LanguageEnabled.find(l)!= this->LanguageEnabled.end());
|
||||
}
|
||||
|
@ -1958,7 +1962,7 @@ cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang) const
|
|||
}
|
||||
}
|
||||
|
||||
int cmGlobalGenerator::GetLinkerPreference(const char* lang) const
|
||||
int cmGlobalGenerator::GetLinkerPreference(const std::string& lang) const
|
||||
{
|
||||
std::map<cmStdString, int>::const_iterator it =
|
||||
this->LanguageToLinkerPreference.find(lang);
|
||||
|
|
|
@ -77,8 +77,8 @@ public:
|
|||
/**
|
||||
* Set/Get and Clear the enabled languages.
|
||||
*/
|
||||
void SetLanguageEnabled(const char*, cmMakefile* mf);
|
||||
bool GetLanguageEnabled(const char*) const;
|
||||
void SetLanguageEnabled(const std::string&, cmMakefile* mf);
|
||||
bool GetLanguageEnabled(const std::string&) const;
|
||||
void ClearEnabledLanguages();
|
||||
void GetEnabledLanguages(std::vector<std::string>& lang) const;
|
||||
/**
|
||||
|
@ -182,13 +182,13 @@ public:
|
|||
bool GetToolSupportsColor() const { return this->ToolSupportsColor; }
|
||||
|
||||
///! return the language for the given extension
|
||||
const char* GetLanguageFromExtension(const char* ext) const;
|
||||
std::string GetLanguageFromExtension(const char* ext) const;
|
||||
///! is an extension to be ignored
|
||||
bool IgnoreFile(const char* ext) const;
|
||||
///! What is the preference for linkers and this language (None or Prefered)
|
||||
int GetLinkerPreference(const char* lang) const;
|
||||
int GetLinkerPreference(const std::string& lang) const;
|
||||
///! What is the object file extension for a given source file?
|
||||
const char* GetLanguageOutputExtension(cmSourceFile const&) const;
|
||||
std::string GetLanguageOutputExtension(cmSourceFile const&) const;
|
||||
|
||||
///! What is the configurations directory variable called?
|
||||
virtual const char* GetCMakeCFGIntDir() const { return "."; }
|
||||
|
@ -332,9 +332,9 @@ protected:
|
|||
bool IsRootOnlyTarget(cmTarget* target) const;
|
||||
void AddTargetDepends(cmTarget const* target,
|
||||
TargetDependSet& projectTargets);
|
||||
void SetLanguageEnabledFlag(const char* l, cmMakefile* mf);
|
||||
void SetLanguageEnabledMaps(const char* l, cmMakefile* mf);
|
||||
void FillExtensionToLanguageMap(const char* l, cmMakefile* mf);
|
||||
void SetLanguageEnabledFlag(const std::string& l, cmMakefile* mf);
|
||||
void SetLanguageEnabledMaps(const std::string& l, cmMakefile* mf);
|
||||
void FillExtensionToLanguageMap(const std::string& l, cmMakefile* mf);
|
||||
|
||||
virtual bool ComputeTargetDepends();
|
||||
|
||||
|
@ -420,9 +420,10 @@ private:
|
|||
void WriteSummary(cmTarget* target);
|
||||
void FinalizeTargetCompileInfo();
|
||||
|
||||
virtual void PrintCompilerAdvice(std::ostream& os, std::string lang,
|
||||
virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang,
|
||||
const char* envVar) const;
|
||||
void CheckCompilerIdCompatibility(cmMakefile* mf, std::string lang) const;
|
||||
void CheckCompilerIdCompatibility(cmMakefile* mf,
|
||||
std::string const& lang) const;
|
||||
|
||||
cmExternalMakefileProjectGenerator* ExtraGenerator;
|
||||
|
||||
|
|
|
@ -114,7 +114,8 @@ protected:
|
|||
|
||||
private:
|
||||
virtual std::string GetVSMakeProgram() = 0;
|
||||
void PrintCompilerAdvice(std::ostream&, std::string, const char*) const {}
|
||||
void PrintCompilerAdvice(std::ostream&, std::string const&,
|
||||
const char*) const {}
|
||||
void ComputeTargetObjects(cmGeneratorTarget* gt) const;
|
||||
|
||||
void FollowLinkDepends(cmTarget const* target,
|
||||
|
|
|
@ -696,12 +696,8 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
|
|||
flags += flagsBuild.GetString();
|
||||
}
|
||||
|
||||
const char* lang =
|
||||
std::string lang =
|
||||
this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
|
||||
if (!lang)
|
||||
{
|
||||
lang = "";
|
||||
}
|
||||
|
||||
cmXCodeObject* buildFile =
|
||||
this->CreateXCodeSourceFileFromPath(sf->GetFullPath(), cmtarget, lang);
|
||||
|
@ -906,12 +902,8 @@ cmXCodeObject*
|
|||
cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf,
|
||||
cmTarget& cmtarget)
|
||||
{
|
||||
const char* lang =
|
||||
std::string lang =
|
||||
this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
|
||||
if (!lang)
|
||||
{
|
||||
lang = "";
|
||||
}
|
||||
|
||||
return this->CreateXCodeFileReferenceFromPath(
|
||||
sf->GetFullPath(), cmtarget, lang);
|
||||
|
@ -1036,7 +1028,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
|
|||
// Include this file in the build if it has a known language
|
||||
// and has not been listed as an ignored extension for this
|
||||
// generator.
|
||||
if(this->CurrentLocalGenerator->GetSourceFileLanguage(**i) &&
|
||||
if(!this->CurrentLocalGenerator->GetSourceFileLanguage(**i).empty() &&
|
||||
!this->IgnoreFile((*i)->GetExtension().c_str()))
|
||||
{
|
||||
sourceFiles.push_back(xsf);
|
||||
|
@ -1241,8 +1233,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget)
|
|||
return;
|
||||
}
|
||||
|
||||
const char* llang = cmtarget.GetLinkerLanguage("NOCONFIG");
|
||||
if(!llang) { return; }
|
||||
std::string llang = cmtarget.GetLinkerLanguage("NOCONFIG");
|
||||
if(llang.empty()) { return; }
|
||||
|
||||
// If the language is compiled as a source trust Xcode to link with it.
|
||||
cmTarget::LinkImplementation const* impl =
|
||||
|
@ -1270,7 +1262,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget)
|
|||
}
|
||||
if(cmSourceFile* sf = mf->GetOrCreateSource(fname.c_str()))
|
||||
{
|
||||
sf->SetProperty("LANGUAGE", llang);
|
||||
sf->SetProperty("LANGUAGE", llang.c_str());
|
||||
cmtarget.AddSourceFile(sf);
|
||||
}
|
||||
}
|
||||
|
@ -1714,12 +1706,12 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
|
|||
(target.GetType() == cmTarget::EXECUTABLE) ||
|
||||
shared);
|
||||
|
||||
const char* lang = target.GetLinkerLanguage(configName);
|
||||
std::string lang = target.GetLinkerLanguage(configName);
|
||||
std::string cflags;
|
||||
if(lang)
|
||||
if(!lang.empty())
|
||||
{
|
||||
// for c++ projects get the c flags as well
|
||||
if(strcmp(lang, "CXX") == 0)
|
||||
if(lang == "CXX")
|
||||
{
|
||||
this->CurrentLocalGenerator->AddLanguageFlags(cflags, "C", configName);
|
||||
this->CurrentLocalGenerator->AddCMP0018Flags(cflags, &target,
|
||||
|
@ -2178,7 +2170,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
|
|||
const char* debugStr = "YES";
|
||||
// We can't set the Xcode flag differently depending on the language,
|
||||
// so put them back in this case.
|
||||
if( (lang && strcmp(lang, "CXX") == 0) && gflag != gflagc )
|
||||
if( (lang == "CXX") && gflag != gflagc )
|
||||
{
|
||||
cflags += " ";
|
||||
cflags += gflagc;
|
||||
|
@ -2201,7 +2193,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
|
|||
this->CreateString("NO"));
|
||||
buildSettings->AddAttribute("GCC_INLINES_ARE_PRIVATE_EXTERN",
|
||||
this->CreateString("NO"));
|
||||
if(lang && strcmp(lang, "CXX") == 0)
|
||||
if(lang == "CXX")
|
||||
{
|
||||
flags += " ";
|
||||
flags += defFlags;
|
||||
|
@ -3800,12 +3792,13 @@ cmGlobalXCodeGenerator
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::string cmGlobalXCodeGenerator::LookupFlags(const char* varNamePrefix,
|
||||
const char* varNameLang,
|
||||
const char* varNameSuffix,
|
||||
const char* default_flags)
|
||||
std::string cmGlobalXCodeGenerator::LookupFlags(
|
||||
const std::string& varNamePrefix,
|
||||
const std::string& varNameLang,
|
||||
const std::string& varNameSuffix,
|
||||
const std::string& default_flags)
|
||||
{
|
||||
if(varNameLang)
|
||||
if(!varNameLang.empty())
|
||||
{
|
||||
std::string varName = varNamePrefix;
|
||||
varName += varNameLang;
|
||||
|
|
|
@ -190,10 +190,10 @@ private:
|
|||
void CreateReRunCMakeFile(cmLocalGenerator* root,
|
||||
std::vector<cmLocalGenerator*> const& gens);
|
||||
|
||||
std::string LookupFlags(const char* varNamePrefix,
|
||||
const char* varNameLang,
|
||||
const char* varNameSuffix,
|
||||
const char* default_flags);
|
||||
std::string LookupFlags(const std::string& varNamePrefix,
|
||||
const std::string& varNameLang,
|
||||
const std::string& varNameSuffix,
|
||||
const std::string& default_flags);
|
||||
|
||||
class Factory;
|
||||
class BuildObjectListOrString;
|
||||
|
@ -215,7 +215,8 @@ protected:
|
|||
std::vector<cmXCodeObject*> XCodeObjects;
|
||||
cmXCodeObject* RootObject;
|
||||
private:
|
||||
void PrintCompilerAdvice(std::ostream&, std::string, const char*) const {}
|
||||
void PrintCompilerAdvice(std::ostream&, std::string const&,
|
||||
const char*) const {}
|
||||
void ComputeTargetObjects(cmGeneratorTarget* gt) const;
|
||||
|
||||
std::string GetObjectsNormalDirectory(
|
||||
|
|
|
@ -572,7 +572,7 @@ void cmLocalGenerator::GenerateTargetManifest()
|
|||
}
|
||||
|
||||
void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
|
||||
const char* lang,
|
||||
const std::string& lang,
|
||||
cmSourceFile& source,
|
||||
cmGeneratorTarget& target)
|
||||
{
|
||||
|
@ -604,7 +604,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
|
|||
std::vector<std::string> commands;
|
||||
cmSystemTools::ExpandList(rules, commands);
|
||||
cmLocalGenerator::RuleVariables vars;
|
||||
vars.Language = lang;
|
||||
vars.Language = lang.c_str();
|
||||
vars.Source = sourceFile.c_str();
|
||||
vars.Object = objectFile.c_str();
|
||||
vars.ObjectDir = objectDir.c_str();
|
||||
|
@ -653,7 +653,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
|
|||
);
|
||||
}
|
||||
|
||||
void cmLocalGenerator::AddBuildTargetRule(const char* llang,
|
||||
void cmLocalGenerator::AddBuildTargetRule(const std::string& llang,
|
||||
cmGeneratorTarget& target)
|
||||
{
|
||||
cmStdString objs;
|
||||
|
@ -703,7 +703,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang,
|
|||
&target);
|
||||
linkLibs = frameworkPath + linkPath + linkLibs;
|
||||
cmLocalGenerator::RuleVariables vars;
|
||||
vars.Language = llang;
|
||||
vars.Language = llang.c_str();
|
||||
vars.Objects = objs.c_str();
|
||||
vars.ObjectDir = ".";
|
||||
vars.Target = targetName.c_str();
|
||||
|
@ -776,8 +776,8 @@ void cmLocalGenerator
|
|||
case cmTarget::MODULE_LIBRARY:
|
||||
case cmTarget::EXECUTABLE:
|
||||
{
|
||||
const char* llang = target.Target->GetLinkerLanguage();
|
||||
if(!llang)
|
||||
std::string llang = target.Target->GetLinkerLanguage();
|
||||
if(llang.empty())
|
||||
{
|
||||
cmSystemTools::Error
|
||||
("CMake can not determine linker language for target: ",
|
||||
|
@ -1290,10 +1290,11 @@ cmLocalGenerator::ConvertToIncludeReference(std::string const& path,
|
|||
std::string cmLocalGenerator::GetIncludeFlags(
|
||||
const std::vector<std::string> &includes,
|
||||
cmGeneratorTarget* target,
|
||||
const char* lang, bool forResponseFile,
|
||||
const std::string& lang,
|
||||
bool forResponseFile,
|
||||
const char *config)
|
||||
{
|
||||
if(!lang)
|
||||
if(lang.empty())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
@ -1415,7 +1416,7 @@ void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines,
|
|||
//----------------------------------------------------------------------------
|
||||
void cmLocalGenerator::AddCompileOptions(
|
||||
std::string& flags, cmTarget* target,
|
||||
const char* lang, const char* config
|
||||
const std::string& lang, const char* config
|
||||
)
|
||||
{
|
||||
std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX";
|
||||
|
@ -1463,7 +1464,7 @@ void cmLocalGenerator::AddCompileOptions(
|
|||
//----------------------------------------------------------------------------
|
||||
void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
|
||||
cmGeneratorTarget* target,
|
||||
const char* lang,
|
||||
const std::string& lang,
|
||||
const char *config,
|
||||
bool stripImplicitInclDirs
|
||||
)
|
||||
|
@ -1689,8 +1690,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
|
|||
linkFlags += this->Makefile->GetSafeDefinition(build.c_str());
|
||||
linkFlags += " ";
|
||||
}
|
||||
const char* linkLanguage = target->Target->GetLinkerLanguage();
|
||||
if(!linkLanguage)
|
||||
std::string linkLanguage = target->Target->GetLinkerLanguage();
|
||||
if(linkLanguage.empty())
|
||||
{
|
||||
cmSystemTools::Error
|
||||
("CMake can not determine linker language for target: ",
|
||||
|
@ -1813,7 +1814,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
|
|||
// Collect library linking flags command line options.
|
||||
std::string linkLibs;
|
||||
|
||||
const char* linkLanguage = cli.GetLinkLanguage();
|
||||
std::string linkLanguage = cli.GetLinkLanguage();
|
||||
|
||||
std::string libPathFlag =
|
||||
this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG");
|
||||
|
@ -1943,7 +1944,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
|
|||
//----------------------------------------------------------------------------
|
||||
void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
|
||||
cmGeneratorTarget* target,
|
||||
const char *lang,
|
||||
const std::string& lang,
|
||||
const char* config)
|
||||
{
|
||||
// Only add Mac OS X specific flags on Darwin platforms (OSX and iphone):
|
||||
|
@ -1969,7 +1970,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
|
|||
std::string("CMAKE_") + lang + "_OSX_DEPLOYMENT_TARGET_FLAG";
|
||||
const char* deploymentTargetFlag =
|
||||
this->Makefile->GetDefinition(deploymentTargetFlagVar.c_str());
|
||||
if(!archs.empty() && lang && (lang[0] =='C' || lang[0] == 'F'))
|
||||
if(!archs.empty() && !lang.empty() && (lang[0] =='C' || lang[0] == 'F'))
|
||||
{
|
||||
for(std::vector<std::string>::iterator i = archs.begin();
|
||||
i != archs.end(); ++i)
|
||||
|
@ -2000,7 +2001,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmLocalGenerator::AddLanguageFlags(std::string& flags,
|
||||
const char* lang,
|
||||
const std::string& lang,
|
||||
const char* config)
|
||||
{
|
||||
// Add language-specific flags.
|
||||
|
@ -2112,7 +2113,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName,
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmLocalGenerator::AddSharedFlags(std::string& flags,
|
||||
const char* lang,
|
||||
const std::string& lang,
|
||||
bool shared)
|
||||
{
|
||||
std::string flagsVar;
|
||||
|
@ -2128,7 +2129,8 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags,
|
|||
}
|
||||
|
||||
static void AddVisibilityCompileOption(std::string &flags, cmTarget* target,
|
||||
cmLocalGenerator *lg, const char *lang)
|
||||
cmLocalGenerator *lg,
|
||||
const std::string& lang)
|
||||
{
|
||||
std::string l(lang);
|
||||
std::string compileOption = "CMAKE_" + l + "_COMPILE_OPTIONS_VISIBILITY";
|
||||
|
@ -2182,7 +2184,7 @@ static void AddInlineVisibilityCompileOption(std::string &flags,
|
|||
//----------------------------------------------------------------------------
|
||||
void cmLocalGenerator
|
||||
::AddVisibilityPresetFlags(std::string &flags, cmTarget* target,
|
||||
const char *lang)
|
||||
const std::string& lang)
|
||||
{
|
||||
int targetType = target->GetType();
|
||||
bool suitableTarget = ((targetType == cmTarget::SHARED_LIBRARY)
|
||||
|
@ -2194,13 +2196,13 @@ void cmLocalGenerator
|
|||
return;
|
||||
}
|
||||
|
||||
if (!lang)
|
||||
if (lang.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
AddVisibilityCompileOption(flags, target, this, lang);
|
||||
|
||||
if(strcmp(lang, "CXX") == 0)
|
||||
if(lang == "CXX")
|
||||
{
|
||||
AddInlineVisibilityCompileOption(flags, target, this);
|
||||
}
|
||||
|
@ -2396,11 +2398,11 @@ void cmLocalGenerator::AppendDefines(std::set<std::string>& defines,
|
|||
//----------------------------------------------------------------------------
|
||||
void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
|
||||
std::string &definesString,
|
||||
const char* lang)
|
||||
const std::string& lang)
|
||||
{
|
||||
// Lookup the define flag for the current language.
|
||||
std::string dflag = "-D";
|
||||
if(lang)
|
||||
if(!lang.empty())
|
||||
{
|
||||
std::string defineFlagVar = "CMAKE_";
|
||||
defineFlagVar += lang;
|
||||
|
@ -2460,7 +2462,7 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmLocalGenerator::AppendFeatureOptions(
|
||||
std::string& flags, const char* lang, const char* feature)
|
||||
std::string& flags, const std::string& lang, const char* feature)
|
||||
{
|
||||
std::string optVar = "CMAKE_";
|
||||
optVar += lang;
|
||||
|
@ -3140,7 +3142,8 @@ cmLocalGenerator
|
|||
bool replaceExt = this->NeedBackwardsCompatibility_2_4();
|
||||
if(!replaceExt)
|
||||
{
|
||||
if(const char* lang = source.GetLanguage())
|
||||
std::string lang = source.GetLanguage();
|
||||
if(!lang.empty())
|
||||
{
|
||||
std::string repVar = "CMAKE_";
|
||||
repVar += lang;
|
||||
|
@ -3174,7 +3177,7 @@ cmLocalGenerator
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const char*
|
||||
std::string
|
||||
cmLocalGenerator
|
||||
::GetSourceFileLanguage(const cmSourceFile& source)
|
||||
{
|
||||
|
|
|
@ -137,14 +137,14 @@ public:
|
|||
|
||||
|
||||
void AddArchitectureFlags(std::string& flags, cmGeneratorTarget* target,
|
||||
const char *lang, const char* config);
|
||||
const std::string&lang, const char* config);
|
||||
|
||||
void AddLanguageFlags(std::string& flags, const char* lang,
|
||||
void AddLanguageFlags(std::string& flags, const std::string& lang,
|
||||
const char* config);
|
||||
void AddCMP0018Flags(std::string &flags, cmTarget* target,
|
||||
std::string const& lang, const char *config);
|
||||
void AddVisibilityPresetFlags(std::string &flags, cmTarget* target,
|
||||
const char *lang);
|
||||
const std::string& lang);
|
||||
void AddConfigVariableFlags(std::string& flags, const std::string& var,
|
||||
const char* config);
|
||||
///! Append flags to a string.
|
||||
|
@ -153,7 +153,8 @@ public:
|
|||
///! Get the include flags for the current makefile and language
|
||||
std::string GetIncludeFlags(const std::vector<std::string> &includes,
|
||||
cmGeneratorTarget* target,
|
||||
const char* lang, bool forResponseFile = false,
|
||||
const std::string& lang,
|
||||
bool forResponseFile = false,
|
||||
const char *config = 0);
|
||||
|
||||
/**
|
||||
|
@ -175,10 +176,10 @@ public:
|
|||
*/
|
||||
void JoinDefines(const std::set<std::string>& defines,
|
||||
std::string &definesString,
|
||||
const char* lang);
|
||||
const std::string& lang);
|
||||
|
||||
/** Lookup and append options associated with a particular feature. */
|
||||
void AppendFeatureOptions(std::string& flags, const char* lang,
|
||||
void AppendFeatureOptions(std::string& flags, const std::string& lang,
|
||||
const char* feature);
|
||||
|
||||
/** \brief Get absolute path to dependency \a name
|
||||
|
@ -223,16 +224,17 @@ public:
|
|||
/** Get the include flags for the current makefile and language. */
|
||||
void GetIncludeDirectories(std::vector<std::string>& dirs,
|
||||
cmGeneratorTarget* target,
|
||||
const char* lang = "C", const char *config = 0,
|
||||
const std::string& lang = "C",
|
||||
const char *config = 0,
|
||||
bool stripImplicitInclDirs = true);
|
||||
void AddCompileOptions(std::string& flags, cmTarget* target,
|
||||
const char* lang, const char* config);
|
||||
const std::string& lang, const char* config);
|
||||
void AddCompileDefinitions(std::set<std::string>& defines,
|
||||
cmTarget const* target,
|
||||
const char* config);
|
||||
|
||||
/** Compute the language used to compile the given source file. */
|
||||
const char* GetSourceFileLanguage(const cmSourceFile& source);
|
||||
std::string GetSourceFileLanguage(const cmSourceFile& source);
|
||||
|
||||
// Fill the vector with the target names for the object files,
|
||||
// preprocessed files and assembly files.
|
||||
|
@ -389,10 +391,11 @@ protected:
|
|||
|
||||
/** Convert a target to a utility target for unsupported
|
||||
* languages of a generator */
|
||||
void AddBuildTargetRule(const char* llang, cmGeneratorTarget& target);
|
||||
void AddBuildTargetRule(const std::string& llang,
|
||||
cmGeneratorTarget& target);
|
||||
///! add a custom command to build a .o file that is part of a target
|
||||
void AddCustomCommandToCreateObject(const char* ofname,
|
||||
const char* lang,
|
||||
const std::string& lang,
|
||||
cmSourceFile& source,
|
||||
cmGeneratorTarget& target);
|
||||
// Create Custom Targets and commands for unsupported languages
|
||||
|
@ -473,7 +476,8 @@ private:
|
|||
std::string const& result,
|
||||
OutputFormat format);
|
||||
|
||||
void AddSharedFlags(std::string& flags, const char* lang, bool shared);
|
||||
void AddSharedFlags(std::string& flags, const std::string& lang,
|
||||
bool shared);
|
||||
bool GetShouldUseOldFlags(bool shared, const std::string &lang) const;
|
||||
void AddPositionIndependentFlags(std::string& flags, std::string const& l,
|
||||
int targetType);
|
||||
|
|
|
@ -2198,7 +2198,7 @@ cmLocalUnixMakefileGenerator3::GetImplicitDepends(cmTarget const& tgt)
|
|||
//----------------------------------------------------------------------------
|
||||
void
|
||||
cmLocalUnixMakefileGenerator3::AddImplicitDepends(cmTarget const& tgt,
|
||||
const char* lang,
|
||||
const std::string& lang,
|
||||
const char* obj,
|
||||
const char* src)
|
||||
{
|
||||
|
|
|
@ -217,7 +217,7 @@ public:
|
|||
public std::map<cmStdString, ImplicitDependLanguageMap> {};
|
||||
ImplicitDependLanguageMap const& GetImplicitDepends(cmTarget const& tgt);
|
||||
|
||||
void AddImplicitDepends(cmTarget const& tgt, const char* lang,
|
||||
void AddImplicitDepends(cmTarget const& tgt, const std::string& lang,
|
||||
const char* obj, const char* src);
|
||||
|
||||
void AppendGlobalTargetDepends(std::vector<std::string>& depends,
|
||||
|
@ -358,7 +358,7 @@ private:
|
|||
cmTarget* Target;
|
||||
std::string Language;
|
||||
LocalObjectEntry(): Target(0), Language() {}
|
||||
LocalObjectEntry(cmTarget* t, const char* lang):
|
||||
LocalObjectEntry(cmTarget* t, const std::string& lang):
|
||||
Target(t), Language(lang) {}
|
||||
};
|
||||
struct LocalObjectInfo: public std::vector<LocalObjectEntry>
|
||||
|
|
|
@ -413,19 +413,16 @@ void cmLocalVisualStudio6Generator
|
|||
compileFlags += cflags;
|
||||
}
|
||||
|
||||
const char* lang = this->GetSourceFileLanguage(*(*sf));
|
||||
if(lang)
|
||||
const std::string& lang = this->GetSourceFileLanguage(*(*sf));
|
||||
if(lang == "CXX")
|
||||
{
|
||||
if(strcmp(lang, "CXX") == 0)
|
||||
{
|
||||
// force a C++ file type
|
||||
compileFlags += " /TP ";
|
||||
}
|
||||
else if(strcmp(lang, "C") == 0)
|
||||
{
|
||||
// force to c file type
|
||||
compileFlags += " /TC ";
|
||||
}
|
||||
// force a C++ file type
|
||||
compileFlags += " /TP ";
|
||||
}
|
||||
else if(lang == "C")
|
||||
{
|
||||
// force to c file type
|
||||
compileFlags += " /TC ";
|
||||
}
|
||||
|
||||
// Add per-source and per-configuration preprocessor definitions.
|
||||
|
@ -469,7 +466,7 @@ void cmLocalVisualStudio6Generator
|
|||
}
|
||||
|
||||
bool excludedFromBuild =
|
||||
(lang && (*sf)->GetPropertyAsBool("HEADER_FILE_ONLY"));
|
||||
(!lang.empty() && (*sf)->GetPropertyAsBool("HEADER_FILE_ONLY"));
|
||||
|
||||
// Check for extra object-file dependencies.
|
||||
const char* dependsValue = (*sf)->GetProperty("OBJECT_DEPENDS");
|
||||
|
@ -1255,8 +1252,8 @@ void cmLocalVisualStudio6Generator
|
|||
if(targetBuilds)
|
||||
{
|
||||
// Get the language to use for linking.
|
||||
const char* linkLanguage = target.GetLinkerLanguage();
|
||||
if(!linkLanguage)
|
||||
const std::string& linkLanguage = target.GetLinkerLanguage();
|
||||
if(linkLanguage.empty())
|
||||
{
|
||||
cmSystemTools::Error
|
||||
("CMake can not determine linker language for target: ",
|
||||
|
@ -1677,8 +1674,8 @@ void cmLocalVisualStudio6Generator
|
|||
if(target.GetType() >= cmTarget::EXECUTABLE &&
|
||||
target.GetType() <= cmTarget::OBJECT_LIBRARY)
|
||||
{
|
||||
const char* linkLanguage = target.GetLinkerLanguage();
|
||||
if(!linkLanguage)
|
||||
const std::string& linkLanguage = target.GetLinkerLanguage();
|
||||
if(linkLanguage.empty())
|
||||
{
|
||||
cmSystemTools::Error
|
||||
("CMake can not determine linker language for target: ",
|
||||
|
@ -1745,11 +1742,11 @@ void cmLocalVisualStudio6Generator
|
|||
std::string minsizeDefines = " ";
|
||||
std::string debugrelDefines = " ";
|
||||
|
||||
this->JoinDefines(definesSet, defines, 0);
|
||||
this->JoinDefines(debugDefinesSet, debugDefines, 0);
|
||||
this->JoinDefines(releaseDefinesSet, releaseDefines, 0);
|
||||
this->JoinDefines(minsizeDefinesSet, minsizeDefines, 0);
|
||||
this->JoinDefines(debugrelDefinesSet, debugrelDefines, 0);
|
||||
this->JoinDefines(definesSet, defines, "");
|
||||
this->JoinDefines(debugDefinesSet, debugDefines, "");
|
||||
this->JoinDefines(releaseDefinesSet, releaseDefines, "");
|
||||
this->JoinDefines(minsizeDefinesSet, minsizeDefines, "");
|
||||
this->JoinDefines(debugrelDefinesSet, debugrelDefines, "");
|
||||
|
||||
flags += defines;
|
||||
flagsDebug += debugDefines;
|
||||
|
|
|
@ -687,17 +687,18 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
|
|||
std::string flags;
|
||||
if(strcmp(configType, "10") != 0)
|
||||
{
|
||||
const char* linkLanguage = (this->FortranProject? "Fortran":
|
||||
const std::string& linkLanguage = (this->FortranProject?
|
||||
std::string("Fortran"):
|
||||
target.GetLinkerLanguage(configName));
|
||||
if(!linkLanguage)
|
||||
if(linkLanguage.empty())
|
||||
{
|
||||
cmSystemTools::Error
|
||||
("CMake can not determine linker language for target: ",
|
||||
target.GetName());
|
||||
return;
|
||||
}
|
||||
if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0
|
||||
|| strcmp(linkLanguage, "Fortran") == 0)
|
||||
if(linkLanguage == "C" || linkLanguage == "CXX"
|
||||
|| linkLanguage == "Fortran")
|
||||
{
|
||||
std::string baseFlagVar = "CMAKE_";
|
||||
baseFlagVar += linkLanguage;
|
||||
|
@ -709,11 +710,11 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
|
|||
flags += this->Makefile->GetRequiredDefinition(flagVar.c_str());
|
||||
}
|
||||
// set the correct language
|
||||
if(strcmp(linkLanguage, "C") == 0)
|
||||
if(linkLanguage == "C")
|
||||
{
|
||||
flags += " /TC ";
|
||||
}
|
||||
if(strcmp(linkLanguage, "CXX") == 0)
|
||||
if(linkLanguage == "CXX")
|
||||
{
|
||||
flags += " /TP ";
|
||||
}
|
||||
|
@ -1081,7 +1082,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
|||
return;
|
||||
}
|
||||
cmComputeLinkInformation& cli = *pcli;
|
||||
const char* linkLanguage = cli.GetLinkLanguage();
|
||||
std::string linkLanguage = cli.GetLinkLanguage();
|
||||
|
||||
// Compute the variable name to lookup standard libraries for this
|
||||
// language.
|
||||
|
@ -1177,7 +1178,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
|||
return;
|
||||
}
|
||||
cmComputeLinkInformation& cli = *pcli;
|
||||
const char* linkLanguage = cli.GetLinkLanguage();
|
||||
std::string linkLanguage = cli.GetLinkLanguage();
|
||||
|
||||
bool isWin32Executable = target.GetPropertyAsBool("WIN32_EXECUTABLE");
|
||||
|
||||
|
@ -1546,14 +1547,14 @@ cmLocalVisualStudio7GeneratorFCInfo
|
|||
}
|
||||
}
|
||||
|
||||
const char* lang =
|
||||
std::string lang =
|
||||
lg->GlobalGenerator->GetLanguageFromExtension
|
||||
(sf.GetExtension().c_str());
|
||||
const char* sourceLang = lg->GetSourceFileLanguage(sf);
|
||||
const char* linkLanguage = target.GetLinkerLanguage(i->c_str());
|
||||
const std::string& sourceLang = lg->GetSourceFileLanguage(sf);
|
||||
const std::string& linkLanguage = target.GetLinkerLanguage(i->c_str());
|
||||
bool needForceLang = false;
|
||||
// source file does not match its extension language
|
||||
if(lang && sourceLang && strcmp(lang, sourceLang) != 0)
|
||||
if(lang != sourceLang)
|
||||
{
|
||||
needForceLang = true;
|
||||
lang = sourceLang;
|
||||
|
@ -1569,16 +1570,15 @@ cmLocalVisualStudio7GeneratorFCInfo
|
|||
|
||||
// if the source file does not match the linker language
|
||||
// then force c or c++
|
||||
if(needForceLang || (linkLanguage && lang
|
||||
&& strcmp(lang, linkLanguage) != 0))
|
||||
if(needForceLang || (linkLanguage != lang))
|
||||
{
|
||||
if(strcmp(lang, "CXX") == 0)
|
||||
if(lang == "CXX")
|
||||
{
|
||||
// force a C++ file type
|
||||
fc.CompileFlags += " /TP ";
|
||||
needfc = true;
|
||||
}
|
||||
else if(strcmp(lang, "C") == 0)
|
||||
else if(lang == "C")
|
||||
{
|
||||
// force to c
|
||||
fc.CompileFlags += " /TC ";
|
||||
|
|
|
@ -2361,10 +2361,10 @@ bool cmMakefile::PlatformIs64Bit() const
|
|||
return false;
|
||||
}
|
||||
|
||||
const char* cmMakefile::GetSONameFlag(const char* language) const
|
||||
const char* cmMakefile::GetSONameFlag(const std::string& language) const
|
||||
{
|
||||
std::string name = "CMAKE_SHARED_LIBRARY_SONAME";
|
||||
if(language)
|
||||
if(!language.empty())
|
||||
{
|
||||
name += "_";
|
||||
name += language;
|
||||
|
|
|
@ -608,7 +608,7 @@ public:
|
|||
bool PlatformIs64Bit() const;
|
||||
|
||||
/** Retrieve soname flag for the specified language if supported */
|
||||
const char* GetSONameFlag(const char* language) const;
|
||||
const char* GetSONameFlag(const std::string& language) const;
|
||||
|
||||
/**
|
||||
* Get a list of preprocessor define flags.
|
||||
|
|
|
@ -160,11 +160,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
|
|||
cmLocalGenerator::SHELL);
|
||||
|
||||
// Get the language to use for linking this executable.
|
||||
const char* linkLanguage =
|
||||
std::string linkLanguage =
|
||||
this->Target->GetLinkerLanguage(this->ConfigName);
|
||||
|
||||
// Make sure we have a link language.
|
||||
if(!linkLanguage)
|
||||
if(linkLanguage.empty())
|
||||
{
|
||||
cmSystemTools::Error("Cannot determine link language for target \"",
|
||||
this->Target->GetName(), "\".");
|
||||
|
@ -348,7 +348,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
|
|||
cmLocalGenerator::RuleVariables vars;
|
||||
vars.RuleLauncher = "RULE_LAUNCH_LINK";
|
||||
vars.CMTarget = this->Target;
|
||||
vars.Language = linkLanguage;
|
||||
vars.Language = linkLanguage.c_str();
|
||||
vars.Objects = buildObjs.c_str();
|
||||
std::string objectDir = this->Target->GetSupportDirectory();
|
||||
objectDir = this->Convert(objectDir.c_str(),
|
||||
|
|
|
@ -131,13 +131,10 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules()
|
|||
//----------------------------------------------------------------------------
|
||||
void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
|
||||
{
|
||||
const char* linkLanguage =
|
||||
std::string linkLanguage =
|
||||
this->Target->GetLinkerLanguage(this->ConfigName);
|
||||
std::string linkRuleVar = "CMAKE_";
|
||||
if (linkLanguage)
|
||||
{
|
||||
linkRuleVar += linkLanguage;
|
||||
}
|
||||
linkRuleVar += linkLanguage;
|
||||
linkRuleVar += "_CREATE_STATIC_LIBRARY";
|
||||
|
||||
if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION") &&
|
||||
|
@ -160,13 +157,10 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
|
|||
this->WriteFrameworkRules(relink);
|
||||
return;
|
||||
}
|
||||
const char* linkLanguage =
|
||||
std::string linkLanguage =
|
||||
this->Target->GetLinkerLanguage(this->ConfigName);
|
||||
std::string linkRuleVar = "CMAKE_";
|
||||
if (linkLanguage)
|
||||
{
|
||||
linkRuleVar += linkLanguage;
|
||||
}
|
||||
linkRuleVar += linkLanguage;
|
||||
linkRuleVar += "_CREATE_SHARED_LIBRARY";
|
||||
|
||||
std::string extraFlags;
|
||||
|
@ -187,13 +181,10 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
|
|||
//----------------------------------------------------------------------------
|
||||
void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
|
||||
{
|
||||
const char* linkLanguage =
|
||||
std::string linkLanguage =
|
||||
this->Target->GetLinkerLanguage(this->ConfigName);
|
||||
std::string linkRuleVar = "CMAKE_";
|
||||
if (linkLanguage)
|
||||
{
|
||||
linkRuleVar += linkLanguage;
|
||||
}
|
||||
linkRuleVar += linkLanguage;
|
||||
linkRuleVar += "_CREATE_SHARED_MODULE";
|
||||
|
||||
std::string extraFlags;
|
||||
|
@ -213,13 +204,10 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
|
|||
//----------------------------------------------------------------------------
|
||||
void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
|
||||
{
|
||||
const char* linkLanguage =
|
||||
std::string linkLanguage =
|
||||
this->Target->GetLinkerLanguage(this->ConfigName);
|
||||
std::string linkRuleVar = "CMAKE_";
|
||||
if (linkLanguage)
|
||||
{
|
||||
linkRuleVar += linkLanguage;
|
||||
}
|
||||
linkRuleVar += linkLanguage;
|
||||
linkRuleVar += "_CREATE_MACOSX_FRAMEWORK";
|
||||
|
||||
std::string extraFlags;
|
||||
|
@ -248,11 +236,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
|
|||
this->AppendLinkDepends(depends);
|
||||
|
||||
// Get the language to use for linking this library.
|
||||
const char* linkLanguage =
|
||||
std::string linkLanguage =
|
||||
this->Target->GetLinkerLanguage(this->ConfigName);
|
||||
|
||||
// Make sure we have a link language.
|
||||
if(!linkLanguage)
|
||||
if(linkLanguage.empty())
|
||||
{
|
||||
cmSystemTools::Error("Cannot determine link language for target \"",
|
||||
this->Target->GetName(), "\".");
|
||||
|
@ -589,7 +577,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
|
|||
|
||||
vars.RuleLauncher = "RULE_LAUNCH_LINK";
|
||||
vars.CMTarget = this->Target;
|
||||
vars.Language = linkLanguage;
|
||||
vars.Language = linkLanguage.c_str();
|
||||
vars.Objects = buildObjs.c_str();
|
||||
std::string objectDir = this->Target->GetSupportDirectory();
|
||||
objectDir = this->Convert(objectDir.c_str(),
|
||||
|
@ -786,7 +774,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
|
|||
//----------------------------------------------------------------------------
|
||||
void
|
||||
cmMakefileLibraryTargetGenerator
|
||||
::AppendOSXVerFlag(std::string& flags, const char* lang,
|
||||
::AppendOSXVerFlag(std::string& flags, const std::string& lang,
|
||||
const char* name, bool so)
|
||||
{
|
||||
// Lookup the flag to specify the version.
|
||||
|
|
|
@ -39,7 +39,7 @@ protected:
|
|||
// Store the computd framework version for OS X Frameworks.
|
||||
std::string FrameworkVersion;
|
||||
|
||||
void AppendOSXVerFlag(std::string& flags, const char* lang,
|
||||
void AppendOSXVerFlag(std::string& flags, const std::string& lang,
|
||||
const char* name, bool so);
|
||||
};
|
||||
|
||||
|
|
|
@ -422,8 +422,9 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()
|
|||
void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source)
|
||||
{
|
||||
// Identify the language of the source file.
|
||||
const char* lang = this->LocalGenerator->GetSourceFileLanguage(source);
|
||||
if(!lang)
|
||||
const std::string& lang =
|
||||
this->LocalGenerator->GetSourceFileLanguage(source);
|
||||
if(lang.empty())
|
||||
{
|
||||
// don't know anything about this file so skip it
|
||||
return;
|
||||
|
@ -523,7 +524,7 @@ cmMakefileTargetGenerator
|
|||
void
|
||||
cmMakefileTargetGenerator
|
||||
::WriteObjectBuildFile(std::string &obj,
|
||||
const char *lang,
|
||||
const std::string& lang,
|
||||
cmSourceFile& source,
|
||||
std::vector<std::string>& depends)
|
||||
{
|
||||
|
@ -552,7 +553,7 @@ cmMakefileTargetGenerator
|
|||
cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
|
||||
|
||||
// Add Fortran format flags.
|
||||
if(strcmp(lang, "Fortran") == 0)
|
||||
if(lang == "Fortran")
|
||||
{
|
||||
this->AppendFortranFormatFlags(flags, source);
|
||||
}
|
||||
|
@ -664,7 +665,7 @@ cmMakefileTargetGenerator
|
|||
cmLocalGenerator::RuleVariables vars;
|
||||
vars.RuleLauncher = "RULE_LAUNCH_COMPILE";
|
||||
vars.CMTarget = this->Target;
|
||||
vars.Language = lang;
|
||||
vars.Language = lang.c_str();
|
||||
vars.Target = targetOutPathReal.c_str();
|
||||
vars.TargetPDB = targetOutPathPDB.c_str();
|
||||
vars.TargetCompilePDB = targetOutPathCompilePDB.c_str();
|
||||
|
@ -689,8 +690,7 @@ cmMakefileTargetGenerator
|
|||
|
||||
vars.Defines = definesString.c_str();
|
||||
|
||||
bool lang_is_c_or_cxx = ((strcmp(lang, "C") == 0) ||
|
||||
(strcmp(lang, "CXX") == 0));
|
||||
bool lang_is_c_or_cxx = ((lang == "C") || (lang == "CXX"));
|
||||
|
||||
// Construct the compile rules.
|
||||
{
|
||||
|
@ -1709,8 +1709,8 @@ void cmMakefileTargetGenerator
|
|||
}
|
||||
|
||||
void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar,
|
||||
const char* linkLang,
|
||||
std::string& linkFlags)
|
||||
const std::string& linkLang,
|
||||
std::string& linkFlags)
|
||||
{
|
||||
// check for language flags that are not allowed at link time, and
|
||||
// remove them, -w on darwin for gcc -w -dynamiclib sends -w to libtool
|
||||
|
@ -1943,7 +1943,7 @@ cmMakefileTargetGenerator
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
|
||||
const char* lang)
|
||||
const std::string& lang)
|
||||
{
|
||||
std::string responseVar = "CMAKE_";
|
||||
responseVar += lang;
|
||||
|
@ -2113,7 +2113,7 @@ bool cmMakefileTargetGenerator::GetFeatureAsBool(const char* feature)
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmMakefileTargetGenerator::AddFeatureFlags(
|
||||
std::string& flags, const char* lang
|
||||
std::string& flags, const std::string& lang
|
||||
)
|
||||
{
|
||||
// Add language-specific flags.
|
||||
|
|
|
@ -93,7 +93,7 @@ protected:
|
|||
|
||||
// write the build rule for an object
|
||||
void WriteObjectBuildFile(std::string &obj,
|
||||
const char *lang,
|
||||
const std::string& lang,
|
||||
cmSourceFile& source,
|
||||
std::vector<std::string>& depends);
|
||||
|
||||
|
@ -173,10 +173,10 @@ protected:
|
|||
bool useResponseFile, std::string& buildObjs,
|
||||
std::vector<std::string>& makefile_depends);
|
||||
|
||||
void AddIncludeFlags(std::string& flags, const char* lang);
|
||||
void AddIncludeFlags(std::string& flags, const std::string& lang);
|
||||
|
||||
virtual void CloseFileStreams();
|
||||
void RemoveForbiddenFlags(const char* flagVar, const char* linkLang,
|
||||
void RemoveForbiddenFlags(const char* flagVar, const std::string& linkLang,
|
||||
std::string& linkFlags);
|
||||
cmTarget *Target;
|
||||
cmGeneratorTarget* GeneratorTarget;
|
||||
|
@ -260,7 +260,7 @@ protected:
|
|||
void AddModuleDefinitionFlag(std::string& flags);
|
||||
|
||||
// Add language feature flags.
|
||||
void AddFeatureFlags(std::string& flags, const char* lang);
|
||||
void AddFeatureFlags(std::string& flags, const std::string& lang);
|
||||
|
||||
// Feature query methods.
|
||||
const char* GetFeature(const char* feature);
|
||||
|
|
|
@ -35,7 +35,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target)
|
|||
, TargetNameReal()
|
||||
, TargetNameImport()
|
||||
, TargetNamePDB()
|
||||
, TargetLinkLanguage(0)
|
||||
, TargetLinkLanguage("")
|
||||
{
|
||||
this->TargetLinkLanguage = target->Target
|
||||
->GetLinkerLanguage(this->GetConfigName());
|
||||
|
@ -72,7 +72,7 @@ cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator()
|
|||
|
||||
void cmNinjaNormalTargetGenerator::Generate()
|
||||
{
|
||||
if (!this->TargetLinkLanguage) {
|
||||
if (this->TargetLinkLanguage.empty()) {
|
||||
cmSystemTools::Error("CMake can not determine linker language for "
|
||||
"target: ",
|
||||
this->GetTarget()->GetName());
|
||||
|
@ -140,7 +140,7 @@ std::string
|
|||
cmNinjaNormalTargetGenerator
|
||||
::LanguageLinkerRule() const
|
||||
{
|
||||
return std::string(this->TargetLinkLanguage)
|
||||
return this->TargetLinkLanguage
|
||||
+ "_"
|
||||
+ cmTarget::GetTargetTypeName(this->GetTarget()->GetType())
|
||||
+ "_LINKER";
|
||||
|
@ -163,7 +163,7 @@ cmNinjaNormalTargetGenerator
|
|||
cmLocalGenerator::RuleVariables vars;
|
||||
vars.RuleLauncher = "RULE_LAUNCH_LINK";
|
||||
vars.CMTarget = this->GetTarget();
|
||||
vars.Language = this->TargetLinkLanguage;
|
||||
vars.Language = this->TargetLinkLanguage.c_str();
|
||||
|
||||
std::string responseFlag;
|
||||
if (!useResponseFile) {
|
||||
|
|
|
@ -47,7 +47,7 @@ private:
|
|||
std::string TargetNameReal;
|
||||
std::string TargetNameImport;
|
||||
std::string TargetNamePDB;
|
||||
const char *TargetLinkLanguage;
|
||||
std::string TargetLinkLanguage;
|
||||
};
|
||||
|
||||
#endif // ! cmNinjaNormalTargetGenerator_h
|
||||
|
|
|
@ -110,7 +110,7 @@ bool cmNinjaTargetGenerator::GetFeatureAsBool(const char* feature)
|
|||
|
||||
// TODO: Picked up from cmMakefileTargetGenerator. Refactor it.
|
||||
void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags,
|
||||
const char* lang)
|
||||
const std::string& lang)
|
||||
{
|
||||
// Add language-specific flags.
|
||||
this->LocalGenerator->AddLanguageFlags(flags, lang, this->GetConfigName());
|
||||
|
|
|
@ -72,7 +72,7 @@ protected:
|
|||
|
||||
const char* GetFeature(const char* feature);
|
||||
bool GetFeatureAsBool(const char* feature);
|
||||
void AddFeatureFlags(std::string& flags, const char* lang);
|
||||
void AddFeatureFlags(std::string& flags, const std::string& lang);
|
||||
|
||||
/**
|
||||
* Compute the flags for compilation of object files for a given @a language.
|
||||
|
|
|
@ -39,7 +39,7 @@ std::string const& cmSourceFile::GetExtension() const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const char* cmSourceFile::GetLanguage()
|
||||
std::string cmSourceFile::GetLanguage()
|
||||
{
|
||||
// If the language was set explicitly by the user then use it.
|
||||
if(const char* lang = this->GetProperty("LANGUAGE"))
|
||||
|
@ -76,7 +76,7 @@ const char* cmSourceFile::GetLanguage()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const char* cmSourceFile::GetLanguage() const
|
||||
std::string cmSourceFile::GetLanguage() const
|
||||
{
|
||||
// If the language was set explicitly by the user then use it.
|
||||
if(const char* lang = this->GetProperty("LANGUAGE"))
|
||||
|
@ -87,11 +87,11 @@ const char* cmSourceFile::GetLanguage() const
|
|||
// If the language was determined from the source file extension use it.
|
||||
if(!this->Language.empty())
|
||||
{
|
||||
return this->Language.c_str();
|
||||
return this->Language;
|
||||
}
|
||||
|
||||
// The language is not known.
|
||||
return 0;
|
||||
return "";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -267,7 +267,8 @@ void cmSourceFile::CheckLanguage(std::string const& ext)
|
|||
// Try to identify the source file language from the extension.
|
||||
cmMakefile const* mf = this->Location.GetMakefile();
|
||||
cmGlobalGenerator* gg = mf->GetLocalGenerator()->GetGlobalGenerator();
|
||||
if(const char* l = gg->GetLanguageFromExtension(ext.c_str()))
|
||||
std::string l = gg->GetLanguageFromExtension(ext.c_str());
|
||||
if(!l.empty())
|
||||
{
|
||||
this->Language = l;
|
||||
}
|
||||
|
|
|
@ -79,8 +79,8 @@ public:
|
|||
/**
|
||||
* Get the language of the compiler to use for this source file.
|
||||
*/
|
||||
const char* GetLanguage();
|
||||
const char* GetLanguage() const;
|
||||
std::string GetLanguage();
|
||||
std::string GetLanguage() const;
|
||||
|
||||
/**
|
||||
* Return the vector that holds the list of dependencies
|
||||
|
|
|
@ -93,7 +93,7 @@ void cmSourceFileLocation::UpdateExtension(const std::string& name)
|
|||
cmMakefile const* mf = this->Makefile;
|
||||
const std::vector<std::string>& srcExts = mf->GetSourceExtensions();
|
||||
const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions();
|
||||
if(gg->GetLanguageFromExtension(ext.c_str()) ||
|
||||
if(!gg->GetLanguageFromExtension(ext.c_str()).empty() ||
|
||||
std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end() ||
|
||||
std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end())
|
||||
{
|
||||
|
|
|
@ -2884,13 +2884,11 @@ private:
|
|||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const char* cmTarget::GetLinkerLanguage(const char* config,
|
||||
std::string cmTarget::GetLinkerLanguage(const char* config,
|
||||
cmTarget const* head) const
|
||||
{
|
||||
cmTarget const* headTarget = head ? head : this;
|
||||
const char* lang = this->GetLinkClosure(config, headTarget)
|
||||
->LinkerLanguage.c_str();
|
||||
return *lang? lang : 0;
|
||||
return this->GetLinkClosure(config, headTarget)->LinkerLanguage;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -2924,7 +2922,7 @@ public:
|
|||
this->Makefile = this->Target->GetMakefile();
|
||||
this->GG = this->Makefile->GetLocalGenerator()->GetGlobalGenerator();
|
||||
}
|
||||
void Consider(const char* lang)
|
||||
void Consider(const std::string& lang)
|
||||
{
|
||||
int preference = this->GG->GetLinkerPreference(lang);
|
||||
if(preference > this->Preference)
|
||||
|
@ -3530,7 +3528,8 @@ void cmTarget::GetFullNameInternal(const char* config,
|
|||
const char* suffixVar = this->GetSuffixVariableInternal(implib);
|
||||
|
||||
// Check for language-specific default prefix and suffix.
|
||||
if(const char* ll = this->GetLinkerLanguage(config, this))
|
||||
std::string ll = this->GetLinkerLanguage(config, this);
|
||||
if(!ll.empty())
|
||||
{
|
||||
if(!targetSuffix && suffixVar && *suffixVar)
|
||||
{
|
||||
|
@ -3867,7 +3866,8 @@ bool cmTarget::NeedRelinkBeforeInstall(const char* config) const
|
|||
}
|
||||
|
||||
// Check for rpath support on this platform.
|
||||
if(const char* ll = this->GetLinkerLanguage(config, this))
|
||||
std::string ll = this->GetLinkerLanguage(config, this);
|
||||
if(!ll.empty())
|
||||
{
|
||||
std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
|
||||
flagVar += ll;
|
||||
|
@ -4825,7 +4825,8 @@ void cmTarget::GetLanguages(std::set<cmStdString>& languages) const
|
|||
for(std::vector<cmSourceFile*>::const_iterator
|
||||
i = this->SourceFiles.begin(); i != this->SourceFiles.end(); ++i)
|
||||
{
|
||||
if(const char* lang = (*i)->GetLanguage())
|
||||
const std::string& lang = (*i)->GetLanguage();
|
||||
if(!lang.empty())
|
||||
{
|
||||
languages.insert(lang);
|
||||
}
|
||||
|
@ -4876,7 +4877,8 @@ bool cmTarget::IsChrpathUsed(const char* config) const
|
|||
#if defined(CMAKE_USE_ELF_PARSER)
|
||||
// Enable if the rpath flag uses a separator and the target uses ELF
|
||||
// binaries.
|
||||
if(const char* ll = this->GetLinkerLanguage(config, this))
|
||||
std::string ll = this->GetLinkerLanguage(config, this);
|
||||
if(!ll.empty())
|
||||
{
|
||||
std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
|
||||
sepVar += ll;
|
||||
|
|
|
@ -347,7 +347,7 @@ public:
|
|||
GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const;
|
||||
|
||||
///! Return the preferred linker language for this target
|
||||
const char* GetLinkerLanguage(const char* config = 0,
|
||||
std::string GetLinkerLanguage(const char* config = 0,
|
||||
cmTarget const* head = 0) const;
|
||||
|
||||
/** Get the full name of the target according to the settings in its
|
||||
|
|
|
@ -1012,18 +1012,18 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
|
|||
si = objectSources.begin();
|
||||
si != objectSources.end(); ++si)
|
||||
{
|
||||
const char* lang = (*si)->GetLanguage();
|
||||
const std::string& lang = (*si)->GetLanguage();
|
||||
const char* tool = NULL;
|
||||
if (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") == 0)
|
||||
if (lang == "C"|| lang == "CXX")
|
||||
{
|
||||
tool = "ClCompile";
|
||||
}
|
||||
else if (strcmp(lang, "ASM_MASM") == 0 &&
|
||||
else if (lang == "ASM_NASM" &&
|
||||
this->GlobalGenerator->IsMasmEnabled())
|
||||
{
|
||||
tool = "MASM";
|
||||
}
|
||||
else if (strcmp(lang, "RC") == 0)
|
||||
else if (lang == "RC")
|
||||
{
|
||||
tool = "ResourceCompile";
|
||||
}
|
||||
|
@ -1108,29 +1108,28 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
|
|||
{
|
||||
defines += cdefs;
|
||||
}
|
||||
const char* lang =
|
||||
std::string lang =
|
||||
this->GlobalGenerator->GetLanguageFromExtension
|
||||
(sf.GetExtension().c_str());
|
||||
const char* sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf);
|
||||
const char* linkLanguage = this->Target->GetLinkerLanguage();
|
||||
std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf);
|
||||
const std::string& linkLanguage = this->Target->GetLinkerLanguage();
|
||||
bool needForceLang = false;
|
||||
// source file does not match its extension language
|
||||
if(lang && sourceLang && strcmp(lang, sourceLang) != 0)
|
||||
if(lang != sourceLang)
|
||||
{
|
||||
needForceLang = true;
|
||||
lang = sourceLang;
|
||||
}
|
||||
// if the source file does not match the linker language
|
||||
// then force c or c++
|
||||
if(needForceLang || (linkLanguage && lang
|
||||
&& strcmp(lang, linkLanguage) != 0))
|
||||
if(needForceLang || (linkLanguage != lang))
|
||||
{
|
||||
if(strcmp(lang, "CXX") == 0)
|
||||
if(lang == "CXX")
|
||||
{
|
||||
// force a C++ file type
|
||||
flags += " /TP ";
|
||||
}
|
||||
else if(strcmp(lang, "C") == 0)
|
||||
else if(lang == "C")
|
||||
{
|
||||
// force to c
|
||||
flags += " /TC ";
|
||||
|
@ -1341,17 +1340,17 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
|
|||
// collect up flags for
|
||||
if(this->Target->GetType() < cmTarget::UTILITY)
|
||||
{
|
||||
const char* linkLanguage =
|
||||
const std::string& linkLanguage =
|
||||
this->Target->GetLinkerLanguage(configName.c_str());
|
||||
if(!linkLanguage)
|
||||
if(linkLanguage.empty())
|
||||
{
|
||||
cmSystemTools::Error
|
||||
("CMake can not determine linker language for target: ",
|
||||
this->Name.c_str());
|
||||
return false;
|
||||
}
|
||||
if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0
|
||||
|| strcmp(linkLanguage, "Fortran") == 0)
|
||||
if(linkLanguage == "C" || linkLanguage == "CXX"
|
||||
|| linkLanguage == "Fortran")
|
||||
{
|
||||
std::string baseFlagVar = "CMAKE_";
|
||||
baseFlagVar += linkLanguage;
|
||||
|
@ -1365,11 +1364,11 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
|
|||
Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str());
|
||||
}
|
||||
// set the correct language
|
||||
if(strcmp(linkLanguage, "C") == 0)
|
||||
if(linkLanguage == "C")
|
||||
{
|
||||
flags += " /TC ";
|
||||
}
|
||||
if(strcmp(linkLanguage, "CXX") == 0)
|
||||
if(linkLanguage == "CXX")
|
||||
{
|
||||
flags += " /TP ";
|
||||
}
|
||||
|
@ -1525,9 +1524,9 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
|
|||
cmVSGetLinkFlagTable(this->LocalGenerator), 0, this));
|
||||
Options& linkOptions = *pOptions;
|
||||
|
||||
const char* linkLanguage =
|
||||
const std::string& linkLanguage =
|
||||
this->Target->GetLinkerLanguage(config.c_str());
|
||||
if(!linkLanguage)
|
||||
if(linkLanguage.empty())
|
||||
{
|
||||
cmSystemTools::Error
|
||||
("CMake can not determine linker language for target: ",
|
||||
|
|
|
@ -222,7 +222,7 @@ cmVisualStudioGeneratorOptions
|
|||
::OutputPreprocessorDefinitions(std::ostream& fout,
|
||||
const char* prefix,
|
||||
const char* suffix,
|
||||
const char* lang)
|
||||
const std::string& lang)
|
||||
{
|
||||
if(this->Defines.empty())
|
||||
{
|
||||
|
@ -270,7 +270,7 @@ cmVisualStudioGeneratorOptions
|
|||
{
|
||||
define = cmVisualStudio10GeneratorOptionsEscapeForXML(define.c_str());
|
||||
|
||||
if(0 == strcmp(lang, "RC"))
|
||||
if(lang == "RC")
|
||||
{
|
||||
cmSystemTools::ReplaceString(define, "\"", "\\\"");
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
void OutputPreprocessorDefinitions(std::ostream& fout,
|
||||
const char* prefix,
|
||||
const char* suffix,
|
||||
const char* lang);
|
||||
const std::string& lang);
|
||||
void OutputFlagMap(std::ostream& fout, const char* indent);
|
||||
void OutputAdditionalOptions(std::ostream& fout,
|
||||
const char* prefix,
|
||||
|
|
|
@ -123,7 +123,7 @@ public:
|
|||
void CopyAttributes(cmXCodeObject* );
|
||||
|
||||
void AddDependLibrary(const char* configName,
|
||||
const char* l)
|
||||
const std::string& l)
|
||||
{
|
||||
if(!configName)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue