summaryrefslogtreecommitdiffstats
path: root/Modules/ProcessorCount.cmake
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2010-11-05 19:57:21 (GMT)
committerBrad King <brad.king@kitware.com>2011-03-15 19:07:30 (GMT)
commit4d6418f68353f888e08b42b86ea9eb7e2e2781e3 (patch)
treeb55075a02727e686979cde77caf5c079252c4b02 /Modules/ProcessorCount.cmake
parent9cc8ad99c9ace52283e293ca3542b3303ce361ee (diff)
downloadCMake-4d6418f68353f888e08b42b86ea9eb7e2e2781e3.zip
CMake-4d6418f68353f888e08b42b86ea9eb7e2e2781e3.tar.gz
CMake-4d6418f68353f888e08b42b86ea9eb7e2e2781e3.tar.bz2
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.
Diffstat (limited to 'Modules/ProcessorCount.cmake')
-rw-r--r--Modules/ProcessorCount.cmake25
1 files changed, 17 insertions, 8 deletions
diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake
index b46a012..5ccfbff 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()