如何从 CMake 访问 Boost on Boost 1.66 和 1.67

How to access Beast on Boost 1.66 and 1.67 from CMake

我正在尝试使用 Beast 创建一个 CMake 项目,它已从 /usr/local/include/boost 中的源代码正确安装,但我无法让 CMake 找到它。我虽然它可能是 3.10.2,所以我厌倦了 3.11.43.12.0-rc1,但都没有用。有人知道怎么办吗?

环境:Windows CLion 2018.1.5,WSL 上 Ubuntu 18.04LTS。

尝试 运行 CMake 时,出现以下错误:

CMake Warning at /home/aidan/Apps/cmake-3.11.4-Linux-x86_64/share/cmake-3.11/Modules/FindBoost.cmake:1723 (message):
  No header defined for beast; skipping header check
Call Stack (most recent call first):
  CMakeLists.txt:15 (find_package)


CMake Error at /home/aidan/Apps/cmake-3.11.4-Linux-x86_64/share/cmake-3.11/Modules/FindBoost.cmake:2044 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.67.0

  Boost include path: /usr/local/include

  Could not find the following Boost libraries:

          boost_beast

  Some (but not all) of the required Boost libraries were found.  You may
  need to install these additional Boost libraries.  Alternatively, set
  BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
  to the location of Boost.
Call Stack (most recent call first):
  CMakeLists.txt:15 (find_package)

Boost beast 是一个仅 header 的库。 Header 只有库不能在 find_package(Boost COMPONENTS ...) 调用中引用。因此,从 find_package(Boost COMPONENTS ... REQUIRED) 调用中删除 beast

要了解 Boost 库是否仅 header,请查看以下内容 Boost page