1

Here is my CMakeLists.txt file

cmake_minimum_required(VERSION 3.8)
project("pi-calc" VERSION 1.0)

find_package(Boost REQUIRED COMPONENTS multiprecision)
add_executable(pi-calc main.cpp)
target_link_libraries(pi-calc PRIVATE Boost::boost Boost::multiprecision)

This is the main part of error message, removing CMake find_package failure Call Stacks

Could NOT find Boost (missing: multiprecision) (found version "1.67.0")

I have tried googling around for a solution but couldn't find anything.

txk2048
  • 281
  • 3
  • 15

1 Answers1

3

Many of Boost's libraries are header-only libraries, including the multiprecision library. You only need to explicitly call out the libraries in COMPONENTS that are not header-only, shown in the list here.

If you need a header-only library, such as multiprecision, you will get this for free from the Boost::boost target, which includes all the Boost headers. There is no need to list any COMPONENTS:

cmake_minimum_required(VERSION 3.8)
project("pi-calc" VERSION 1.0)

find_package(Boost REQUIRED)
add_executable(pi-calc main.cpp)
target_link_libraries(pi-calc PRIVATE Boost::boost)

Note, in CMake versions 3.15 and later, you should instead use the Boost::headers target, which supersedes the Boost::boost target.

Kevin
  • 16,549
  • 8
  • 60
  • 74
  • Is using Boost::headers possible or even recommended in CMake 3.8? In what version of CMake was the Boost::headers target introduced. – txk2048 Mar 18 '20 at 18:50
  • @Toothless204 The `Boost::headers` target was introduced in CMake 3.15, so if you are using an earlier version, you should use `Boost::boost`. I'll update my response with this info. – Kevin Mar 18 '20 at 18:53