【发布时间】:2018-01-12 15:23:20
【问题描述】:
我在 CMake 中有 2 个项目 L 和 A,比如 L 是一个库,A 是一个依赖于 L 的应用程序。
文件夹层次结构如下:
- 一个
- CMakeLists.txt + headers + src
- 大号
- CMakeLists.txt + headers + src
- subL
- 头文件 + src 文件
现在,就包含目录而言,我知道我需要在 L/CMakeLists.txt/include_directories() 中指定 subL,以便 L 中的其他文件可以引用包含文件只需使用 #include "mySubLHeaderFile.h" 或 #include 。
现在,如果我想在 A 项目的文件中引用 subL 的头文件,并且能够引用此 subL 文件只需使用 #include "mySubLHeaderFile.h" 或 #include ,我注意到我需要重新指定 subL在 A/CMakeLists.txt/include_directories() 中。这是正常行为吗? include_directories() 不是继承自依赖项目吗?
------ 编辑 1 --------
请注意,我在 A 和 L 上方有一个顶级 CMakeLists.txt。
【问题讨论】:
-
你有顶级 CMakeLists.txt,在 A 和 L 之上吗?
-
我确实有一个顶级 CMakeLists.txt,超过 A 和 L。刚刚修改了帖子以反映这一点。
-
我不确定这一点,但我认为您可以在该顶级文件中放置一个 include_directories,以便所有子文件夹都可以访问。
-
你知道最佳实践吗?