From 4d6418f68353f888e08b42b86ea9eb7e2e2781e3 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 5 Nov 2010 15:57:21 -0400 Subject: 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. --- Modules/ProcessorCount.cmake | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'Modules/ProcessorCount.cmake') diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake index b46a0122f1..5ccfbffedb 100644 --- a/Modules/ProcessorCount.cmake +++ b/Modules/ProcessorCount.cmake @@ -30,6 +30,7 @@ function(ProcessorCount var) if(WIN32) # Windows: set(count "$ENV{NUMBER_OF_PROCESSORS}") + message("ProcessorCount: using environment variable") elseif(APPLE) # Mac: find_program(ProcessorCount_cmd_sysctl sysctl @@ -38,21 +39,29 @@ function(ProcessorCount var) execute_process(COMMAND ${ProcessorCount_cmd_sysctl} -n hw.ncpu OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE count) + message("ProcessorCount: using sysctl '${ProcessorCount_cmd_sysctl}'") endif() else() + # Linux (and other systems with getconf): find_program(ProcessorCount_cmd_getconf getconf) if(ProcessorCount_cmd_getconf) - # Linux and other systems with getconf: execute_process(COMMAND ${ProcessorCount_cmd_getconf} _NPROCESSORS_ONLN OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE count) - else() - # Linux and other 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) - endif() + message("ProcessorCount: using getconf '${ProcessorCount_cmd_getconf}'") + endif() + endif() + + # Execute this code when there is no 'sysctl' or 'getconf' or + # when previously executed methods return empty output: + # + 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() -- cgit v1.2.1