diff options
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 8498e39..a8a307c 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -548,11 +548,11 @@ void cmGlobalNinjaGenerator::Generate() { // Check minimum Ninja version. if (cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, - CurrentNinjaVersion().c_str(), + this->NinjaVersion.c_str(), RequiredNinjaVersion().c_str())) { std::ostringstream msg; - msg << "The detected version of Ninja (" << this->CurrentNinjaVersion(); + msg << "The detected version of Ninja (" << this->NinjaVersion; msg << ") is less than the version of Ninja required by CMake ("; msg << this->RequiredNinjaVersion() << ")."; this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, msg.str()); @@ -585,6 +585,23 @@ void cmGlobalNinjaGenerator::Generate() this->CloseBuildFileStream(); } +void cmGlobalNinjaGenerator::FindMakeProgram(cmMakefile* mf) +{ + this->cmGlobalGenerator::FindMakeProgram(mf); + if (const char* ninjaCommand = mf->GetDefinition("CMAKE_MAKE_PROGRAM")) + { + this->NinjaCommand = ninjaCommand; + std::vector<std::string> command; + command.push_back(this->NinjaCommand); + command.push_back("--version"); + std::string version; + cmSystemTools::RunSingleCommand(command, + &version, 0, 0, 0, + cmSystemTools::OUTPUT_NONE); + this->NinjaVersion = cmSystemTools::TrimWhitespace(version); + } +} + void cmGlobalNinjaGenerator ::EnableLanguage(std::vector<std::string>const& langs, cmMakefile* mf, @@ -1260,28 +1277,16 @@ std::string cmGlobalNinjaGenerator::ninjaCmd() const { cmLocalGenerator* lgen = this->LocalGenerators[0]; if (lgen) { - return lgen->ConvertToOutputFormat( - lgen->GetMakefile()->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"), - cmLocalGenerator::SHELL); + return lgen->ConvertToOutputFormat(this->NinjaCommand, + cmLocalGenerator::SHELL); } return "ninja"; } -std::string cmGlobalNinjaGenerator::CurrentNinjaVersion() const -{ - std::string version; - std::string command = ninjaCmd() + " --version"; - cmSystemTools::RunSingleCommand(command.c_str(), - &version, 0, 0, 0, - cmSystemTools::OUTPUT_NONE); - - return cmSystemTools::TrimWhitespace(version); -} - bool cmGlobalNinjaGenerator::SupportsConsolePool() const { return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, - CurrentNinjaVersion().c_str(), + this->NinjaVersion.c_str(), RequiredNinjaVersionForConsolePool().c_str()) == false; } |