1

This is in my CMakeLists.txt:

cmake_minimum_required(VERSION 3.1.0)

project(myProject)

set(EXECUTABLE_OUTPUT_PATH ./bin/${CMAKE_BUILD_TYPE})

find_package(Boost REQUIRED COMPONENTS filesystem)

I compiled Boost 1.64.0 from source. The Boost compilation succeeded, and the filesystem headers are present in the Boost installation directory. I then pointed Boost_INCLUDE_DIR to its base folder (the one containing bootstrap and b2.exe).

I get this CMake output:

CMake Error at C:/Program Files/CMake/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
  Could NOT find Boost (missing: filesystem) (found version "1.64.0")
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake/share/cmake-3.18/Modules/FindBoost.cmake:2177 (find_package_handle_standard_args)
  CMakeLists.txt:9 (find_package)


Configuring incomplete, errors occurred!

What does this mean? How can CMake "NOT find Boost", but find version 1.64.0?

acl
  • 254
  • 1
  • 5
  • 13
  • 4
    It found the headers but not the libs. Did you install or only compile Boost? – rustyx Oct 15 '20 at 12:21
  • 1
    Many of the boost libraries are header only but filesystem is not. There is a library built for it. I believe `Boost_INCLUDE_DIR` will not help you find the binaries. You need to set `BOOST_ROOT` or `Boost_DIR` [https://cmake.org/cmake/help/v3.18/module/FindBoost.html](https://cmake.org/cmake/help/v3.18/module/FindBoost.html) – drescherjm Oct 15 '20 at 12:38
  • @rustyx I compiled it and moved it to `C:\Program Files\boost`. I'm not sure I know what you mean by "install", the [Getting Started guide](https://www.boost.org/doc/libs/1_74_0/more/getting_started/windows.html) only says how to compile it. – acl Oct 16 '20 at 07:31
  • @drescherjm I set both `BOOST_ROOT` and `BOOST_DIR` to boost's directory, which didn't change the error. – acl Oct 16 '20 at 07:33
  • I have the same problem, I set BOOST_ROOT, Boost_INCLUDE_DIR and Boost_LIBRARY_DIR however it still does not work. I asked the question over https://stackoverflow.com/questions/66000702/howto-use-cmake-with-boost-asio?noredirect=1#comment116694146_66000702 – U_flow Feb 02 '21 at 08:16

0 Answers0