CMake Boost 1.59.0 几何

CMake Boost 1.59.0 geometry

我对将 boost 与 C++ 一起使用还很陌生。我刚刚安装了 Boost 1.59.0,我想使用几何库。

如果我包含 FIND_PACKAGE( Boost 1.47 REQUIRED ) 它会发现提升并且不会出现问题。如果我然后包含 FIND_PACKAGE( Boost 1.47 COMPONENTS geometry REQUIRED ) 我会收到以下错误:

 Unable to find the requested Boost libraries.

  Boost version: 1.59.0

  Boost include path: /usr/include

  Could not find the following Boost libraries:

          boost_geometry

  No Boost libraries were found.  You may need to set BOOST_LIBRARYDIR to the
  directory containing Boost libraries or BOOST_ROOT to the location of
  Boost.

如果我在 CLI 中 运行 以下 [ -f /usr/include/boost/geometry/geometry.hpp ] && echo "Found" || echo "Not found",我会得到 Found 作为结果。所以看起来它在那里,但是CMake告诉我它不存在。

我误会了什么?

COMPONENTS 仅对于构建的库是必需的。 Geometry 是一个 header-only 库,因此不需要它。您只需要找到提升 headers 位置。