Chinaunix首页 | 论坛 | 博客
  • 博客访问: 95363
  • 博文数量: 14
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 142
  • 用 户 组: 普通用户
  • 注册时间: 2013-06-22 14:20
个人简介

会挽雕弓如满月,西北望,射天狼

文章分类

全部博文(14)

文章存档

2020年(2)

2015年(10)

2014年(2)

我的朋友

分类: LINUX

2015-06-29 10:36:23

学习QT插件机制时, 参照 http://blog.csdn.net/jingwenlai_scut/article/details/5412584
写代码和cmake文件, 实际编译主CMakeLists.txt 出现如下错误

*********************************************************************************************************
CMake Warning (dev) at CMakeLists.txt:8 (link_directories):
  This command specifies the relative path

     TestPlugin

 as a link directory.


  Policy CMP0015 is not set: link_directories() treats paths relative to the
  source dir.  Run "cmake --help-policy CMP0015" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.
This warning is for project developers.  Use -Wno-dev to suppress it

********************************************************************************************************

我使用的cmake版本是 2.8.4 
错误行为   8 link_directories(TestPlugin)

google后得到解释如下

********************************************************************************************************
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修饰对路径,链接时先转换成绝对路径再进行链接。
*********************************************************************************************************

更改CMakeLists.txt 第8行如下,问题解决

link_directories(${CMAKE_CURRENT_SOURCE_DIR}/TestPlugin) 

另外改成如下方式 也可

link_directories(${CMAKE_CURRENT_BINARY_DIR}/TestPlugin)

那么 CMAKE_CURRENT_SOURCE_DIR和CMAKE_CURRENT_BINARY_DIR有什么区别呢,而且这些宏是在什么地方定义的呢?

CMAKE_CURRENT_SOURCE_DIR:

The path to the source directory currently being processed.

This the full path to the source directory that is currently being processed by cmake.

大意是此值代表源文件路径, 即当前路径/source路径
CMAKE_CURRENT_BINARY_DIR:

The path to the binary directory currently being processed.

This the full path to the build directory that is currently being processed by cmake. Each directory added by add_subdirectory will create a binary directory in the build tree, and as it is being processed this variable will be set. For in-source builds this is the current source directory being processed.

大意是此值代表源文件路径, 每一个由add_subdirectory 添加的路径在编译树上创建一个二进制文件路径, 同时这个变量将被设置. 对于in-source 编译此值是当前源文件路径,对于out-source此值为 当前路径/编译路径


阅读(14733) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~