[cmake-developers] Compile targets affected by changeset

Brad King brad.king at kitware.com
Mon May 22 14:37:26 EDT 2017


On 05/18/2017 05:48 PM, Robert Patterson via cmake-developers wrote:
>  we must have a preprocessing step (makedepend or gcc -M) 

Where in your example(s) does this step take place?

> 'make' has a limitation where if 'make target1 target2 target3' is invoked,
> target1, target2, and target3 are built serially, not in parallel.

I don't think that is a limitation of `make`, but rather of CMake's
generated makefiles.  The `Makefile` files in the build tree work
internally in such a way that only one target can be built from the
command-line at a time, so they contain a `.NOTPARALLEL` mark to tell
GNU make to act serially.

> To get around this, we decided that the best option was to dynamically
> create a new [cmake] target which depends on the affected targets.

Another approach is to use `CMakeFiles/Makefile2` directly:

  make cmake_check_build_system
  make -j -f CMakeFiles/Makefile2 dir1/tgt1.dir/all dir2/tgt2.dir/all dir3/tgt3.dir/all

This will build all of the targets in parallel safely.  The difficulty
will be in constructing the paths to these per-target `/all` make targets.
Maybe some changes to the Unix Makefiles generator could relieve that.

Or, we could just expose an alternative entry point in the Makefile files.
It is likely not too hard to get the following to work:

  make -j cmake_targets_variable TARGETS="tgt1 tgt2 tgt3"

-Brad



More information about the cmake-developers mailing list