Skip to content

Commit

Permalink
i#2267 utils.cmake: Use <unknown> for cpu_vendor as fallback (#6457)
Browse files Browse the repository at this point in the history
`vendor_id` is not always available, only do `REGEX REPLACE` if a match
is found. Tested on Intel, AMD, and \<unknown\> AArch64 machines via GA
runners.

Issue: #2267
  • Loading branch information
ksco authored Nov 16, 2023
1 parent e32b2c1 commit 81fdbd7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions make/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,11 @@ function (get_processor_vendor out)
"[HKEY_LOCAL_MACHINE\\Hardware\\Description\\System\\CentralProcessor\\0;VendorIdentifier]"
NAME)
elseif (EXISTS "/proc/cpuinfo")
set (regex ".*vendor_id[ \t]*:[ \t]+([a-zA-Z0-9_-]+).*")
file(READ "/proc/cpuinfo" contents)
string(REGEX REPLACE ".*vendor_id[ \t]*:[ \t]+([a-zA-Z0-9_-]+).*" "\\1"
cpu_vendor "${contents}")
if (contents MATCHES ${regex})
string(REGEX REPLACE ${regex} "\\1" cpu_vendor "${contents}")
endif ()
endif ()
message(STATUS "Processor vendor is ${cpu_vendor}")
set(${out} ${cpu_vendor} PARENT_SCOPE)
Expand Down

0 comments on commit 81fdbd7

Please sign in to comment.