Skip to content

cmake: Change all usage of target_link_libraries to keyword signature

Michael Thies requested to merge cmake_link_libraries_keyword into ov3

This change allows to use target_link_libraries(<target> PRIVATE <lib>) to specify (linker) library dependencies that are not propagated to dependant build targets.

This is a breaking change! You MUST change all usages of target_link_libraries in your project's CMake scripts to use the keyword signature, since CMake only allows only one signature per project. I.e.

target_link_libraries(<target> <lib1> <lib2>)

must be changed to

target_link_librares(<target> PUBLIC <lib1> <lib2>)

You may consider using PRIVATE instead of PUBLIC to restrain the linker (and compiler) flags of the libraries <lib1>, <lib2> to the build of <target>, instead of propageting it to other targets, depending on <target>. This is typically appropriate, until you use definitions or symbols of <lib1>, <lib2> in <target>'s public header files.

Edited by Michael Thies

Merge request reports