1

I've added boost like this: "-DBoost_INCLUDE_DIR=/boost_1_71_0" and this is what I get:

Could NOT find Boost (missing: context headers) (found suitable version "1.71.0", minimum required is "1.71")

Cmake can determine boost version but cannot find boost at the same time! Is there a way for me to fix it?

This is how I include boost in my cmake file. Nothing fancy in here.

find_package(Boost 1.71 COMPONENTS context headers REQUIRED)
Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
Hirasawa Yui
  • 1,138
  • 11
  • 29
  • Show us your `CMakeLists.txt` file. In general, use `find_package` along with `FindBoost.cmake` -- see https://stackoverflow.com/questions/3897839/how-to-link-c-program-with-boost-using-cmake ; Also see if you're setting the min required version somewhere in your cmakelists file. – aspen100 Jul 07 '20 at 19:20
  • It could be that your CMake does not understand boost 1.71 yet. – drescherjm Jul 07 '20 at 19:40

1 Answers1

3

Boost context and headers are header only libraries and therefore do not need to be mentioned in the find_packages call. Do a simple find_package(Boost 1.71 REQUIRED) and you are done. Later you can reference the Boost header directory either with Boost::boost or Boost::headers in your target_link_librariescommand.

vre
  • 6,041
  • 1
  • 25
  • 39