[CMake] Newie's question: Multiple applications with one common kernel

Tyler Roscoe tyler at cryptio.net
Tue Dec 8 11:28:35 EST 2009


On Tue, Dec 08, 2009 at 09:27:42AM +0100, Matthias Moeller wrote:
> Thank you for your help. Actually, I need it in the opposite way, that
> is, each application (parent) adds the kernel directory. In the kernel's
> CMakeLists.txt file a list of source files is generated and this list
> should be passed to the top directory (i.e. the application).

The set (... PARENT_SCOPE) calls would be in the kernel CMakeLists so I
don't know what you're saying here.

> > Another common approach to this sort of setup is to deal with all the
> > common kernel code in a top-level CMakeLists and then have that
> > top-level CMakeLists do the add_subdirectory() calls into each appX subdirectory.
> >   
> Wouldn't this mean that cmake always works on all applications each time
> it is called?

Yes. For most projects this is desirable.

But you've gotten some better advice in this thread: make kernel a
library and don't add the same CMakeLists multiple times. I guard my
add_subdirectory() calls with if (NOT TARGET some_buildable) but YMMV
since I don't know all the details of how your project is put together.

tyler


More information about the CMake mailing list