Thanks!<br><br><div class="gmail_quote">On Thu, Oct 7, 2010 at 6:08 PM, Mark Moll <span dir="ltr"><<a href="mailto:mmoll@rice.edu">mmoll@rice.edu</a>></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>
> I just posted a short blog article demonstrating how to figure out the number of processors available for a "make -j" or a scripted ctest_build call (with the "Unix Makefiles" generator) on Linux, Mac and Windows. Please let me know if you have any ideas for how it might be improved or extended.<br>
><br>
> <a href="http://www.kitware.com/blog/home/post/63" target="_blank">http://www.kitware.com/blog/home/post/63</a><br>
><br>
><br>
> Cheers,<br>
> David<br>
><br>
><br>
> Blog text copied here, too, for search-ability on the mailing list archives:<br>
> ==============================================================================<br>
> At the end of this script snippet, the CMake variable PROCESSOR_COUNT has a value appropriate for passing to make's -j for parallel builds.<br>
><br>
> When used in a ctest -S script, you can call...<br>
><br>
> if(PROCESSOR_COUNT)<br>
> set(CTEST_BUILD_FLAGS "-j${PROCESSOR_COUNT}")<br>
> endif()<br>
><br>
> ...to enable parallel builds with "Unix Makefiles" and the ctest_build command.<br>
><br>
><br>
> Here's the snippet:<br>
> if(NOT DEFINED PROCESSOR_COUNT)<br>
> # Unknown:<br>
> set(PROCESSOR_COUNT 0)<br>
><br>
> # Linux:<br>
> set(cpuinfo_file "/proc/cpuinfo")<br>
> if(EXISTS "${cpuinfo_file}")<br>
> file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$")<br>
> list(LENGTH procs PROCESSOR_COUNT)<br>
> endif()<br>
><br>
> # Mac:<br>
> if(APPLE)<br>
> find_program(cmd_sys_pro "system_profiler")<br>
> if(cmd_sys_pro)<br>
> execute_process(COMMAND ${cmd_sys_pro} OUTPUT_VARIABLE info)<br>
> string(REGEX REPLACE "^.*Total Number Of Cores: ([0-9]+).*$" "\\1"<br>
> PROCESSOR_COUNT "${info}")<br>
> endif()<br>
> endif()<br>
><br>
> # Windows:<br>
> if(WIN32)<br>
> set(PROCESSOR_COUNT "$ENV{NUMBER_OF_PROCESSORS}")<br>
> endif()<br>
> endif()<br>
><br>
</div></div>> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> 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>
><br>
> 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>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <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>