[CMake] Building CMake in parallel problem

Brad King brad.king at kitware.com
Fri Apr 9 11:32:57 EDT 2010


Michael Wild wrote:
> the dependency should prevent anything bad from happening.

Dependencies in the actual "Makefile" are not meaningful.  It is
a front-end that launches a make process for driving the build
through "CMakeFiles/Makefile2" which has the real inter-target
dependencies. Each target in the top-level "Makefile" just runs
Makefile2 with that target.  This is the reason that specifying
multiple targets on one "make" line does not work.  The top-
and subdir-level Makefiles need some redesign to solve this
problem.

> I think the problem here is the following snipped (tabs expanded for posting here):
> 
>   # Special rule for the target install
>   install: cmake
>   install: preinstall
>           @echo "Install the project..."
>           bin/cmake -P cmake_install.cmake
>   .PHONY : install
> 

Yes, the "install: cmake" line causes "make install" to be as if
the user ran "make install cmake", which does not work in parallel
for the reason described above.

This problem shouldn't happen with any project except CMake itself.
The reason is that CMake has a special-case for the installation
rule.  It uses the just-built bin/cmake to run the install script
instead of the CMake that configured the build tree.  The internal
logic that generates the install command line treats it just like
any other custom command, which automatically makes a target that
contains a custom rule depend on the target that provides the
executable the custom rule runs.

> If I remove the dependency "install: cmake" everything works fine

We would need additional special-case logic to remove the dependency
"install: cmake".

-Brad



More information about the CMake mailing list