diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 493d26eaf..244c9e593 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -50,6 +50,7 @@ cmLocalGenerator::cmLocalGenerator() this->MinGWMake = false; this->NMake = false; this->MSYSShell = false; + this->LinkScriptShell = false; this->IgnoreLibPrefix = false; this->UseRelativePaths = false; this->Configured = false; @@ -1995,7 +1996,7 @@ std::string cmLocalGenerator::Convert(const char* source, // For the MSYS shell convert drive letters to posix paths, so // that c:/some/path becomes /c/some/path. This is needed to // avoid problems with the shell path translation. - if(this->MSYSShell) + if(this->MSYSShell && !this->LinkScriptShell) { if(result.size() > 2 && result[1] == ':') { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index d89974706..c55f6a332 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -210,6 +210,9 @@ public: const char* Defines; }; + /** Set whether to treat conversions to SHELL as a link script shell. */ + void SetLinkScriptShell(bool b) { this->LinkScriptShell = b; } + /** Escape the given string to be used as a command line argument in the native build system shell. Optionally allow the build system to replace make variable references. Optionally adjust @@ -346,6 +349,7 @@ protected: bool NMake; bool ForceUnixPath; bool MSYSShell; + bool LinkScriptShell; bool UseRelativePaths; bool IgnoreLibPrefix; bool Configured; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index e67b991f1..bb54f265c 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -367,6 +367,9 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Expand the rule variables. { + // Set path conversion for link script shells. + this->LocalGenerator->SetLinkScriptShell(useLinkScript); + // Collect up flags to link in needed libraries. cmOStringStream linklibs; this->LocalGenerator->OutputLinkLibraries(linklibs, *this->Target, relink); @@ -428,6 +431,9 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) this->LocalGenerator->ExpandRuleVariables(*i, vars); } this->LocalGenerator->TargetImplib = ""; + + // Restore path conversion to normal shells. + this->LocalGenerator->SetLinkScriptShell(false); } // Optionally convert the build rule to use a script to avoid long diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index a81cfd67d..8e96fd6d9 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -673,7 +673,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::vector archiveAppendCommands; std::vector archiveFinishCommands; std::string::size_type archiveCommandLimit = std::string::npos; - if(useLinkScript && this->Target->GetType() == cmTarget::STATIC_LIBRARY) + if(this->Target->GetType() == cmTarget::STATIC_LIBRARY) { std::string arCreateVar = "CMAKE_"; arCreateVar += linkLanguage; @@ -696,18 +696,28 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules { cmSystemTools::ExpandListArgument(rule, archiveFinishCommands); } + } + + // Decide whether to use archiving rules. + bool useArchiveRules = + !archiveCreateCommands.empty() && !archiveAppendCommands.empty(); + if(useArchiveRules) + { + // Archiving rules are always run with a link script. + useLinkScript = true; // Limit the length of individual object lists to less than the // 32K command line length limit on Windows. We could make this a // platform file variable but this should work everywhere. archiveCommandLimit = 30000; } - bool useArchiveRules = - !archiveCreateCommands.empty() && !archiveAppendCommands.empty(); // Expand the rule variables. std::vector real_link_commands; { + // Set path conversion for link script shells. + this->LocalGenerator->SetLinkScriptShell(useLinkScript); + // Collect up flags to link in needed libraries. cmOStringStream linklibs; this->LocalGenerator->OutputLinkLibraries(linklibs, *this->Target, relink); @@ -864,6 +874,9 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } } this->LocalGenerator->TargetImplib = ""; + + // Restore path conversion to normal shells. + this->LocalGenerator->SetLinkScriptShell(false); } // Optionally convert the build rule to use a script to avoid long