问题描述
是否有任何用例
target_link_libraries(my-lib xyz)
add_dependencies (my-lib x)#这不只是浪费字节吗?
如果是这样,有人可以解释一下吗?
在当前的CMake版本中:
检查 add_dependencies
导致调用。 x
已添加到 my-lib
。
target_link_libraries
不会导致调用 AddUtility
,但它会将参数添加到目标属性。
稍后, LINK_LIBRARIES
目标属性和实用程序列表的内容都用于计算。
目标中的实用程序列表无法在配置时查询,只有在生成时使用,因此使用 add_dependencies
的参数是已经添加了 target_link_libraries
的库是多余的。 / p>
Is there any use case in which
target_link_libraries(my-lib x y z)
add_dependencies(my-lib x) # this is not just a waste of bytes?
If so, can someone explain what it would be?
In current CMake releases:
After some error checking add_dependencies
results in a call to Target->AddUtility()
. x
is added to the list of utilities for my-lib
.
target_link_libraries
does not result in a call to AddUtility
, but it does add the arguments to the LINK_LIBRARIES
target property.
Later, both the content of the LINK_LIBRARIES
target property and the list of utilities are used to compute the dependencies of the target in cmComputeTargetDepends
.
The list of utilities in a target can not be queried at configure time, and is only used at generate time, so the use of add_dependencies
with arguments which are libraries already added with target_link_libraries
is redundant.
这篇关于target_link_libraries和add_dependencies的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!