[Cmake-commits] CMake branch, next, updated. v2.8.4-1190-g01fb587

Brad King brad.king at kitware.com
Tue Mar 15 15:17:53 EDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  01fb58738bac8a6e910c4344cbf400c385045e0b (commit)
       via  4dd2ec2cb9dec683eafd3b303e04418c694675a3 (commit)
       via  6dd74d5a593e422dcc588ad8bc37382e06e8b256 (commit)
       via  c15983690f23ee9e39aced14cf74b55595d7d391 (commit)
       via  6259bc4222d7eb391a76ab5fd5e0460be238241e (commit)
       via  3430955d5f207232ed0ada83d3e6519ae5c908eb (commit)
       via  4d6418f68353f888e08b42b86ea9eb7e2e2781e3 (commit)
       via  9cc8ad99c9ace52283e293ca3542b3303ce361ee (commit)
       via  abbaa123aa0bc7c1d712a7cde018dfbdcccf0c43 (commit)
      from  d467a905862dd70f71d1a111464cf9ed39283d9e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=01fb58738bac8a6e910c4344cbf400c385045e0b
commit 01fb58738bac8a6e910c4344cbf400c385045e0b
Merge: d467a90 4dd2ec2
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Mar 15 15:17:51 2011 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Mar 15 15:17:51 2011 -0400

    Merge topic 'add-ProcessorCount-module' into next
    
    4dd2ec2 ProcessorCount: Test fails if count is 0 (#11302)
    6dd74d5 ProcessorCount: Add support for remaining platforms (#11302)
    c159836 ProcessorCount test: more output, do not fail. (#11302)
    6259bc4 Compare ProcessorCount to SystemInformation count. (#11302)
    3430955 Add ProcessorCount support for QNX via pidin. (#11302)
    4d6418f If getconf returns empty output, try cpuinfo. (#11302)
    9cc8ad9 Add correct module notice header.
    abbaa12 Add module ProcessorCount.cmake (#11302)


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4dd2ec2cb9dec683eafd3b303e04418c694675a3
commit 4dd2ec2cb9dec683eafd3b303e04418c694675a3
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Wed Mar 9 16:21:10 2011 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 15 15:07:31 2011 -0400

    ProcessorCount: Test fails if count is 0 (#11302)
    
    It also fails if count is not a decimal integer.

diff --git a/Tests/CMakeTests/ProcessorCountTest.cmake.in b/Tests/CMakeTests/ProcessorCountTest.cmake.in
index c653628..c5feb31 100644
--- a/Tests/CMakeTests/ProcessorCountTest.cmake.in
+++ b/Tests/CMakeTests/ProcessorCountTest.cmake.in
@@ -25,9 +25,11 @@ message("")
 # Evaluate possible error conditions:
 #
 set(err 0)
+set(fatal 0)
 
 if(processor_count EQUAL 0)
   set(err 1)
+  set(fatal 1)
   message("err 1")
   message("could not determine number of processors
 - Additional code for this platform needed in ProcessorCount.cmake?")
@@ -45,6 +47,7 @@ endif()
 
 if(NOT processor_count MATCHES "^[0-9]+$")
   set(err 3)
+  set(fatal 1)
   message("err 3")
   message("ProcessorCount function returned a non-integer")
   message("")
@@ -57,8 +60,6 @@ if(NOT system_info_processor_count MATCHES "^[0-9]+$")
   message("")
 endif()
 
-# TODO: Make this test fail again, once all the dev work is done...
-#
-if(err)
-#  message(FATAL_ERROR "err='${err}'")
+if(fatal)
+  message(FATAL_ERROR "processor_count='${processor_count}' - see previous test output for more details - it is likely more/different code is needed in ProcessorCount.cmake to fix this test failure - processor_count should be a non-zero positive integer (>=1) for all supported CMake platforms")
 endif()

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6dd74d5a593e422dcc588ad8bc37382e06e8b256
commit 6dd74d5a593e422dcc588ad8bc37382e06e8b256
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Wed Mar 9 14:06:58 2011 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 15 15:07:31 2011 -0400

    ProcessorCount: Add support for remaining platforms (#11302)
    
    Including AIX, cygwin, FreeBSD, HPUX, IRIX, OpenBSD and Sun.

diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake
index 5c38267..001f928 100644
--- a/Modules/ProcessorCount.cmake
+++ b/Modules/ProcessorCount.cmake
@@ -3,15 +3,27 @@
 #
 # Sets the variable named ${var} to the number of physical cores available on
 # the machine if the information can be determined. Otherwise it is set to 0.
-# Currently this functionality is only implemented for Windows, Mac OS X and
-# Unix systems providing getconf or the /proc/cpuinfo interface (e.g. Linux).
+# Currently this functionality is implemented for AIX, cygwin, FreeBSD, HPUX,
+# IRIX, Linux, Mac OS X, QNX, Sun and Windows.
+#
+# This function is guaranteed to return a positive integer (>=1) if it
+# succeeds. It returns 0 if there's a problem determining the processor count.
+#
+# Example use, in a ctest -S dashboard script:
+#
+#   include(ProcessorCount)
+#   ProcessorCount(N)
+#   if(NOT N EQUAL 0)
+#     set(CTEST_BUILD_FLAGS -j${N})
+#     set(ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${N})
+#   endif()
 
 # A more reliable way might be to compile a small C program that uses the CPUID
 # instruction, but that again requires compiler support or compiling assembler
 # code.
 
 #=============================================================================
-# Copyright 2010 Kitware, Inc.
+# Copyright 2010-2011 Kitware, Inc.
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file Copyright.txt for details.
@@ -30,43 +42,102 @@ function(ProcessorCount var)
   if(WIN32)
     # Windows:
     set(count "$ENV{NUMBER_OF_PROCESSORS}")
-    message("ProcessorCount: using environment variable")
-  elseif(APPLE)
-    # Mac:
+    message("ProcessorCount: WIN32, trying environment variable")
+  endif()
+
+  if(NOT count)
+    # Mac, FreeBSD, OpenBSD (systems with sysctl):
     find_program(ProcessorCount_cmd_sysctl sysctl
-      PATHS /usr/sbin)
+      PATHS /usr/sbin /sbin)
     if(ProcessorCount_cmd_sysctl)
       execute_process(COMMAND ${ProcessorCount_cmd_sysctl} -n hw.ncpu
         OUTPUT_STRIP_TRAILING_WHITESPACE
         OUTPUT_VARIABLE count)
-      message("ProcessorCount: using sysctl '${ProcessorCount_cmd_sysctl}'")
+      message("ProcessorCount: trying sysctl '${ProcessorCount_cmd_sysctl}'")
     endif()
-  else()
+  endif()
+
+  if(NOT count)
     # Linux (systems with getconf):
     find_program(ProcessorCount_cmd_getconf getconf)
     if(ProcessorCount_cmd_getconf)
       execute_process(COMMAND ${ProcessorCount_cmd_getconf} _NPROCESSORS_ONLN
         OUTPUT_STRIP_TRAILING_WHITESPACE
         OUTPUT_VARIABLE count)
-      message("ProcessorCount: using getconf '${ProcessorCount_cmd_getconf}'")
+      message("ProcessorCount: trying getconf '${ProcessorCount_cmd_getconf}'")
+    endif()
+  endif()
+
+  if(NOT count)
+    # HPUX (systems with machinfo):
+    find_program(ProcessorCount_cmd_machinfo machinfo
+      PATHS /usr/contrib/bin)
+    if(ProcessorCount_cmd_machinfo)
+      execute_process(COMMAND ${ProcessorCount_cmd_machinfo}
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+        OUTPUT_VARIABLE machinfo_output)
+      string(REGEX MATCHALL "Number of CPUs = ([0-9]+)" procs "${machinfo_output}")
+      set(count "${CMAKE_MATCH_1}")
+      message("ProcessorCount: trying machinfo '${ProcessorCount_cmd_machinfo}'")
+    endif()
+  endif()
+
+  if(NOT count)
+    # IRIX (systems with hinv):
+    find_program(ProcessorCount_cmd_hinv hinv
+      PATHS /sbin)
+    if(ProcessorCount_cmd_hinv)
+      execute_process(COMMAND ${ProcessorCount_cmd_hinv}
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+        OUTPUT_VARIABLE hinv_output)
+      string(REGEX MATCHALL "([0-9]+) .* Processors" procs "${hinv_output}")
+      set(count "${CMAKE_MATCH_1}")
+      message("ProcessorCount: trying hinv '${ProcessorCount_cmd_hinv}'")
     endif()
+  endif()
+
+  if(NOT count)
+    # AIX (systems with lsconf):
+    find_program(ProcessorCount_cmd_lsconf lsconf
+      PATHS /usr/sbin)
+    if(ProcessorCount_cmd_lsconf)
+      execute_process(COMMAND ${ProcessorCount_cmd_lsconf}
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+        OUTPUT_VARIABLE lsconf_output)
+      string(REGEX MATCHALL "Number Of Processors: ([0-9]+)" procs "${lsconf_output}")
+      set(count "${CMAKE_MATCH_1}")
+      message("ProcessorCount: trying lsconf '${ProcessorCount_cmd_lsconf}'")
+    endif()
+  endif()
+
+  if(NOT count)
+    # QNX (systems with pidin):
+    find_program(ProcessorCount_cmd_pidin pidin)
+    if(ProcessorCount_cmd_pidin)
+      execute_process(COMMAND ${ProcessorCount_cmd_pidin} info
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+        OUTPUT_VARIABLE pidin_output)
+      string(REGEX MATCHALL "Processor[0-9]+: " procs "${pidin_output}")
+      list(LENGTH procs count)
+      message("ProcessorCount: trying pidin '${ProcessorCount_cmd_pidin}'")
+    endif()
+  endif()
 
-    if(NOT count)
-      # QNX (systems with pidin):
-      find_program(ProcessorCount_cmd_pidin pidin)
-      if(ProcessorCount_cmd_pidin)
-        execute_process(COMMAND ${ProcessorCount_cmd_pidin} info
-          OUTPUT_STRIP_TRAILING_WHITESPACE
-          OUTPUT_VARIABLE pidin_output)
-        string(REGEX MATCHALL "Processor[0-9]+: " procs "${pidin_output}")
-        list(LENGTH procs count)
-        message("ProcessorCount: using pidin '${ProcessorCount_cmd_pidin}'")
-      endif()
+  if(NOT count)
+    # Sun (systems where uname -X emits "NumCPU" in its output):
+    find_program(ProcessorCount_cmd_uname uname)
+    if(ProcessorCount_cmd_uname)
+      execute_process(COMMAND ${ProcessorCount_cmd_uname} -X
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+        OUTPUT_VARIABLE uname_X_output)
+      string(REGEX MATCHALL "NumCPU = ([0-9]+)" procs "${uname_X_output}")
+      set(count "${CMAKE_MATCH_1}")
+      message("ProcessorCount: trying uname -X '${ProcessorCount_cmd_uname}'")
     endif()
   endif()
 
-  # Execute this code when there is no 'sysctl' or 'getconf' or 'pidin' or
-  # when previously executed methods return empty output:
+  # Execute this code when all previously attempted methods return empty
+  # output:
   #
   if(NOT count)
     # Systems with /proc/cpuinfo:
@@ -74,10 +145,18 @@ function(ProcessorCount var)
     if(EXISTS "${cpuinfo_file}")
       file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$")
       list(LENGTH procs count)
-      message("ProcessorCount: using cpuinfo '${cpuinfo_file}'")
+      message("ProcessorCount: trying cpuinfo '${cpuinfo_file}'")
     endif()
   endif()
 
+  # Since cygwin builds of CMake do not define WIN32 anymore, but they still
+  # run on Windows, and will still have this env var defined:
+  #
+  if(NOT count)
+    set(count "$ENV{NUMBER_OF_PROCESSORS}")
+    message("ProcessorCount: last fallback, trying environment variable")
+  endif()
+
   # Ensure an integer return (avoid inadvertently returning an empty string
   # or an error string)... If it's not a decimal integer, return 0:
   #

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c15983690f23ee9e39aced14cf74b55595d7d391
commit c15983690f23ee9e39aced14cf74b55595d7d391
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Wed Nov 10 10:23:50 2010 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 15 15:07:30 2011 -0400

    ProcessorCount test: more output, do not fail. (#11302)
    
    More dev work remains to be done here. Removing test failure
    condition until that dev work is complete, so it does not
    mask or hide other, more important failures, on the dashboard.

diff --git a/Tests/CMakeTests/ProcessorCountTest.cmake.in b/Tests/CMakeTests/ProcessorCountTest.cmake.in
index 6550973..c653628 100644
--- a/Tests/CMakeTests/ProcessorCountTest.cmake.in
+++ b/Tests/CMakeTests/ProcessorCountTest.cmake.in
@@ -9,39 +9,56 @@ execute_process(
   OUTPUT_VARIABLE out)
 string(REGEX REPLACE "(.*)GetNumberOfPhysicalCPU:.([0-9]*)(.*)" "\\2"
   system_info_processor_count "${out}")
+
 message("system_info_processor_count='${system_info_processor_count}'")
 
 if(system_info_processor_count EQUAL processor_count)
   message("processor count matches system information")
 endif()
 
+message("")
+message("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
+message("")
+message("out='${out}'")
+message("")
+
 # Evaluate possible error conditions:
 #
 set(err 0)
 
 if(processor_count EQUAL 0)
   set(err 1)
+  message("err 1")
   message("could not determine number of processors
 - Additional code for this platform needed in ProcessorCount.cmake?")
+  message("")
 endif()
 
 if(NOT system_info_processor_count EQUAL processor_count)
   set(err 2)
+  message("err 2")
   message("SystemInformation and ProcessorCount.cmake disagree:\n"
     "processor_count='${processor_count}'\n"
     "SystemInformation processor_count='${system_info_processor_count}'")
+  message("")
 endif()
 
 if(NOT processor_count MATCHES "^[0-9]+$")
   set(err 3)
+  message("err 3")
   message("ProcessorCount function returned a non-integer")
+  message("")
 endif()
 
 if(NOT system_info_processor_count MATCHES "^[0-9]+$")
   set(err 4)
+  message("err 4")
   message("SystemInformation ProcessorCount function returned a non-integer")
+  message("")
 endif()
 
+# TODO: Make this test fail again, once all the dev work is done...
+#
 if(err)
-  message(FATAL_ERROR "err='${err}'")
+#  message(FATAL_ERROR "err='${err}'")
 endif()

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6259bc4222d7eb391a76ab5fd5e0460be238241e
commit 6259bc4222d7eb391a76ab5fd5e0460be238241e
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Tue Nov 9 14:29:52 2010 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 15 15:07:30 2011 -0400

    Compare ProcessorCount to SystemInformation count. (#11302)
    
    Maximize output to gather data on the dashboards.
    Only FATAL_ERROR out once at the bottom if an error
    occurred earlier.

diff --git a/Tests/CMakeTests/ProcessorCountTest.cmake.in b/Tests/CMakeTests/ProcessorCountTest.cmake.in
index ac7a1da..6550973 100644
--- a/Tests/CMakeTests/ProcessorCountTest.cmake.in
+++ b/Tests/CMakeTests/ProcessorCountTest.cmake.in
@@ -3,11 +3,45 @@ include(ProcessorCount)
 ProcessorCount(processor_count)
 message("processor_count='${processor_count}'")
 
-if(NOT processor_count MATCHES "^[0-9]+$")
-  message(FATAL_ERROR "ProcessorCount function returned a non-integer")
+execute_process(
+  COMMAND "@CMAKE_BINARY_DIR@/Source/kwsys/$ENV{CMAKE_CONFIG_TYPE}/cmsysTestsCxx"
+  testSystemInformation
+  OUTPUT_VARIABLE out)
+string(REGEX REPLACE "(.*)GetNumberOfPhysicalCPU:.([0-9]*)(.*)" "\\2"
+  system_info_processor_count "${out}")
+message("system_info_processor_count='${system_info_processor_count}'")
+
+if(system_info_processor_count EQUAL processor_count)
+  message("processor count matches system information")
 endif()
 
+# Evaluate possible error conditions:
+#
+set(err 0)
+
 if(processor_count EQUAL 0)
-  message(FATAL_ERROR "could not determine number of processors
+  set(err 1)
+  message("could not determine number of processors
 - Additional code for this platform needed in ProcessorCount.cmake?")
 endif()
+
+if(NOT system_info_processor_count EQUAL processor_count)
+  set(err 2)
+  message("SystemInformation and ProcessorCount.cmake disagree:\n"
+    "processor_count='${processor_count}'\n"
+    "SystemInformation processor_count='${system_info_processor_count}'")
+endif()
+
+if(NOT processor_count MATCHES "^[0-9]+$")
+  set(err 3)
+  message("ProcessorCount function returned a non-integer")
+endif()
+
+if(NOT system_info_processor_count MATCHES "^[0-9]+$")
+  set(err 4)
+  message("SystemInformation ProcessorCount function returned a non-integer")
+endif()
+
+if(err)
+  message(FATAL_ERROR "err='${err}'")
+endif()

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3430955d5f207232ed0ada83d3e6519ae5c908eb
commit 3430955d5f207232ed0ada83d3e6519ae5c908eb
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Mon Nov 8 09:37:04 2010 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 15 15:07:30 2011 -0400

    Add ProcessorCount support for QNX via pidin. (#11302)
    
    Thanks to Rolf Eike Beer <eike at sf-mail.de> for the code snippet
    parsing the pidin output.

diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake
index 5ccfbff..5c38267 100644
--- a/Modules/ProcessorCount.cmake
+++ b/Modules/ProcessorCount.cmake
@@ -42,7 +42,7 @@ function(ProcessorCount var)
       message("ProcessorCount: using sysctl '${ProcessorCount_cmd_sysctl}'")
     endif()
   else()
-    # Linux (and other systems with getconf):
+    # Linux (systems with getconf):
     find_program(ProcessorCount_cmd_getconf getconf)
     if(ProcessorCount_cmd_getconf)
       execute_process(COMMAND ${ProcessorCount_cmd_getconf} _NPROCESSORS_ONLN
@@ -50,9 +50,22 @@ function(ProcessorCount var)
         OUTPUT_VARIABLE count)
       message("ProcessorCount: using getconf '${ProcessorCount_cmd_getconf}'")
     endif()
+
+    if(NOT count)
+      # QNX (systems with pidin):
+      find_program(ProcessorCount_cmd_pidin pidin)
+      if(ProcessorCount_cmd_pidin)
+        execute_process(COMMAND ${ProcessorCount_cmd_pidin} info
+          OUTPUT_STRIP_TRAILING_WHITESPACE
+          OUTPUT_VARIABLE pidin_output)
+        string(REGEX MATCHALL "Processor[0-9]+: " procs "${pidin_output}")
+        list(LENGTH procs count)
+        message("ProcessorCount: using pidin '${ProcessorCount_cmd_pidin}'")
+      endif()
+    endif()
   endif()
 
-  # Execute this code when there is no 'sysctl' or 'getconf' or
+  # Execute this code when there is no 'sysctl' or 'getconf' or 'pidin' or
   # when previously executed methods return empty output:
   #
   if(NOT count)
@@ -65,5 +78,12 @@ function(ProcessorCount var)
     endif()
   endif()
 
+  # Ensure an integer return (avoid inadvertently returning an empty string
+  # or an error string)... If it's not a decimal integer, return 0:
+  #
+  if(NOT count MATCHES "^[0-9]+$")
+    set(count 0)
+  endif()
+
   set(${var} ${count} PARENT_SCOPE)
 endfunction()
diff --git a/Tests/CMakeTests/ProcessorCountTest.cmake.in b/Tests/CMakeTests/ProcessorCountTest.cmake.in
index 0815fd8..ac7a1da 100644
--- a/Tests/CMakeTests/ProcessorCountTest.cmake.in
+++ b/Tests/CMakeTests/ProcessorCountTest.cmake.in
@@ -3,7 +3,11 @@ include(ProcessorCount)
 ProcessorCount(processor_count)
 message("processor_count='${processor_count}'")
 
+if(NOT processor_count MATCHES "^[0-9]+$")
+  message(FATAL_ERROR "ProcessorCount function returned a non-integer")
+endif()
+
 if(processor_count EQUAL 0)
   message(FATAL_ERROR "could not determine number of processors
-- Additional code needed in ProcessorCount.cmake?")
+- Additional code for this platform needed in ProcessorCount.cmake?")
 endif()

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4d6418f68353f888e08b42b86ea9eb7e2e2781e3
commit 4d6418f68353f888e08b42b86ea9eb7e2e2781e3
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Fri Nov 5 15:57:21 2010 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 15 15:07:30 2011 -0400

    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.

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()
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9cc8ad99c9ace52283e293ca3542b3303ce361ee
commit 9cc8ad99c9ace52283e293ca3542b3303ce361ee
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Fri Nov 5 09:21:51 2010 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 15 15:07:30 2011 -0400

    Add correct module notice header.
    
    Fixes failing ModuleNotices test.

diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake
index e4aea19..b46a012 100644
--- a/Modules/ProcessorCount.cmake
+++ b/Modules/ProcessorCount.cmake
@@ -11,7 +11,7 @@
 # code.
 
 #=============================================================================
-# Copyright 2002-2009 Kitware, Inc.
+# Copyright 2010 Kitware, Inc.
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file Copyright.txt for details.
@@ -20,7 +20,7 @@
 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 # See the License for more information.
 #=============================================================================
-# (To distributed this file outside of CMake, substitute the full
+# (To distribute this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
 function(ProcessorCount var)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=abbaa123aa0bc7c1d712a7cde018dfbdcccf0c43
commit abbaa123aa0bc7c1d712a7cde018dfbdcccf0c43
Author:     Michael Wild <themiwi at users.sourceforge.net>
AuthorDate: Fri Oct 8 09:16:04 2010 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 15 15:07:30 2011 -0400

    Add module ProcessorCount.cmake (#11302)
    
    Credit goes to David Cole ( http://www.kitware.com/blog/home/post/63 ).
    
    Also add a script-based test of the new module.
    
    Signed-off-by: Michael Wild <themiwi at users.sourceforge.net>

diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake
new file mode 100644
index 0000000..e4aea19
--- /dev/null
+++ b/Modules/ProcessorCount.cmake
@@ -0,0 +1,60 @@
+# - ProcessorCount(var)
+# Determine the number of processors/cores and save value in ${var}
+#
+# Sets the variable named ${var} to the number of physical cores available on
+# the machine if the information can be determined. Otherwise it is set to 0.
+# Currently this functionality is only implemented for Windows, Mac OS X and
+# Unix systems providing getconf or the /proc/cpuinfo interface (e.g. Linux).
+
+# A more reliable way might be to compile a small C program that uses the CPUID
+# instruction, but that again requires compiler support or compiling assembler
+# code.
+
+#=============================================================================
+# Copyright 2002-2009 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distributed this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+function(ProcessorCount var)
+  # Unknown:
+  set(count 0)
+
+  if(WIN32)
+    # Windows:
+    set(count "$ENV{NUMBER_OF_PROCESSORS}")
+  elseif(APPLE)
+    # Mac:
+    find_program(ProcessorCount_cmd_sysctl sysctl
+      PATHS /usr/sbin)
+    if(ProcessorCount_cmd_sysctl)
+      execute_process(COMMAND ${ProcessorCount_cmd_sysctl} -n hw.ncpu
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+        OUTPUT_VARIABLE count)
+    endif()
+  else()
+    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()
+    endif()
+  endif()
+
+  set(${var} ${count} PARENT_SCOPE)
+endfunction()
diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt
index cceef3b..5cb50c9 100644
--- a/Tests/CMakeTests/CMakeLists.txt
+++ b/Tests/CMakeTests/CMakeLists.txt
@@ -27,6 +27,7 @@ AddCMakeTest(String "")
 AddCMakeTest(Math "")
 AddCMakeTest(CMakeMinimumRequired "")
 AddCMakeTest(CompilerIdVendor "")
+AddCMakeTest(ProcessorCount "")
 
 AddCMakeTest(FileDownload "")
 set_property(TEST CMake.FileDownload PROPERTY
diff --git a/Tests/CMakeTests/ProcessorCountTest.cmake.in b/Tests/CMakeTests/ProcessorCountTest.cmake.in
new file mode 100644
index 0000000..0815fd8
--- /dev/null
+++ b/Tests/CMakeTests/ProcessorCountTest.cmake.in
@@ -0,0 +1,9 @@
+include(ProcessorCount)
+
+ProcessorCount(processor_count)
+message("processor_count='${processor_count}'")
+
+if(processor_count EQUAL 0)
+  message(FATAL_ERROR "could not determine number of processors
+- Additional code needed in ProcessorCount.cmake?")
+endif()

-----------------------------------------------------------------------

Summary of changes:
 Modules/ProcessorCount.cmake                 |  168 ++++++++++++++++++++++++++
 Tests/CMakeTests/CMakeLists.txt              |    1 +
 Tests/CMakeTests/ProcessorCountTest.cmake.in |   65 ++++++++++
 3 files changed, 234 insertions(+), 0 deletions(-)
 create mode 100644 Modules/ProcessorCount.cmake
 create mode 100644 Tests/CMakeTests/ProcessorCountTest.cmake.in


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list