CMake target_link_libraries Interface Dependencies

后端 未结 3 490
攒了一身酷
攒了一身酷 2020-12-07 07:46

I am new to CMake and a bit confused with the PUBLIC, PRIVATE and INTERFACE keywords related to target_link_libraries(). Documentation mentions that they can be used to spec

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-07 08:12

    Some answers only said when to use PRIVATE/PUBLIC/INTERFACE, but the affects are ignored. Refer:CMake-Public-Private-Interface

    PUBLIC
    All the objects following PUBLIC will be used for linking to the current target and providing the interface to the other targets that have dependencies on the current target.

    PRIVATE
    All the objects following PRIVATE will only be used for linking to the current target.

    INTERFACE
    All the objects following INTERFACE will only be used for providing the interface to the other targets that have dependencies on the current target.

提交回复
热议问题