CMake的FIND_PACKAGE成功,但返回错误的道路 [英] CMake FIND_PACKAGE succeeds but returns wrong path

查看:1438
本文介绍了CMake的FIND_PACKAGE成功,但返回错误的道路的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有CMake的2.8.6链接提振::使用以下code program_options在我的CMakeLists.txt

I'm trying to have CMake 2.8.6 link to boost::program_options using the following code in my CMakeLists.txt

FIND_PACKAGE(Boost COMPONENTS program_options REQUIRED)
INCLUDE_DIRECTORIES (${Boost_INCLUDE_DIR})

ADD_EXECUTABLE (segment segment.cpp)
TARGET_LINK_LIBRARIES (segment ${Boost_LIBRARIES})

find命令似乎成功,但传递了错误的目录连接器。包实际上是:

The find command seems to succeed but passes the wrong directory to the linker. The package is actually in:

`/usr/lib64/libboost_program_options-mt.so.5`

CMakeFiles / segment.dir / link.txt 列出以下内容:

/cm/shared/apps/gcc/4.4.6/bin/c++       CMakeFiles/segment.dir/segment.cpp.o  -o segment -rdynamic /usr/lib64/lib64/libboost_program_options-mt.so.5 -lpthread -lrt -Wl,-rpath,/usr/lib64/lib64

请注意在路径额外的 lib64的。此外,在路径前面-l标志似乎缺少。

Note the extra lib64 in the path. Also, the -l flag in front of the path seems to be missing.

在运行CMake的它报告说,它正确地发现包,而 {$ Boost_LIBRARIES} 变量似乎列出正确的库:

When running CMake it reports that it correctly finds the package, and the {$Boost_LIBRARIES} variable seems to list the correct libs:

Boost  found.
Found Boost components:
   program_options
${Boost_LIBRARIES} - optimized;boost_program_options-mt-shared;debug;boost_program_options-mt-shared-debug

生成CMakeCache.txt文件的开头为:

The generated CMakeCache.txt file starts with:

//The directory containing a CMake configuration file for Boost.
Boost_DIR:PATH=/usr/lib64/boost

//Boost include directory
Boost_INCLUDE_DIR:FILEPATH=/usr/include

这似乎是正确的。但在运行时做它用在上面link.txt路径和我得到的错误:

Which seems to be correct. But when running make it uses the path in link.txt above and I get the error:

make[2]: *** No rule to make target `/usr/lib64/lib64/libboost_program_options-mt.so.5', needed by `segment'.  Stop.
make[1]: *** [CMakeFiles/segment.dir/all] Error 2
make: *** [all] Error 2

什么可能导致一个子目录到路径的这种额外的注入?什么可能会导致以这种方式来产生link.txt?而如何解决它(或解决它)?

What might cause this extra injection of a subdir into the path? What might cause link.txt to be generated in this way? And how do I fix it (or work around it)?

推荐答案

使用了一些旧版本的升压时,会出现此问题 cmake的-2.8.6-RC2 或更高版本,其中升压包发现code的改变。

This problem occurs when using some older versions of boost with cmake-2.8.6-rc2 or later, where the boost package finding code was changed.

这个问题可以通过指定 -DBoost_NO_BOOST_CMAKE = ON CMake的命令行工作周围

The problem can be worked around by specifying -DBoost_NO_BOOST_CMAKE=ON on the cmake command line.

实际的提交,其中这个问题引入是7da796d1fdd7cca07df733d010cd343f6f8787a9,并且可以是<一个href=\"http://cmake.org/gitweb?p=cmake.git;a=commit;h=7da796d1fdd7cca07df733d010cd343f6f8787a9\">viewed这里。

The actual commit where this problem is introduced is 7da796d1fdd7cca07df733d010cd343f6f8787a9, and can be viewed here.

这篇关于CMake的FIND_PACKAGE成功,但返回错误的道路的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆