cmGlobalNinjaGenerator: Save 'ninja' version very early
Keep it in a member variable for convenient reference. Store the value as soon as it is known.
This commit is contained in:
parent
ed67f40522
commit
a3c5ca960b
@ -548,11 +548,11 @@ void cmGlobalNinjaGenerator::Generate()
|
|||||||
{
|
{
|
||||||
// Check minimum Ninja version.
|
// Check minimum Ninja version.
|
||||||
if (cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
|
if (cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
|
||||||
CurrentNinjaVersion().c_str(),
|
this->NinjaVersion.c_str(),
|
||||||
RequiredNinjaVersion().c_str()))
|
RequiredNinjaVersion().c_str()))
|
||||||
{
|
{
|
||||||
std::ostringstream msg;
|
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 << ") is less than the version of Ninja required by CMake (";
|
||||||
msg << this->RequiredNinjaVersion() << ").";
|
msg << this->RequiredNinjaVersion() << ").";
|
||||||
this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, msg.str());
|
this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, msg.str());
|
||||||
@ -591,6 +591,14 @@ void cmGlobalNinjaGenerator::FindMakeProgram(cmMakefile* mf)
|
|||||||
if (const char* ninjaCommand = mf->GetDefinition("CMAKE_MAKE_PROGRAM"))
|
if (const char* ninjaCommand = mf->GetDefinition("CMAKE_MAKE_PROGRAM"))
|
||||||
{
|
{
|
||||||
this->NinjaCommand = ninjaCommand;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1275,21 +1283,10 @@ std::string cmGlobalNinjaGenerator::ninjaCmd() const
|
|||||||
return "ninja";
|
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
|
bool cmGlobalNinjaGenerator::SupportsConsolePool() const
|
||||||
{
|
{
|
||||||
return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
|
return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
|
||||||
CurrentNinjaVersion().c_str(),
|
this->NinjaVersion.c_str(),
|
||||||
RequiredNinjaVersionForConsolePool().c_str()) == false;
|
RequiredNinjaVersionForConsolePool().c_str()) == false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +305,6 @@ public:
|
|||||||
|
|
||||||
virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
|
virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
|
||||||
|
|
||||||
std::string CurrentNinjaVersion() const;
|
|
||||||
// Ninja generator uses 'deps' and 'msvc_deps_prefix' introduced in 1.3
|
// Ninja generator uses 'deps' and 'msvc_deps_prefix' introduced in 1.3
|
||||||
static std::string RequiredNinjaVersion() { return "1.3"; }
|
static std::string RequiredNinjaVersion() { return "1.3"; }
|
||||||
static std::string RequiredNinjaVersionForConsolePool() { return "1.5"; }
|
static std::string RequiredNinjaVersionForConsolePool() { return "1.5"; }
|
||||||
@ -394,6 +393,7 @@ private:
|
|||||||
TargetAliasMap TargetAliases;
|
TargetAliasMap TargetAliases;
|
||||||
|
|
||||||
std::string NinjaCommand;
|
std::string NinjaCommand;
|
||||||
|
std::string NinjaVersion;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ! cmGlobalNinjaGenerator_h
|
#endif // ! cmGlobalNinjaGenerator_h
|
||||||
|
Loading…
x
Reference in New Issue
Block a user