[Cmake-commits] CMake branch, next, updated. v2.8.4-1124-g6c10df2

David Cole david.cole at kitware.com
Wed Mar 9 16:43:06 EST 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  6c10df2ed2c53263babf53182843302172a66f52 (commit)
       via  5dfb6f708fff25e7e38d95d964c9c2c7a20b9135 (commit)
       via  39a254f6ddbb0f6bbcd00d8fb53738146773bf50 (commit)
      from  6bead336227dc2eb3e9cb9bb622c1ea333a777ae (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=6c10df2ed2c53263babf53182843302172a66f52
commit 6c10df2ed2c53263babf53182843302172a66f52
Merge: 6bead33 5dfb6f7
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Wed Mar 9 16:43:04 2011 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Mar 9 16:43:04 2011 -0500

    Merge topic 'add-ProcessorCount-module' into next
    
    5dfb6f7 ProcessorCount: Test fails if count is 0 (#11302)
    39a254f ProcessorCount: Add support for remaining platforms (#11302)


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5dfb6f708fff25e7e38d95d964c9c2c7a20b9135
commit 5dfb6f708fff25e7e38d95d964c9c2c7a20b9135
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Wed Mar 9 16:21:10 2011 -0500
Commit:     David Cole <david.cole at kitware.com>
CommitDate: Wed Mar 9 16:36:45 2011 -0500

    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=39a254f6ddbb0f6bbcd00d8fb53738146773bf50
commit 39a254f6ddbb0f6bbcd00d8fb53738146773bf50
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Wed Mar 9 14:06:58 2011 -0500
Commit:     David Cole <david.cole at kitware.com>
CommitDate: Wed Mar 9 16:36:33 2011 -0500

    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:
   #

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

Summary of changes:
 Modules/ProcessorCount.cmake                 |  127 +++++++++++++++++++++-----
 Tests/CMakeTests/ProcessorCountTest.cmake.in |    9 +-
 2 files changed, 108 insertions(+), 28 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list