If getconf returns empty output, try cpuinfo. (#11302)
Also, add message output (temporarily) for gathering data on all the dashboard machines. After the test runs on the overnight dashboards tonight, I'll comment out the message output and commit/push again.
This commit is contained in:
parent
9cc8ad99c9
commit
4d6418f683
|
@ -30,6 +30,7 @@ function(ProcessorCount var)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
# Windows:
|
# Windows:
|
||||||
set(count "$ENV{NUMBER_OF_PROCESSORS}")
|
set(count "$ENV{NUMBER_OF_PROCESSORS}")
|
||||||
|
message("ProcessorCount: using environment variable")
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
# Mac:
|
# Mac:
|
||||||
find_program(ProcessorCount_cmd_sysctl sysctl
|
find_program(ProcessorCount_cmd_sysctl sysctl
|
||||||
|
@ -38,21 +39,29 @@ function(ProcessorCount var)
|
||||||
execute_process(COMMAND ${ProcessorCount_cmd_sysctl} -n hw.ncpu
|
execute_process(COMMAND ${ProcessorCount_cmd_sysctl} -n hw.ncpu
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
OUTPUT_VARIABLE count)
|
OUTPUT_VARIABLE count)
|
||||||
|
message("ProcessorCount: using sysctl '${ProcessorCount_cmd_sysctl}'")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
|
# Linux (and other systems with getconf):
|
||||||
find_program(ProcessorCount_cmd_getconf getconf)
|
find_program(ProcessorCount_cmd_getconf getconf)
|
||||||
if(ProcessorCount_cmd_getconf)
|
if(ProcessorCount_cmd_getconf)
|
||||||
# Linux and other systems with getconf:
|
|
||||||
execute_process(COMMAND ${ProcessorCount_cmd_getconf} _NPROCESSORS_ONLN
|
execute_process(COMMAND ${ProcessorCount_cmd_getconf} _NPROCESSORS_ONLN
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
OUTPUT_VARIABLE count)
|
OUTPUT_VARIABLE count)
|
||||||
else()
|
message("ProcessorCount: using getconf '${ProcessorCount_cmd_getconf}'")
|
||||||
# Linux and other systems with /proc/cpuinfo:
|
endif()
|
||||||
set(cpuinfo_file /proc/cpuinfo)
|
endif()
|
||||||
if(EXISTS "${cpuinfo_file}")
|
|
||||||
file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$")
|
# Execute this code when there is no 'sysctl' or 'getconf' or
|
||||||
list(LENGTH procs count)
|
# when previously executed methods return empty output:
|
||||||
endif()
|
#
|
||||||
|
if(NOT count)
|
||||||
|
# Systems with /proc/cpuinfo:
|
||||||
|
set(cpuinfo_file /proc/cpuinfo)
|
||||||
|
if(EXISTS "${cpuinfo_file}")
|
||||||
|
file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$")
|
||||||
|
list(LENGTH procs count)
|
||||||
|
message("ProcessorCount: using cpuinfo '${cpuinfo_file}'")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue