我有一堆目标,我正尝试在每个目标的基础上设置包含目录。
set_target_properties (foo PROPERTIES INCLUDE_DIRECTORIES ${CMAKE_Fortran_MODULE_DIRECTORY}/bar)
当我在 Mac OS X 上构建(make VERBOSE=1
)时,我得到了
... -J../build/modules/foo -I../build/modules/bar
当我在 Linux 上做同样的事情时,我得到了
... -J../build/modules/foo ...
我能看到的唯一区别是,在 Mac 上我使用的是 cmake 2.8.8,而在 Linux 上我使用的是 2.8.7。 2.8.8之前的版本不支持吗?
最佳答案
此行为确实是从 2.8.7 到 2.8.8 的版本更改。
来自changelog :
Call ExpandVariablesInString for each target's INCLUDE_DIRECTORIES
Update the documentation regarding INCLUDE_DIRECTORIES. [...]
Keep the INCLUDE_DIRECTORIES target property up to date.
Extract and use the INCLUDE_DIRECTORIES target properties.
特别感兴趣的是 commit changing the documentation .据此,2.8.7 中的 INCLUDE_DIRECTORIES
属性是目录的只读属性。目标属性在该版本中根本不存在。
由于 CMake 允许设置任意目标属性,因此您的脚本仍然可以正常运行,但 CMake 会简单地忽略该属性。
这是另一个很好的例子,为什么你应该始终注意 specifying the correct minimum required version .
关于linux - cmake set_target_properties INCLUDE_DIRECTORIES 在 linux 上被忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17048986/