是否有任何方法可以获取CMake目标(包括其依赖目标)的完整包含目录
假设在CMakeLists.txt中有两个目标是否有任何方法可以获取CMake目标(包括其依赖目标)的完整包含目录,cmake,Cmake,假设在CMakeLists.txt中有两个目标 add_library(liba ...) target_include_directory(liba PUBLIC /path/to/somewhere/a) add_executable(exec ...) target_include_directory(exec PUBLIC /path/to/somewhere/b) target_link_directories(exec liba) 我知道如何获取exec的INCLUDE\u目录属性
add_library(liba ...)
target_include_directory(liba PUBLIC /path/to/somewhere/a)
add_executable(exec ...)
target_include_directory(exec PUBLIC /path/to/somewhere/b)
target_link_directories(exec liba)
我知道如何获取exec
的INCLUDE\u目录
属性。但是只获取/path/to/somewhere/b
,而实际上,目标exec
的源文件将使用从liba
继承的附加搜索路径/path/to/somewhere/a
进行编译
另外,我想这样做的原因是我正在尝试将YCM与CMake集成,而CMake生成的compliation数据库缺少头文件的信息,编写
YCM\u extra\u conf.py
在依赖关系复杂的情况下非常可怕。嗯,我觉得情况有点不清楚/奇怪。首先,/path/to/where/a
是绝对路径吗?当liba
为makeinstall
ed?时,如果需要更改它,您可能会发现这一点很有用: