[CMake] transitive link flags

Luke Dalessandro luked at cs.rochester.edu
Sun Nov 6 16:33:22 EST 2011


On Nov 6, 2011, at 4:26 PM, Łukasz Tasz wrote:

>> As it is, I've written my own macro for linking with this particular library, essentially a custom target_link_libraries command: target_link_foo, that contains the right flags. This is basically unsatisfactory though, since I need to remember to use it and just hope everyone else does too.
>> 
> 
> to avoid separate function you can write wrapper to target_link_libraries():
> 
> function(target_link_libraries lib)
>    list(search you_lib ..... in ARGN)
>    if(output_var)
>          #do special linking with your lib
>          _target_link_libraries(${lib} your_lib specialflags)
>          or target_link_foo()
>          list(REMOVE ARGN your_lib)
>    endif()
>    _target_link_libraries(${lib} your_lib)
> endfunction()
> 
> This will allow you to avoid special treatment in CMakeLists.txt,
> Later if you will find better solution you will just remove wrapper
> function for target_link_libraries().

Ok, thanks. This is basically a more generic version of what I'm doing now.

Luke



More information about the CMake mailing list