[cmake-developers] Ninja and add_subdirectory EXCLUDE_FROM_ALL

Brad King brad.king at kitware.com
Tue Mar 15 13:58:41 EDT 2016


On 03/14/2016 05:04 AM, Charles Huet wrote:
> I modified my patch a bit to use C++98 only, and try to stick
> to the coding conventions.

Thanks.  While reviewing the logic I realized my suggestion to include
all targets was not quite consistent with my observation that this matches
the Makefile generator "cd dir; make" behavior.  The latter still excludes
targets that have the EXCLUDE_FROM_ALL target property, as seen by this
code in cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2:

>  if((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) &&

This is per-target and is different than add_subdirectory EXCLUDE_FROM_ALL.
We should still honor this.  Such targets are meant to be built only upon
explicit request.  Also later in WriteDirectoryRule2 is this section:

> // The directory-level rule should depend on the directory-level
> // rules of the subdirectories.

The rules we're generating here could work like that too.  Each one
depends on all the targets defined in its own directory and on the
directory-level target for subdirectories.  The goal is to match the
Makefile generator behavior for target selection in each directory.
I don't think matching subdirectory name prefixes is needed for that.

> These targets are prefixed with "path/" in order to set them apart of
> normal CMake targets.

I think the names can instead use a "/all" suffix e.g. "sub/dir/all".
This would be consistent with the "ninja all" one can now do at the
top.

Thanks,
-Brad



More information about the cmake-developers mailing list