1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-24 11:32:44 +08:00

cmLocalGenerator: Simplify ConvertToLinkReference

Make conversion to output format the caller responsibility, so that the
method only 'converts to a link reference'.
This commit is contained in:
Stephen Kelly
2016-10-04 22:56:32 +02:00
parent fd93b3605b
commit 20e62f74c5
5 changed files with 13 additions and 19 deletions

View File

@@ -75,8 +75,10 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
// Append the flag and value. Use ConvertToLinkReference to help // Append the flag and value. Use ConvertToLinkReference to help
// vs6's "cl -link" pass it to the linker. // vs6's "cl -link" pass it to the linker.
std::string flag = defFileFlag; std::string flag = defFileFlag;
flag += (this->LocalGenerator->ConvertToLinkReference( flag += this->LocalGenerator->ConvertToOutputFormat(
this->ModuleDefinitionFile->GetFullPath())); this->LocalGenerator->ConvertToLinkReference(
this->ModuleDefinitionFile->GetFullPath()),
cmOutputConverter::SHELL);
this->LocalGenerator->AppendFlags(flags, flag); this->LocalGenerator->AppendFlags(flags, flag);
} }

View File

@@ -1374,8 +1374,7 @@ std::string cmLocalGenerator::GetTargetFortranFlags(
return std::string(); return std::string();
} }
std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib, std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib)
OutputFormat format)
{ {
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
// Work-ardound command line parsing limitations in MSVC 6.0 // Work-ardound command line parsing limitations in MSVC 6.0
@@ -1392,17 +1391,14 @@ std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib,
// Append the rest of the path with no space. // Append the rest of the path with no space.
sp += lib.substr(pos); sp += lib.substr(pos);
// Convert to an output path. return sp;
return this->ConvertToOutputFormat(sp.c_str(), format);
} }
} }
} }
#endif #endif
// Normal behavior. // Normal behavior.
return this->ConvertToOutputFormat( return this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), lib);
this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), lib),
format);
} }
/** /**
@@ -1517,7 +1513,8 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
continue; continue;
} }
if (li->IsPath) { if (li->IsPath) {
linkLibs += this->ConvertToLinkReference(li->Value, shellFormat); linkLibs += this->ConvertToOutputFormat(
this->ConvertToLinkReference(li->Value), shellFormat);
} else { } else {
linkLibs += li->Value; linkLibs += li->Value;
} }

View File

@@ -367,9 +367,7 @@ protected:
std::string& CreateSafeUniqueObjectFileName(const std::string& sin, std::string& CreateSafeUniqueObjectFileName(const std::string& sin,
std::string const& dir_max); std::string const& dir_max);
virtual std::string ConvertToLinkReference( virtual std::string ConvertToLinkReference(std::string const& lib);
std::string const& lib,
cmOutputConverter::OutputFormat format = cmOutputConverter::SHELL);
/** Check whether the native build system supports the given /** Check whether the native build system supports the given
definition. Issues a warning. */ definition. Issues a warning. */

View File

@@ -121,10 +121,9 @@ cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator()
// Virtual protected methods. // Virtual protected methods.
std::string cmLocalNinjaGenerator::ConvertToLinkReference( std::string cmLocalNinjaGenerator::ConvertToLinkReference(
std::string const& lib, cmOutputConverter::OutputFormat format) std::string const& lib)
{ {
std::string path = this->GetGlobalNinjaGenerator()->ConvertToNinjaPath(lib); return this->GetGlobalNinjaGenerator()->ConvertToNinjaPath(lib);
return this->ConvertToOutputFormat(path, format);
} }
std::string cmLocalNinjaGenerator::ConvertToIncludeReference( std::string cmLocalNinjaGenerator::ConvertToIncludeReference(

View File

@@ -76,9 +76,7 @@ public:
void AppendCustomCommandDeps(cmCustomCommandGenerator const& ccg, void AppendCustomCommandDeps(cmCustomCommandGenerator const& ccg,
cmNinjaDeps& ninjaDeps); cmNinjaDeps& ninjaDeps);
std::string ConvertToLinkReference(std::string const& lib, std::string ConvertToLinkReference(std::string const& lib) CM_OVERRIDE;
cmOutputConverter::OutputFormat format =
cmOutputConverter::SHELL) CM_OVERRIDE;
void ComputeObjectFilenames( void ComputeObjectFilenames(
std::map<cmSourceFile const*, std::string>& mapping, std::map<cmSourceFile const*, std::string>& mapping,