[CMake] Executable and library dependencies

Tyler Roscoe tyler at cryptio.net
Tue May 5 11:28:12 EDT 2009


On Tue, May 05, 2009 at 03:05:31PM +0200, Andreas Pakulat wrote:
> On 05.05.09 14:29:03, eblotml at free.fr wrote:
> > I use a top CMakeLists.txt which looks like:
> >   PROJECT (proj)
> >   SET (subprojects mylib myapp)
> >   FOREACH (prj ${subprojects})
> >     ADD_SUBDIRECTORY (${prj} ${prj})
> >   ENDFOREACH (prj)

Doing in-source builds is generally considered a bad idea. Instead do
something like:

    ADD_SUBDIRECTORY (${prj} ${prj}/build)

> > What would be the best way to add a dependency to solve this issue?
> > In other word, I'll go for ADD_DEPENDENCY(myapp x), but I'm not sure how to define 'x' here.
> 
> This would be the right way and "x" should simply be "mylib" in your
> example, which creates a dependency between the myapp target and the mylib
> target in your project.

+1.

tyler


More information about the CMake mailing list