Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于private/public/interface关键字? #11

Open
sunyd1006 opened this issue May 3, 2022 · 2 comments
Open

关于private/public/interface关键字? #11

sunyd1006 opened this issue May 3, 2022 · 2 comments

Comments

@sunyd1006
Copy link

关于如下链接没有理解清楚,大佬可以详细解释一下吗?或者举个例子单开个博客,求求了

参考链接:https://github.com/SFUMECJF/cmake-examples-Chinese/blob/main/01-basic/1.3%20%20Static%20Library.md#:~:text=%E4%BC%A0%E9%80%92%E7%BB%99%E5%87%BD%E6%95%B0,%E5%8F%AF%E8%83%BD%E6%80%A7%E8%BE%83%E5%B0%8F%E3%80%82

@SFUMECJF
Copy link
Owner

SFUMECJF commented May 3, 2022

关于这篇内容,确实是大家的痛点,很多人对这部分有疑问。会考虑重制一下这篇文章的。

@Elite-zx
Copy link

  • PRIVATE:当一个目标被定义为PRIVATE时,它表示这个目标只应用于该目标自身。也就是说,如果你有一个库A,而你把库B设置为库A的PRIVATE依赖,那么只有库A能使用库B,而不能链接库A的其他目标无法使用库B。
  • INTERFACE:表示只有当其他目标链接到该目标时,才会使用这个目标。用库A和库B的例子来说,如果你把库B设置为库A的INTERFACE依赖,那么只有当其他目标链接库A时,才会使用库B,而库A自身无法使用库B。
  • PUBLIC:表示该目标同时应用于自身和链接到它的其他目标。再用库A和库B的例子,如果你把库B设置为库A的PUBLIC依赖,那么库A和链接库A的其他目标都能使用库B。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants