BUILD_INTERFACE or INSTALL_INTERFACE genex with target_link_libraries?

Hi,

While BUILD_INTERFACE and INSTALL_INTERFACE are explicitely mentioned in
target_include_directories documentation, they don’t appear in target_link_libraries documentation. I’m thus wondering if their use is valid beyond target_include_directories context.

I’ve found very few questions/examples of BUILD_INTERFACE genex with target_link_libraries (e.g. [CMake] BUILD_INTERFACE genex used even in install(EXPORT… or How to completely ignore BUILD_INTERFACE libraries in installation?. And they generally seem to address specific (awkward?) cases.

I nevertheless tried by myself. CMake accept such statements and the produced tgt-config.cmake file differs with/without use of genex.

So, taking opencv_imgproc imported target from find_package(OpenCV REQUIRED COMPONENT imgproc) as an example, target_link_libraries(tgt PUBLIC opencv_imgproc) yields to opencv_imgproc populating tgt’s INTERFACE_LINK_LIBRARIES property.

target_link_libraries(tgt PRIVATE opencv_imgproc) and target_link_libraries(tgt PRIVATE $<BUILD_INTERFACE:opencv_imgproc>) both yields to opencv_imgproc populating tgt’s IMPORTED_LINK_DEPENDENT_LIBRARIES, as if BUILD_INTERFACE genex had no effect.

By contrast, target_link_libraries(tgt PUBLIC $<BUILD_INTERFACE:opencv_imgproc>) makes opencv_imgproc totally disappears from tgt-config.cmake.

Regarding use of INSTALL_INTERFACE genex, target_link_libraries(tgt PUBLIC $<INSTALL_INTERFACE:opencv_imgproc>) yields to opencv_imgproc populating tgt’s INTERFACE_LINK_LIBRARIES property.

And target_link_libraries(tgt PRIVATE $<INSTALL_INTERFACE:opencv_imgproc>) makes opencv_imgproc totally disappears from tgt-config.cmake.

Are the statements with BUILD_INTERFACE or INSTALL_INTERFACE genex valid and how should they be read/understood?

Thanks.