[CMake] namespace support

Michael Wild themiwi at gmail.com
Wed Feb 2 10:17:24 EST 2011


On 02/02/2011 04:08 PM, Peter Kümmel wrote:
> I wanna build several targets in one CMakeLists.txt,
> because I have many simple one-file-only plugins with
> the same build rules, for instance:
> 
> include_directories(a)
> add_library(a MODULE a/a.cpp)
> 
> include_directories(b)
> add_library(b MODULE b/b.cpp)
> 
> 
> 
> The problem is that all include_directories and
> add_definitions have a file scope and are visible
> for all targets.
> 
> Is it already possible to use push/pop the scope like it
> must be done for add_subdirectory?
> 
> scope_push()
>     include_directories(a)
>     add_library(a MODULE a/a.cpp)
> scope_pop()
> 
> or
> 
> scope_enter(b)
>     include_directories(b)
>     add_library(b MODULE b/b.cpp)
> scope_leave()
> 
> or
> 
> namespace(a)
>     include_directories(a)
>     add_library(a MODULE a/a.cpp)
> endnamespace()
> 
> 
> Peter

Put a CMakeLists.txt file in a/ and b/ and do the include_directories()
and add_library() calls in there. That's the only way to have separate
include directories since there is no corresponding target property
(which admittedly would be nice to have).

Michael


More information about the CMake mailing list