[CMake] Deferred CPU count variable in CMake for Makefile generator?

Clifford Yapp cliffyapp at gmail.com
Fri Sep 9 10:49:49 EDT 2011


Per the customizing Makefile email, I'd like to ask if a mechanism exists or
could be implemented to allow CMakeLists.txt files to define commands that
pass a CPU count to subcommands - e.g. something that allows the generators
to take a syntax along the lines of:

ADD_CUSTOM_TARGET(subbuild
     COMMAND ${CMAKE_COMMAND} --build ${TARGET_DIR} -- -j${PARENT_CPUS}
)

and generate makefiles that will take "make JOBS=3 subbuild" and have cmake
in turn launch "make -j3" in the target directory - in other words,
${PARENT_CPUS} would be a cue for the backend generator to add logic to pass
down parallel make settings to the subbuild command.  (Ideally -j3 could be
passed down, but it looks like make itself precludes that so some other
variable would have to be used at the top level.)

Any insight is appreciated - this one has got me pretty stumped as to the
"right way" to achieve this effect.

Thanks,
CY
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110909/16683bb3/attachment.htm>


More information about the CMake mailing list