[cmake-developers] target_link_libraries not callable from other directory scopes

Patrick Stotko stotko at informatik.uni-bonn.de
Wed Apr 25 14:22:10 EDT 2018


Hi,

this nice post 
(https://crascit.com/2016/01/31/enhanced-source-file-handling-with-target_sources/) 
mentions some modern usage of target_sources(), but also shows some 
discrepancy between target_link_libraries and the remaining target_* 
functions. In particlar, CMake does not allow linking to a target 
outside its creation scope whereas all the other ones do. There exists a 
workaround with include(), but it seems not the correct and clean way to 
handle this.

So I think lifting this limitation would escepially help large-scale 
projects and improve modularization by handling third-party dependencies 
in the specific modules (as long as only this particular module needs it).

So what is your experience regarding this linking restriction, 
especially in larger projects? I also opened an issue for this (see 
https://gitlab.kitware.com/cmake/cmake/issues/17943).

Best regards,
Patrick Stotko


More information about the cmake-developers mailing list