[CMake] link_libraries vs target_link_libraries

Andreas Pakulat apaku at gmx.de
Tue Nov 11 14:28:07 EST 2008


On 11.11.08 16:13:43, Fernando Cacciola wrote:
> Which is precisely my point!! :)
>
> target_link_libraries, which is GREAT, is actually pretty useless  
> without target_include_directories, target_add_definitions and  
> <TARGET>_CMAKE_CXX_FLAGS.
>
> Yet OTOH given that those do not exists, it is just plain silly to  
> recommend not using link_libraries, because it gets less than half the  
> story right.
>
> And IMO is equally silly to follow the recomendation and end up doing  
> what most Use files typically do: to set so much that affects all  
> subsequent targets, even compiler and linker flags, BUT simply define a  
> variable XYZ_LIBRARY so a user can decide which target to link againt  
> XYZ_LIBRARY.
>
> I mean, being able to control this is cool, sure, but why can I only  
> control that and not the other equally critical settings???

I can't tell you why things are as they are, I didn't decide on this.
However my understanding is that UseXXX allows for very easy usage of a
particular package, you don't need to worry about anything like
include-dirs or flags. In that case however I agree also putting a couple
of libs as default to link against makes sense. OTOH if you want full
control you should simply use just the find_package() and then use the
variables that it defines where needed.

Andreas

-- 
A visit to a strange place will bring fresh work.


More information about the CMake mailing list