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

Reply via email to