[CMake] link_libraries

Hendrik Sattler post at hendrik-sattler.de
Mon Oct 20 06:04:32 EDT 2008


Ioan Calin Borcoman schrieb:
> Hi,
> 
> I have a dir with a lot of small example apps that all link with the
> same libs. The link_libraries is much more convenient in this case
> than writing a target_link_libraries line for each example target.
> 
> Why is the link_libraries deprecated? Will it be removed in the future?

In this case, you usually use a foreach anyway, don't you?

set (exampleapps
  ex1
  ex2
  ex3
)

foreach ( ex ${exampleapps} )
  add_executable( ${ex} ${ex}.c )
  target_link_libraries( ${ex} mylib)
endforeach ( ex )


Easy enough?

HS


More information about the CMake mailing list