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

Michael Hufer michael.hufer at swissrisk.com
Tue Dec 8 04:25:14 EST 2009


Hi,
This looks to me as if the "kernel" is a good candidate for a (internal) 
static (or even shared) library that is used by the "applications"

	Micha.

On Monday 07 December 2009 18:25:42 Tyler Roscoe wrote:
> On Mon, Dec 07, 2009 at 05:53:37PM +0100, Matthias Moeller wrote:
> > Our project has the following structure:
> >
> > root/applications (Applications by different users)
> >      applications/app1
> >      applications/app2
> >      applications/...
> >
> > root/kernel (common kernel source files)
> >
> > root/libraries (external libraries)
> >
> > Each application has some source files and uses the common source files
> > from the kernel directory which is *not* a subdirectory. In a first
> > attempt, I wrote one CMakeLists.txt file on the kernel directory which
> > has a list of all kernel source files. Each application/appX directory
> > has its own CMakeLists.txt file which includes the kernel sources via:
> >
> > ADD_SUBDIRECTORY (${APPX_SOURCE_DIR}/../..
> > ${CMAKE_CURRENT_BINARY_DIR}/kernel)
> >
> > Unfortunately, the variables defined in the kernel's CMakeLists.txt file
> > are not available from within the application's CMakeLists.txt file.
> 
> When you do add_subdirectory(), you create a new scope. The variables in
> your kernel CMakeLists are set in that scope by default. Take a look at
> the PARENT_SCOPE argument to set() to deal with this.
> 
> 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.
> 
> tyler
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
>  http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at:
>  http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
> 

-- 
Michael Hufer
Software Developer
--------------------------------
Swissrisk Financial Systems

www.swissrisk.com
-------------------------------
Swissrisk Financial Systems GmbH
Sitz / Registered Office: Holzhausenstrasse 44, 60322 Frankfurt/Main
HRB-Nr. / Commercial Register No.  83397
Geschäftsführer / Managing Directors: Dr. Peter Marshall, Jürgen Dahmen, 
Andreas Wagner, Peter Hemmer


More information about the CMake mailing list