From 5ba04bba44c18f5b04c16a020cce4896a6ccc6f5 Mon Sep 17 00:00:00 2001 From: Duy-Nguyen Ta Date: Wed, 27 Apr 2016 01:13:53 -0400 Subject: [PATCH] Fix number processors on mac for parallelizing ctest system_profiler takes too long on my machine and the string regex replace doesn't work correctly (cmake 3.3.1) --- cmake/GtsamTesting.cmake | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cmake/GtsamTesting.cmake b/cmake/GtsamTesting.cmake index 25d091e50..5e2c84b60 100644 --- a/cmake/GtsamTesting.cmake +++ b/cmake/GtsamTesting.cmake @@ -112,11 +112,10 @@ if(NOT DEFINED PROCESSOR_COUNT) # Mac: if(APPLE) - find_program(cmd_sys_pro "system_profiler") - if(cmd_sys_pro) - execute_process(COMMAND ${cmd_sys_pro} OUTPUT_VARIABLE info) - string(REGEX REPLACE "^.*Total Number Of Cores: ([0-9]+).*$" "\\1" - PROCESSOR_COUNT "${info}") + find_program(cmd_sysctl "sysctl") + if(cmd_sysctl) + execute_process(COMMAND ${cmd_sysctl} -n hw.ncpu OUTPUT_VARIABLE info) + string(STRIP ${info} PROCESSOR_COUNT) endif() endif()