From e1aeb61e7dc20d3b733328d6f7d96c294f82813b Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 20 Jan 2025 13:33:17 -0800 Subject: [PATCH] SystemInformation: Fix GetNumberOfLogicalCPU on s390x The format of `/proc/cpuinfo` is different on `s390x` than other architectures. Issue: cmake/cmake#26619 --- SystemInformation.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/SystemInformation.cxx b/SystemInformation.cxx index 7b0d271..9b1a85b 100644 --- a/SystemInformation.cxx +++ b/SystemInformation.cxx @@ -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"); + const char* 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__) -- GitLab