Thanks!<br><br><div class="gmail_quote">On Thu, Oct 7, 2010 at 6:08 PM, Mark Moll <span dir="ltr">&lt;<a href="mailto:mmoll@rice.edu">mmoll@rice.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
On OS X, this command might be easier / faster:<br>
<br>
sysctl -n hw.ncpu<br>
<div><div></div><div class="h5"><br>
On Oct 7, 2010, at 3:50 PM, David Cole wrote:<br>
<br>
&gt; I just posted a short blog article demonstrating how to figure out the number of processors available for a &quot;make -j&quot; or a scripted ctest_build call (with the &quot;Unix Makefiles&quot; generator) on Linux, Mac and Windows. Please let me know if you have any ideas for how it might be improved or extended.<br>

&gt;<br>
&gt; <a href="http://www.kitware.com/blog/home/post/63" target="_blank">http://www.kitware.com/blog/home/post/63</a><br>
&gt;<br>
&gt;<br>
&gt; Cheers,<br>
&gt; David<br>
&gt;<br>
&gt;<br>
&gt; Blog text copied here, too, for search-ability on the mailing list archives:<br>
&gt; ==============================================================================<br>
&gt; At the end of this script snippet, the CMake variable PROCESSOR_COUNT has a value appropriate for passing to make&#39;s -j for parallel builds.<br>
&gt;<br>
&gt; When used in a ctest -S script, you can call...<br>
&gt;<br>
&gt; if(PROCESSOR_COUNT)<br>
&gt;   set(CTEST_BUILD_FLAGS &quot;-j${PROCESSOR_COUNT}&quot;)<br>
&gt; endif()<br>
&gt;<br>
&gt; ...to enable parallel builds with &quot;Unix Makefiles&quot; and the ctest_build command.<br>
&gt;<br>
&gt;<br>
&gt; Here&#39;s the snippet:<br>
&gt; if(NOT DEFINED PROCESSOR_COUNT)<br>
&gt;   # Unknown:<br>
&gt;   set(PROCESSOR_COUNT 0)<br>
&gt;<br>
&gt;   # Linux:<br>
&gt;   set(cpuinfo_file &quot;/proc/cpuinfo&quot;)<br>
&gt;   if(EXISTS &quot;${cpuinfo_file}&quot;)<br>
&gt;     file(STRINGS &quot;${cpuinfo_file}&quot; procs REGEX &quot;^processor.: [0-9]+$&quot;)<br>
&gt;     list(LENGTH procs PROCESSOR_COUNT)<br>
&gt;   endif()<br>
&gt;<br>
&gt;   # Mac:<br>
&gt;   if(APPLE)<br>
&gt;     find_program(cmd_sys_pro &quot;system_profiler&quot;)<br>
&gt;     if(cmd_sys_pro)<br>
&gt;       execute_process(COMMAND ${cmd_sys_pro} OUTPUT_VARIABLE info)<br>
&gt;       string(REGEX REPLACE &quot;^.*Total Number Of Cores: ([0-9]+).*$&quot; &quot;\\1&quot;<br>
&gt;         PROCESSOR_COUNT &quot;${info}&quot;)<br>
&gt;     endif()<br>
&gt;   endif()<br>
&gt;<br>
&gt;   # Windows:<br>
&gt;   if(WIN32)<br>
&gt;     set(PROCESSOR_COUNT &quot;$ENV{NUMBER_OF_PROCESSORS}&quot;)<br>
&gt;   endif()<br>
&gt; endif()<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;<br>
&gt; Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;<br>
&gt; Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
&gt;<br>
&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; <a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
<br>
--<br>
<font color="#888888">Mark Moll<br>
<br>
<br>
<br>
</font></blockquote></div><br>