summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2014-02-04 02:20:56 (GMT)
committerBrad King <brad.king@kitware.com>2014-03-08 18:05:30 (GMT)
commitce5114354c357df973e54872ab7abebbff36793b (patch)
tree472c096db98ba5b36c7c32910a334a044ecafd80 /Source
parent83a5e453f8c0dc0fc9b6bdee9723478aafefd0da (diff)
downloadCMake-ce5114354c357df973e54872ab7abebbff36793b.zip
CMake-ce5114354c357df973e54872ab7abebbff36793b.tar.gz
CMake-ce5114354c357df973e54872ab7abebbff36793b.tar.bz2
stringapi: Use strings for the languages
Diffstat (limited to 'Source')
-rw-r--r--Source/cmComputeLinkInformation.cxx4
-rw-r--r--Source/cmComputeLinkInformation.h4
-rw-r--r--Source/cmCoreTryCompile.cxx3
-rw-r--r--Source/cmDepends.cxx2
-rw-r--r--Source/cmDepends.h4
-rw-r--r--Source/cmDependsC.cxx2
-rw-r--r--Source/cmDependsC.h3
-rw-r--r--Source/cmExtraCodeBlocksGenerator.cxx3
-rw-r--r--Source/cmExtraCodeLiteGenerator.cxx3
-rw-r--r--Source/cmExtraSublimeTextGenerator.cxx10
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx3
-rw-r--r--Source/cmGeneratorTarget.cxx2
-rw-r--r--Source/cmGetSourceFilePropertyCommand.cxx2
-rw-r--r--Source/cmGlobalGenerator.cxx36
-rw-r--r--Source/cmGlobalGenerator.h21
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h3
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx41
-rw-r--r--Source/cmGlobalXCodeGenerator.h11
-rw-r--r--Source/cmLocalGenerator.cxx55
-rw-r--r--Source/cmLocalGenerator.h28
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx2
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.h4
-rw-r--r--Source/cmLocalVisualStudio6Generator.cxx41
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx32
-rw-r--r--Source/cmMakefile.cxx4
-rw-r--r--Source/cmMakefile.h2
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx6
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx36
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.h2
-rw-r--r--Source/cmMakefileTargetGenerator.cxx22
-rw-r--r--Source/cmMakefileTargetGenerator.h8
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx8
-rw-r--r--Source/cmNinjaNormalTargetGenerator.h2
-rw-r--r--Source/cmNinjaTargetGenerator.cxx2
-rw-r--r--Source/cmNinjaTargetGenerator.h2
-rw-r--r--Source/cmSourceFile.cxx11
-rw-r--r--Source/cmSourceFile.h4
-rw-r--r--Source/cmSourceFileLocation.cxx2
-rw-r--r--Source/cmTarget.cxx20
-rw-r--r--Source/cmTarget.h2
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx39
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx4
-rw-r--r--Source/cmVisualStudioGeneratorOptions.h2
-rw-r--r--Source/cmXCodeObject.h2
44 files changed, 246 insertions, 253 deletions
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 6986965..716eb4d 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -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: ",
diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h
index 356e6ed..26ee8f0 100644
--- a/Source/cmComputeLinkInformation.h
+++ b/Source/cmComputeLinkInformation.h
@@ -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.
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 7b52069..1e8e4d0 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -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);
}
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index 1a0e93f..51150f2 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -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;
diff --git a/Source/cmDepends.h b/Source/cmDepends.h
index d787edd..b293c5b 100644
--- a/Source/cmDepends.h
+++ b/Source/cmDepends.h
@@ -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.
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index 4fc5efb..585f959 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -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)
diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h
index 16dfad7..cd1e7a4 100644
--- a/Source/cmDependsC.h
+++ b/Source/cmDependsC.h
@@ -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. */
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index 548c88b..8d4cf85 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -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();
diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx
index ff84fb7..028d3d5 100644
--- a/Source/cmExtraCodeLiteGenerator.cxx
+++ b/Source/cmExtraCodeLiteGenerator.cxx
@@ -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();
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 604bfcc..1c9ac02 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -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.
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index c27c03f..d12a66d 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -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,
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index d9885b9..4e7c71e 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -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);
}
diff --git a/Source/cmGetSourceFilePropertyCommand.cxx b/Source/cmGetSourceFilePropertyCommand.cxx
index 3d85e6d..a6e4fcc 100644
--- a/Source/cmGetSourceFilePropertyCommand.cxx
+++ b/Source/cmGetSourceFilePropertyCommand.cxx
@@ -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());
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index f76c6d1..7e93676 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -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);
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index b66f01e..2f23fd5 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -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;
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index 9186d65..4b73118 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -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,
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index ab92c6e..3f24167 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -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;
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 31c2cfb..15f1363 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -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(
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 476c95d..0b4f94b 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -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)
{
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 80a1421..74303f4 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -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);
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 93722d1..11b89f4 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -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)
{
diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h
index 703369e..b0ccf52 100644
--- a/Source/cmLocalUnixMakefileGenerator3.h
+++ b/Source/cmLocalUnixMakefileGenerator3.h
@@ -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>
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index a5e8294..ff217c3 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -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;
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index d11bf55..f93a7aa 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -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 ";
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index ff0576e..8274b13 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -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;
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 044324e..331a064 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -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.
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 1802054..b827363 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -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(),
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 10418d0..96159f9 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -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.
diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h
index 4873516..68980c3 100644
--- a/Source/cmMakefileLibraryTargetGenerator.h
+++ b/Source/cmMakefileLibraryTargetGenerator.h
@@ -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);
};
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index bf0dc51..3ba5a77 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -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.
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index f960afc..8ab65bf 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -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);
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 73ba815..b81fbeb 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -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) {
diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h
index c7a089c..556ed5e 100644
--- a/Source/cmNinjaNormalTargetGenerator.h
+++ b/Source/cmNinjaNormalTargetGenerator.h
@@ -47,7 +47,7 @@ private:
std::string TargetNameReal;
std::string TargetNameImport;
std::string TargetNamePDB;
- const char *TargetLinkLanguage;
+ std::string TargetLinkLanguage;
};
#endif // ! cmNinjaNormalTargetGenerator_h
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 00b0441..1c43cb3 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -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());
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index 43f2279..e8ac81c 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -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.
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index f052044..0d37205 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -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;
}
diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h
index b362c98..17c96ac 100644
--- a/Source/cmSourceFile.h
+++ b/Source/cmSourceFile.h
@@ -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
diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx
index 832a6a7..30a53cb 100644
--- a/Source/cmSourceFileLocation.cxx
+++ b/Source/cmSourceFileLocation.cxx
@@ -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())
{
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 34d92fa..6782822 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -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;
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 9f7b811..205c81c 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -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
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 2d21a3d..aa721b7 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -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: ",
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 6aca787..f48c593 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -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, "\"", "\\\"");
}
diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h
index 90f7667..214b893 100644
--- a/Source/cmVisualStudioGeneratorOptions.h
+++ b/Source/cmVisualStudioGeneratorOptions.h
@@ -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,
diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h
index 0761136..ad1533e 100644
--- a/Source/cmXCodeObject.h
+++ b/Source/cmXCodeObject.h
@@ -123,7 +123,7 @@ public:
void CopyAttributes(cmXCodeObject* );
void AddDependLibrary(const char* configName,
- const char* l)
+ const std::string& l)
{
if(!configName)
{