diff options
author | Stephen Kelly <steveire@gmail.com> | 2016-10-08 10:21:36 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2016-10-10 18:38:53 (GMT) |
commit | 5b361fdda0f2808f0368b746a880981ebda0ade0 (patch) | |
tree | f1c0ed09db22c32951b8fea68e15a2ccd94aff84 /Source/cmLocalGenerator.cxx | |
parent | 2e5d1990f382aa42e8a0ad34117ee1e5a9187153 (diff) | |
download | CMake-5b361fdda0f2808f0368b746a880981ebda0ade0.zip CMake-5b361fdda0f2808f0368b746a880981ebda0ade0.tar.gz CMake-5b361fdda0f2808f0368b746a880981ebda0ade0.tar.bz2 |
cmLinkLineComputer: Extract from cmLocalGenerator
CMake has several classes which have too many responsibilities.
cmLocalGenerator is one of them. Start to extract the link line
computation. Create generator-specific implementations of the interface
to account for generator-specific behavior.
Unfortunately MSVC60 has different behavior to everything else and CMake
still generates makefiles for it. Isolate it with MSVC60-specific
names.
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 64 |
1 files changed, 16 insertions, 48 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index f1b7c6a..c152a8b 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -12,6 +12,7 @@ #include "cmInstallGenerator.h" #include "cmInstallScriptGenerator.h" #include "cmInstallTargetGenerator.h" +#include "cmLinkLineComputer.h" #include "cmMakefile.h" #include "cmSourceFile.h" #include "cmSystemTools.h" @@ -1148,9 +1149,10 @@ void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, } void cmLocalGenerator::GetTargetFlags( - const std::string& config, std::string& linkLibs, std::string& flags, - std::string& linkFlags, std::string& frameworkPath, std::string& linkPath, - cmGeneratorTarget* target, bool useWatcomQuote) + cmLinkLineComputer* linkLineComputer, const std::string& config, + std::string& linkLibs, std::string& flags, std::string& linkFlags, + std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget* target, + bool useWatcomQuote) { const std::string buildType = cmSystemTools::UpperCase(config); const char* libraryLinkVariable = @@ -1203,8 +1205,9 @@ void cmLocalGenerator::GetTargetFlags( linkFlags += " "; } } - this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, *target, - false, false, useWatcomQuote); + this->OutputLinkLibraries(linkLineComputer, linkLibs, frameworkPath, + linkPath, *target, false, false, + useWatcomQuote); } break; case cmState::EXECUTABLE: { linkFlags += this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS"); @@ -1223,8 +1226,9 @@ void cmLocalGenerator::GetTargetFlags( return; } this->AddLanguageFlags(flags, linkLanguage, buildType); - this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, *target, - false, false, useWatcomQuote); + this->OutputLinkLibraries(linkLineComputer, linkLibs, frameworkPath, + linkPath, *target, false, false, + useWatcomQuote); if (cmSystemTools::IsOn( this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) { std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") + @@ -1383,51 +1387,15 @@ std::string cmLocalGenerator::GetTargetFortranFlags( return std::string(); } -std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - // Work-ardound command line parsing limitations in MSVC 6.0 - if (this->Makefile->IsOn("MSVC60")) { - // Search for the last space. - std::string::size_type pos = lib.rfind(' '); - if (pos != lib.npos) { - // Find the slash after the last space, if any. - pos = lib.find('/', pos); - - // Convert the portion of the path with a space to a short path. - std::string sp; - if (cmSystemTools::GetShortPath(lib.substr(0, pos).c_str(), sp)) { - // Append the rest of the path with no space. - sp += lib.substr(pos); - - return sp; - } - } - } -#endif - - // Normal behavior. - std::string relLib = lib; - cmState::Directory stateDir = this->GetStateSnapshot().GetDirectory(); - if (cmOutputConverter::ContainedInDirectory( - stateDir.GetCurrentBinary(), lib, stateDir)) { - relLib = cmOutputConverter::ForceToRelativePath( - stateDir.GetCurrentBinary(), lib); - } - return relLib; -} - /** * Output the linking rules on a command line. For executables, * targetLibrary should be a NULL pointer. For libraries, it should point * to the name of the library. This will not link a library against itself. */ -void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, - std::string& frameworkPath, - std::string& linkPath, - cmGeneratorTarget& tgt, bool relink, - bool forResponseFile, - bool useWatcomQuote) +void cmLocalGenerator::OutputLinkLibraries( + cmLinkLineComputer* linkLineComputer, std::string& linkLibraries, + std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget& tgt, + bool relink, bool forResponseFile, bool useWatcomQuote) { OutputFormat shellFormat = (forResponseFile) ? RESPONSE : ((useWatcomQuote) ? WATCOMQUOTE : SHELL); @@ -1486,7 +1454,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, } if (li->IsPath) { linkLibs += this->ConvertToOutputFormat( - this->ConvertToLinkReference(li->Value), shellFormat); + linkLineComputer->ConvertToLinkReference(li->Value), shellFormat); } else { linkLibs += li->Value; } |