CMake target_include_directories meaning of scope

前端 未结 2 1255
南旧
南旧 2020-12-07 08:12

What is the meaning of the keyword PUBLIC, PRIVATE, and INTERFACE related to CMake\'s target_include_directories?

2条回答
  •  -上瘾入骨i
    2020-12-07 09:04

    The INTERFACE, PUBLIC and PRIVATE keywords are required to specify the scope of the following arguments. PRIVATE and PUBLIC items will populate the INCLUDE_DIRECTORIES property of < target >. PUBLIC and INTERFACE items will populate the INTERFACE_INCLUDE_DIRECTORIES property of < target >. The following arguments specify include directories.

    From the documentation: http://www.cmake.org/cmake/help/v3.0/command/target_include_directories.html

    To rephrase the documentation with my own words:

    • you want to add a directory to list of include directory for a target
    • with PRIVATE the directory is added to the target's include directories
    • with INTERFACE the target is not modified, but the INTERFACE_INCLUDE_DIRECTORIES is extended by the directory. The variable is a list of public include directories for a library.
    • with PUBLIC both actions from PRIVATE and INTERFACE are performed.

提交回复
热议问题