[CMake] 2.6.1 RC12 add_subdirectory(xxx EXCLUDE_FROM_ALL) problems

Brad King brad.king at kitware.com
Thu Aug 7 15:22:49 EDT 2008


temp wrote:
> Bill Hoffman wrote:
>> Ross, Thomas wrote:
>> That is a new feature of 2.6.X, any library that is linked into 
>> something is included, even if it is excluded from all.  The 
>> sub-projects are also now complete.  The reasoning is that you could get 
>> incomplete builds if we don't do this.
> 
> While I do understand the reason behind that change, the 'EXCLUDE_FROM_ALL'
> is a bit misleading now since it doesn't do what it says it does (btw. the
> online documentation doesn't reflect the changed behavior either).

The documentation says "this subdirectory will not be included in build
by default".  Even after this change the targets in the subdirectory are
not included unless something that *is* included links to them.  The
documentation also says that this feature is meant for use by examples,
where the targets in the subdirectory depend on targets in the main
project, not the other way around.  Excluding the 3rd party library
targets from the build is basically dropping dependencies.  Many people
considered the old behavior a bug, which is why this change was made.

The documentation should be updated to clarify the current behavior, but
I don't think it should be changed.  If you update one of your third
party libraries then the project will fail to build unless the user
first builds the subproject by hand.  If you don't want the dependencies
then the third-party libs should not be part of the same CMake project.
   Instead the users should build and install the third-party libraries
as their own project, and then point the main project at them.

You can use packaging and export/import features documented here to
separate the projects but easily refer to the third-party libraries with
logical target names:

  http://www.cmake.org/Wiki/CMake_2.6_Notes

> Is there any chance to get the old behavior back? With a new policy maybe?

The policy mechanism is meant for cases where the existing project
actually *fails* to build.  In your case the project still builds, just
with some extra dependencies.

-Brad


More information about the CMake mailing list