gpt4 book ai didi

cmake - include_directories 的默认隐私/范围设置是什么?

转载 作者:行者123 更新时间:2023-12-04 01:40:52 25 4
gpt4 key购买 nike

我了解 target_include_directories() 可以与 PUBLICINTERFACEPRIVATE 结合使用以指定目录的范围或隐私。但是很多过时的代码仍然使用 include_directories() ,而且我不确定使用它们的目标如何处理这些目录。

使用 include_directories() 与使用 target_include_directories(MyTarget PRIVATE ...) 本质上是一样的吗?我看过this类似的问题,但是 include_directories() 是否也没有默认范围行为?

最佳答案

Is using include_directories() essentially the same as using target_include_directories(MyTarget PRIVATE ...)?

是的,对于受 include_directories 影响的每个目标(即在当前CMakeLists.txt及以下),与PRIVATE具有相同的效果命令的目标特定版本中的关键字。


Documentation对于 include_directories说,该命令分配 INCLUDE_DIRECTORIES目标和目录的属性:

The include directories are added to the INCLUDE_DIRECTORIES directory property for the current CMakeLists file. They are also added to the INCLUDE_DIRECTORIES target property for each target in the current CMakeLists file.

和目录属性affects在进一步的目标上:

This property is used to populate the INCLUDE_DIRECTORIES target property.

正是INCLUDE_DIRECTORIES目标属性(property) is affected通过 PRIVATE target_include_directories的关键词命令:

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>.

关于cmake - include_directories 的默认隐私/范围设置是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57500745/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com