[Cmake-commits] CMake branch, next, updated. v2.8.3-551-g20ae1b5

David Cole david.cole at kitware.com
Mon Nov 8 09:44:25 EST 2010


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  20ae1b5b8908f183b389361e76efc693af9af03e (commit)
       via  680ca4baab85cbc1be98bcfd81b7e4402ffa8d84 (commit)
      from  25be1b070297dea7def03bf95009c752426c54ab (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=20ae1b5b8908f183b389361e76efc693af9af03e
commit 20ae1b5b8908f183b389361e76efc693af9af03e
Merge: 25be1b0 680ca4b
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Mon Nov 8 09:44:24 2010 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Nov 8 09:44:24 2010 -0500

    Merge topic 'add-ProcessorCount-module' into next
    
    680ca4b Add ProcessorCount support for QNX via pidin. (#11302)


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=680ca4baab85cbc1be98bcfd81b7e4402ffa8d84
commit 680ca4baab85cbc1be98bcfd81b7e4402ffa8d84
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Mon Nov 8 09:37:04 2010 -0500
Commit:     David Cole <david.cole at kitware.com>
CommitDate: Mon Nov 8 09:37:04 2010 -0500

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

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

Summary of changes:
 Modules/ProcessorCount.cmake                 |   24 ++++++++++++++++++++++--
 Tests/CMakeTests/ProcessorCountTest.cmake.in |    6 +++++-
 2 files changed, 27 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list