CMake target_link_libraries接口依赖关系 [英] CMake target_link_libraries Interface Dependencies

查看:1562
本文介绍了CMake target_link_libraries接口依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是CMAKE的新手,有点混淆与target_link_libraries相关的PUBLIC,PRIVATE和INTERFACE关键字。文档提到它们可以用于在一个命令中指定链接依赖性和链接接口。



链接依赖关系和链接接口是什么意思?

解决方案

如果你正在创建一个共享库和你的源cpp文件#include另一个库的头(Say,QtNetwork例如),但你的头文件不包括QtNetwork头,那么QtNetwork是一个 PRIVATE 依赖。



如果你的源文件和你的头包括另一个库的头,那么它是一个 PUBLIC 依赖。



如果你的头文件而不是你的源文件包括另一个库的头文件,那么它是一个 INTERFACE 其他构建属性 PUBLIC INTERFACE

/ code>依赖项传播到使用库。 http://www.cmake.org/ cmake / help / v3.0 / manual / cmake-buildsystem.7.html#transitive-usage-requirements


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 specify both the link dependencies and the link interface in one command.

What does link dependencies and link interface actually mean?

解决方案

If you are creating a shared library and your source cpp files #include the headers of another library (Say, QtNetwork for example), but your header files don't include QtNetwork headers, then QtNetwork is a PRIVATE dependency.

If your source files and your headers include the headers of another library, then it is a PUBLIC dependency.

If your header files but not your source files include the headers of another library, then it is an INTERFACE dependency.

Other build properties of PUBLIC and INTERFACE dependencies are propagated to consuming libraries. http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html#transitive-usage-requirements

这篇关于CMake target_link_libraries接口依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆