Issue
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.
Solution
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.
Answered By - Kevin Answer Checked By - Katrina (WPSolving Volunteer)