今天再編譯工程時,遇到了這個問題:
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修飾對路徑,鏈接時先轉換成絕對路徑再進行鏈接。