diff options
author | Brad King <brad.king@kitware.com> | 2016-06-08 14:15:29 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-06-08 16:00:44 (GMT) |
commit | ea59867187e8bdb8a7ffda37ad58e7f8493ebf7c (patch) | |
tree | 83de15eec6a989f77632fcbc1846440caffe0f11 /Source/cmNinjaNormalTargetGenerator.cxx | |
parent | 1cfc750150065ee3b65ad66d2b37a3b28a9e799d (diff) | |
download | CMake-ea59867187e8bdb8a7ffda37ad58e7f8493ebf7c.zip CMake-ea59867187e8bdb8a7ffda37ad58e7f8493ebf7c.tar.gz CMake-ea59867187e8bdb8a7ffda37ad58e7f8493ebf7c.tar.bz2 |
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>
Diffstat (limited to 'Source/cmNinjaNormalTargetGenerator.cxx')
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 3e91545..be6afee 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -144,6 +144,14 @@ std::string cmNinjaNormalTargetGenerator::LanguageLinkerRule() const this->GetGeneratorTarget()->GetName()); } +struct cmNinjaRemoveNoOpCommands +{ + bool operator()(std::string const& cmd) + { + return cmd.empty() || cmd[0] == ':'; + } +}; + void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) { cmState::TargetType targetType = this->GetGeneratorTarget()->GetType(); @@ -231,6 +239,13 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) i != linkCmds.end(); ++i) { this->GetLocalGenerator()->ExpandRuleVariables(*i, vars); } + { + // If there is no ranlib the command will be ":". Skip it. + std::vector<std::string>::iterator newEnd = std::remove_if( + linkCmds.begin(), linkCmds.end(), cmNinjaRemoveNoOpCommands()); + linkCmds.erase(newEnd, linkCmds.end()); + } + linkCmds.insert(linkCmds.begin(), "$PRE_LINK"); linkCmds.push_back("$POST_BUILD"); std::string linkCmd = |