CMake 文件 link_directories() 使用相对路径失败的问题

今天再编译工程时,遇到了这个问题:

Policy CMP0015 is not set: link_directories() treats paths relative to the source dir.

看到了这一篇 博客
解决了这个问题,核心如下:

In CMake 2.8.0 and lower the link_directories() command passed relative paths unchanged to the linker. In CMake 2.8.1 and above the link_directories() command prefers to interpret relative paths with respect to CMAKE_CURRENT_SOURCE_DIR, which is consistent with include_directories() and other commands. The OLD behavior for this policy is to use relative paths verbatim in the linker command. The NEW behavior for this policy is to convert relative paths to absolute paths by appending the relative path to CMAKE_CURRENT_SOURCE_DIR.

CMake 2.8.0 以下的版本,加载动态链接库link_directories()时使用相对路径,链接时也使用相对路径;CMake 2.8.1 及以上版本加载动态链接库link_directories()时使用CMAKE_CURRENT_SOURCE_DIR修饰对路径,链接时先转换成绝对路径再进行链接。

猜你喜欢

转载自www.cnblogs.com/walnuttree/p/11595206.html