Ninja: Centralized required Ninja version numbers and comparisons.
This commit is contained in:
parent
101ba25e6a
commit
c5ac2b9df3
@ -1256,7 +1256,7 @@ std::string cmGlobalNinjaGenerator::ninjaCmd() const
|
|||||||
return "ninja";
|
return "ninja";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmGlobalNinjaGenerator::ninjaVersion() const
|
std::string cmGlobalNinjaGenerator::CurrentNinjaVersion() const
|
||||||
{
|
{
|
||||||
std::string version;
|
std::string version;
|
||||||
std::string command = ninjaCmd() + " --version";
|
std::string command = ninjaCmd() + " --version";
|
||||||
@ -1264,13 +1264,14 @@ std::string cmGlobalNinjaGenerator::ninjaVersion() const
|
|||||||
&version, 0, 0, 0,
|
&version, 0, 0, 0,
|
||||||
cmSystemTools::OUTPUT_NONE);
|
cmSystemTools::OUTPUT_NONE);
|
||||||
|
|
||||||
return version;
|
return cmSystemTools::TrimWhitespace(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmGlobalNinjaGenerator::SupportsConsolePool() const
|
bool cmGlobalNinjaGenerator::SupportsConsolePool() const
|
||||||
{
|
{
|
||||||
return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
|
return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
|
||||||
ninjaVersion().c_str(), "1.5") == false;
|
CurrentNinjaVersion().c_str(),
|
||||||
|
RequiredNinjaVersionForConsolePool().c_str()) == false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
|
void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
|
||||||
|
@ -299,8 +299,10 @@ public:
|
|||||||
|
|
||||||
virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
|
virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
|
||||||
|
|
||||||
std::string ninjaVersion() const;
|
std::string CurrentNinjaVersion() const;
|
||||||
|
// Ninja generator uses 'deps' and 'msvc_deps_prefix' introduced in 1.3
|
||||||
|
static std::string RequiredNinjaVersion() { return "1.3"; }
|
||||||
|
static std::string RequiredNinjaVersionForConsolePool() { return "1.5"; }
|
||||||
bool SupportsConsolePool() const;
|
bool SupportsConsolePool() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -193,16 +193,14 @@ void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os)
|
|||||||
void cmLocalNinjaGenerator::WriteNinjaRequiredVersion(std::ostream& os)
|
void cmLocalNinjaGenerator::WriteNinjaRequiredVersion(std::ostream& os)
|
||||||
{
|
{
|
||||||
// Default required version
|
// Default required version
|
||||||
// Ninja generator uses 'deps' and 'msvc_deps_prefix' introduced in 1.3
|
std::string requiredVersion =
|
||||||
std::string requiredVersion = "1.3";
|
this->GetGlobalNinjaGenerator()->RequiredNinjaVersion();
|
||||||
|
|
||||||
// Ninja generator uses the 'console' pool if available (>= 1.5)
|
// Ninja generator uses the 'console' pool if available (>= 1.5)
|
||||||
std::string usedVersion = this->GetGlobalNinjaGenerator()->ninjaVersion();
|
if(this->GetGlobalNinjaGenerator()->SupportsConsolePool())
|
||||||
if(cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
|
|
||||||
usedVersion.c_str(),
|
|
||||||
"1.5") == false)
|
|
||||||
{
|
{
|
||||||
requiredVersion = "1.5";
|
requiredVersion =
|
||||||
|
this->GetGlobalNinjaGenerator()->RequiredNinjaVersionForConsolePool();
|
||||||
}
|
}
|
||||||
|
|
||||||
cmGlobalNinjaGenerator::WriteComment(os,
|
cmGlobalNinjaGenerator::WriteComment(os,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user