[CMake] Any way to make/fake subdirectories depending on ExternalProject?
Alexander Neundorf
a.neundorf-work at gmx.net
Thu Jan 20 15:38:26 EST 2011
On Thursday 20 January 2011, Bill Hoffman wrote:
> On 1/20/2011 3:19 PM, kent williams wrote:
> > I kinda know the simple answer is 'no.' I hope there's a creative
> > *couch*sneaky*cough* way to do this.
> >
> > I'm trying to build CableSwig as a external project as part of ITK. I
> > have this working for a single-process build. It works in that case
> > because the ExternalProject_add happens textually before all the
> > add_subdirectory clauses at the bottom of ITK's top level
> > CMakeLists.txt file.
> >
> > If you run a parallel build, CableSwig gets downloaded and built in
> > parallel with subdirectories that need CableSwig to build, so the
> > compile fails, obviously.
> >
> > The problem is that subdirectories aren't targets, and can't depend on
> > CableSwig. What I need is a trick to fake out CMake such that it
> > guarantees the CableSwig subproject get built completely before moving
> > on into subdirectories.
> >
> > Any ideas? Or am I just abusing the very spirit of CMake?
>
> You are abusing the spirit of external project. To do this you would
> want to create one project that has two external projects:
>
> CableSwig
> ITK
>
> Then you can have ITK depend on CableSwig. You really can not mix
> external project with regular targets that expect that stuff to be built
> first.
Sure ?
I do that at work without problems.
The externalproject_add() creates targets using add_custom_target(), and I
make my actual library/executable targets depend on these targets using
add_dependencies().
Alex
More information about the CMake
mailing list