CMake FIND_PACKAGE succeeds but returns wrong path(CMake FIND_PACKAGE 成功但返回错误的路径)
问题描述
我正在尝试使用 CMakeLists.txt 中的以下代码将 CMake 2.8.6 链接到 boost::program_options
I'm trying to have CMake 2.8.6 link to boost::program_options using the following code in my CMakeLists.txt
find 命令似乎成功了,但将错误的目录传递给了链接器.包裹实际上在:
The find command seems to succeed but passes the wrong directory to the linker. The package is actually in:
但是CMakeFiles/segment.dir/link.txt
列出了以下内容:
注意路径中额外的 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:
生成的 CMakeCache.txt 文件以:
The generated CMakeCache.txt file starts with:
这似乎是正确的.但是当运行 make 它使用上面link.txt中的路径时,我得到了错误:
Which seems to be correct. But when running make it uses the path in link.txt above and I get the error:
什么可能导致将子目录额外注入到路径中?什么可能导致以这种方式生成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)?
推荐答案
当使用一些旧版本的 boost 和 cmake-2.8.6-rc2
或更高版本时会出现这个问题,其中 boost 包发现代码已更改.
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.
该问题可以通过在 cmake 命令行中指定 -DBoost_NO_BOOST_CMAKE=ON
来解决.
The problem can be worked around by specifying -DBoost_NO_BOOST_CMAKE=ON
on the cmake command line.
引入这个问题的实际 commit 是 7da796d1fdd7cca07df733d010cd343f6f8787a9,可以是 在此处查看.
The actual commit where this problem is introduced is 7da796d1fdd7cca07df733d010cd343f6f8787a9, and can be viewed here.
这篇关于CMake FIND_PACKAGE 成功但返回错误的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!