[cmake-developers] Convention driven CMAKE_USE_PACKAGE macro

Clinton Stimpson clinton at elemtech.com
Fri Feb 24 14:27:40 EST 2012


On Feb 24, 2012, at 12:00 PM, Brad King wrote:

> On 2/24/2012 1:56 PM, Clinton Stimpson wrote:
>> What about a more generic approach like the following?
>> 
>> add_library(foo IMPORTED ...)
>> set_target_properties(foo PROPERTIES
>>       DEPENDENT_COMPILE_DEFINITIONS "FOO_DEFINE"
>>       DEPENDENT_INCLUDE_DIRECTORIES "/path/to/foo/include")
>> 
>> add_executable(bar ...)
>> target_link_libraries(foo bar)
>> 
>> And that could automatically add -DFOO_DEFINE and -I/path/to/foo/include to
>> the bar executable.
>> So basically any DEPENDENT_<property>  can be pushed to<property>  on the other
>> target.
> 
> Nice.  This is exactly the kind of interface I had in mind for the
> "usage requirements" approach Alex and I were discussing elsewhere
> in this thread.  We will have to think about how to define transitive
> properties of these requirements though.
> 

Good.  And I like how it takes CMake into a more declarative direction, for places where it makes sense.
A non-declarative approach involves worrying about scoping, ordering, etc...

Clint


More information about the cmake-developers mailing list