Run ranlib on archives only if the tool is available

CMakeFindBinUtils sets CMAKE_RANLIB to `:` if it is not available in
order to get a no-op.  This does not work on a Windows host build
environment that runs commands in `cmd` instead of `sh`.  Teach the
Ninja and Makefile generators to simply skip the command if it is `:`.

This this was already done by the Makefile generator since commit
v2.6.0~3161 (BUG: Do not write link script lines that use the ':',
2006-06-18), but only when using a link script.

Reported-by: Michael Jäntsch <Michael.Jaentsch@gmx.de>
This commit is contained in:
Brad King
2016-06-08 10:15:29 -04:00
parent 1cfc750150
commit ea59867187
2 changed files with 19 additions and 1 deletions
+4 -1
View File
@@ -676,7 +676,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
i != archiveFinishCommands.end(); ++i) {
std::string cmd = *i;
this->LocalGenerator->ExpandRuleVariables(cmd, vars);
real_link_commands.push_back(cmd);
// If there is no ranlib the command will be ":". Skip it.
if (!cmd.empty() && cmd[0] != ':') {
real_link_commands.push_back(cmd);
}
}
} else {
// Get the set of commands.