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修飾對路徑,鏈接時先轉換成絕對路徑再進行鏈接。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM