mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-07 14:20:06 -06:00
Autogen: Restore AUTOGEN_PARALLEL support for numbers
Refactoring in commit d867e05892 (Autogen: Use JSON instead of CMake
script for info files, 2019-09-20, v3.16.0-rc1~57^2) broke support for
numerical values of `AUTOGEN_PARALLEL`. Parse and verify the range.
Warn if the value is invalid.
Fixes: #20376
This commit is contained in:
committed by
Brad King
parent
9d439e235c
commit
a42ecb1614
@@ -5,6 +5,7 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
|
#include <limits>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <sstream> // for basic_ios, istringstream
|
#include <sstream> // for basic_ios, istringstream
|
||||||
@@ -457,12 +458,23 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
|
|||||||
|
|
||||||
// Autogen target parallel processing
|
// Autogen target parallel processing
|
||||||
{
|
{
|
||||||
|
using ParallelType = decltype(this->AutogenTarget.Parallel);
|
||||||
|
unsigned long propInt = 0;
|
||||||
std::string const& prop =
|
std::string const& prop =
|
||||||
this->GenTarget->GetSafeProperty("AUTOGEN_PARALLEL");
|
this->GenTarget->GetSafeProperty("AUTOGEN_PARALLEL");
|
||||||
if (prop.empty() || (prop == "AUTO")) {
|
if (prop.empty() || (prop == "AUTO")) {
|
||||||
// Autodetect number of CPUs
|
// Autodetect number of CPUs
|
||||||
this->AutogenTarget.Parallel = GetParallelCPUCount();
|
this->AutogenTarget.Parallel = GetParallelCPUCount();
|
||||||
|
} else if (cmStrToULong(prop, &propInt) && propInt > 0 &&
|
||||||
|
propInt <= std::numeric_limits<ParallelType>::max()) {
|
||||||
|
this->AutogenTarget.Parallel = static_cast<ParallelType>(propInt);
|
||||||
} else {
|
} else {
|
||||||
|
// Warn the project author that AUTOGEN_PARALLEL is not valid.
|
||||||
|
this->Makefile->IssueMessage(
|
||||||
|
MessageType::AUTHOR_WARNING,
|
||||||
|
cmStrCat("AUTOGEN_PARALLEL=\"", prop, "\" for target \"",
|
||||||
|
this->GenTarget->GetName(),
|
||||||
|
"\" is not valid. Using AUTOGEN_PARALLEL=1"));
|
||||||
this->AutogenTarget.Parallel = 1;
|
this->AutogenTarget.Parallel = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user