KWSys: Backport "Fix GetNumberOfLogicalCPU on s390x" to CMake 3.31

The format of `/proc/cpuinfo` is different on `s390x` than other
architectures.

Issue: #26619
This commit is contained in:
Tom Stellard 2025-01-20 13:33:17 -08:00 committed by Brad King
parent 07df1a2a64
commit b64548eedc

View File

@ -3418,10 +3418,16 @@ bool SystemInformationImplementation::RetrieveInformationFromCpuInfoFile()
buffer.resize(fileSize - 2);
// Number of logical CPUs (combination of multiple processors, multi-core
// and SMT)
size_t pos = buffer.find("processor\t");
char const* processor_string =
#ifdef __s390x__
"cpu number";
#else
"processor\t";
#endif
size_t pos = buffer.find(processor_string);
while (pos != std::string::npos) {
this->NumberOfLogicalCPU++;
pos = buffer.find("processor\t", pos + 1);
pos = buffer.find(processor_string, pos + 1);
}
#if defined(__linux) || defined(__CYGWIN__)