Search code examples
c++boostcmake

CMake: Cannot find component include directory


I've been investigating CMake as a tool to consolidate our builds so we can more easily do cross-platform (and cross-IDE!) development, but I seem to be hitting a snag with using the FindBoost stuff. See below the relevant cmake file:

message(STATUS "Entering setup_boost.cmake")

# CMake for setting up boost via find_package
set(BOOST_ROOT ${BOOST_DIR}) # Set to be my directory with boost headers + libraries.
set(Boost_DEBUG ON) # Disable if you don't want debugging output for finding boost.
set(Boost_DETAILED_FAILURE_MESSAGE ON) # Disable if you don't want detailed error messages when finding boost.
set(BOOST_INCLUDEDIR "${BOOST_ROOT}/include")
set(BOOST_LIBRARYDIR "${BOOST_ROOT}/${C_BLD_RELDIR}/lib") # C_BLD_RELDIR is evaluated prior to this.
message(STATUS "Boost Root: '${BOOST_ROOT}'")
message(STATUS "Boost Include Directory: '${BOOST_INCLUDEDIR}'")
message(STATUS "Boost Library Directory: '${BOOST_LIBRARYDIR}'")

set(BOOST_COMPONENTS "filesystem")
message(STATUS "Using boost components: ${BOOST_COMPONENTS}")

set(Boost_NO_SYSTEM_PATHS ON)
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost
    ${S_BOOST_V} EXACT
    REQUIRED
    COMPONENTS ${BOOST_COMPONENTS}
    )

Based on my research, this should be working, but it fails to find the filesystem include dir. The output is below:

"C:\dev\Jetbrains\CLion 2019.3.4\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - NMake Makefiles" C:\path\to\project\Source

# This all seems pretty legit; correctly evaluates for the message commands.
-- Boost Root: 'C:\path\to\ThirdParty/boost/1.74.0'
-- Boost Include Directory: 'C:\path\to\ThirdParty/boost/1.74.0/include'
-- Boost Library Directory: 'C:\path\to\ThirdParty/boost/1.74.0/w2016/vs2019/release64mt/lib'

# I've removed the filepath + line numbers to the CMake messages below to keep things succinct.
# As above, this all seems correct.
-- _boost_TEST_VERSIONS = "1.74.0;1.74"
-- Boost_USE_MULTITHREADED = "TRUE"
-- Boost_USE_STATIC_LIBS = "ON"
-- Boost_USE_STATIC_RUNTIME = <unset>
-- Boost_ADDITIONAL_VERSIONS = <unset>
-- Boost_NO_SYSTEM_PATHS = "ON"
-- BOOST_ROOT = "C:\path\to\ThirdParty/boost/1.74.0"
-- ENV{BOOST_ROOT} = <unset>
-- BOOST_INCLUDEDIR = "C:\path\to\ThirdParty/boost/1.74.0/include"
-- ENV{BOOST_INCLUDEDIR} = <unset>
-- BOOST_LIBRARYDIR = "C:\path\to\ThirdParty/boost/1.74.0/w2016/vs2019/release64mt/lib"
-- ENV{BOOST_LIBRARYDIR} = <unset>
-- _boost_INCLUDE_SEARCH_DIRS = "C:\path\to\ThirdParty/boost/1.74.0/include;C:\path\to\ThirdParty/boost/1.74.0;NO_CMAKE_SYSTEM_PATH;NO_SYSTEM_ENVIRONMENT_PATH"
-- _boost_PATH_SUFFIXES = "boost-1_74_0;boost_1_74_0;boost/boost-1_74_0;boost/boost_1_74_0;boost-1_74;boost_1_74;boost/boost-1_74;boost/boost_1_74"
-- Boost_LIB_PREFIX = "lib"
-- Boost_NAMESPACE = "boost"
-- _boost_COMPILER = "-vc142;-vc141;-vc140" (guessed)
-- _boost_MULTITHREADED = "-mt"
-- _boost_ARCHITECTURE_TAG = "" (detected)
-- _boost_RELEASE_ABI_TAG = "-"
-- _boost_DEBUG_ABI_TAG = "-gd"

# This is where it gets shonky. Notice all the 'Boost_INCLUDE_DIR-NOTFOUND' here
-- _boost_LIBRARY_SEARCH_DIRS_RELEASE =
  C:\path\to\ThirdParty/boost/1.74.0/w2016/vs2019/release64mt/lib
  C:\path\to\ThirdParty/boost/1.74.0/lib;
  C:\path\to\ThirdParty/boost/1.74.0/stage/lib;
  C:\path\to\ThirdParty/boost/1.74.0/lib64-msvc-14.2;
  C:\path\to\ThirdParty/boost/1.74.0/lib64-msvc-14.1;
  C:\path\to\ThirdParty/boost/1.74.0/lib64-msvc-14.0;
  Boost_INCLUDE_DIR-NOTFOUND/lib;
  Boost_INCLUDE_DIR-NOTFOUND/../lib;
  Boost_INCLUDE_DIR-NOTFOUND/stage/lib;
  Boost_INCLUDE_DIR-NOTFOUND/../lib64-msvc-14.2;
  Boost_INCLUDE_DIR-NOTFOUND/../lib64-msvc-14.1;
  Boost_INCLUDE_DIR-NOTFOUND/../lib64-msvc-14.0;
  Boost_INCLUDE_DIR-NOTFOUND/lib64-msvc-14.2;
  Boost_INCLUDE_DIR-NOTFOUND/lib64-msvc-14.1;
  Boost_INCLUDE_DIR-NOTFOUND/lib64-msvc-14.0;
  NO_CMAKE_SYSTEM_PATH;
  NO_SYSTEM_ENVIRONMENT_PATH

-- _boost_LIBRARY_SEARCH_DIRS_DEBUG =
  C:\path\to\ThirdParty/boost/1.74.0/w2016/vs2019/release64mt/lib;
  C:\path\to\ThirdParty/boost/1.74.0/lib;
  C:\path\to\ThirdParty/boost/1.74.0/stage/lib;
  C:\path\to\ThirdParty/boost/1.74.0/lib64-msvc-14.2;
  C:\path\to\ThirdParty/boost/1.74.0/lib64-msvc-14.1;
  C:\path\to\ThirdParty/boost/1.74.0/lib64-msvc-14.0;
  Boost_INCLUDE_DIR-NOTFOUND/lib;
  Boost_INCLUDE_DIR-NOTFOUND/../lib;
  Boost_INCLUDE_DIR-NOTFOUND/stage/lib;
  Boost_INCLUDE_DIR-NOTFOUND/../lib64-msvc-14.2;
  Boost_INCLUDE_DIR-NOTFOUND/../lib64-msvc-14.1;
  Boost_INCLUDE_DIR-NOTFOUND/../lib64-msvc-14.0;
  Boost_INCLUDE_DIR-NOTFOUND/lib64-msvc-14.2;
  Boost_INCLUDE_DIR-NOTFOUND/lib64-msvc-14.1;
  Boost_INCLUDE_DIR-NOTFOUND/lib64-msvc-14.0;
  NO_CMAKE_SYSTEM_PATH;
  NO_SYSTEM_ENVIRONMENT_PATH

-- Searching for FILESYSTEM_LIBRARY_RELEASE:
  libboost_filesystem-vc142-mt-;
  libboost_filesystem-vc142-mt;
  libboost_filesystem-vc142-mt;
  libboost_filesystem-vc141-mt-;
  libboost_filesystem-vc141-mt;
  libboost_filesystem-vc141-mt;
  libboost_filesystem-vc140-mt-;
  libboost_filesystem-vc140-mt;
  libboost_filesystem-vc140-mt;
  libboost_filesystem-mt-;
  libboost_filesystem-mt;
  libboost_filesystem-mt;
  libboost_filesystem-mt;
  libboost_filesystem;
  libboost_filesystem-vc142-mt-s-;
  libboost_filesystem-vc142-mt-s;
  libboost_filesystem-vc142-mt-s;
  libboost_filesystem-vc141-mt-s-;
  libboost_filesystem-vc141-mt-s;
  libboost_filesystem-vc141-mt-s;
  libboost_filesystem-vc140-mt-s-;
  libboost_filesystem-vc140-mt-s;
  libboost_filesystem-vc140-mt-s;
  libboost_filesystem-mt-s-;
  libboost_filesystem-mt-s;
  libboost_filesystem-mt-s

-- Searching for FILESYSTEM_LIBRARY_DEBUG:
  libboost_filesystem-vc142-mt-gd-;
  libboost_filesystem-vc142-mt-gd;
  libboost_filesystem-vc142-mt-gd;
  libboost_filesystem-vc141-mt-gd-;
  libboost_filesystem-vc141-mt-gd;
  libboost_filesystem-vc141-mt-gd;
  libboost_filesystem-vc140-mt-gd-;
  libboost_filesystem-vc140-mt-gd;
  libboost_filesystem-vc140-mt-gd;
  libboost_filesystem-mt-gd-;
  libboost_filesystem-mt-gd;
  libboost_filesystem-mt-gd;
  libboost_filesystem-mt;
  libboost_filesystem;
  libboost_filesystem-vc142-mt-s-gd-;
  libboost_filesystem-vc142-mt-s-gd;
  libboost_filesystem-vc142-mt-s-gd;
  libboost_filesystem-vc141-mt-s-gd-;
  libboost_filesystem-vc141-mt-s-gd;
  libboost_filesystem-vc141-mt-s-gd;
  libboost_filesystem-vc140-mt-s-gd-;
  libboost_filesystem-vc140-mt-s-gd;
  libboost_filesystem-vc140-mt-s-gd;
  libboost_filesystem-mt-s-gd-;
  libboost_filesystem-mt-s-gd;
  libboost_filesystem-mt-s-gd

CMake Error at C:/dev/Jetbrains/CLion 2019.3.4/bin/cmake/win/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
  Could NOT find Boost (missing: Boost_INCLUDE_DIR filesystem) (Required is
  exact version "1.74.0")

I've verified that the filesystem directory is in the include directory. The filepath for the relevant stuff looks like this:

C:\path\to
|-- Project
|   `-- Source
|       |-- CMake (directory with .cmake files)
|       |   `-- setup_boost.cmake
|       |
|       `-- CMakeLists.txt
|
`-- ThirdParty
    `-- boost
        `-- 1.74.0
            |-- include
            |   |-- filesystem (filesystem directory with contents)
            |   |
            |   |-- filesystem.hpp
            |   `-- version.hpp
            |
            `-- w2016
                |-- vs2019/release64mt/lib
                |   |-- cmake (bunch of cmake files)
                |   `-- libboost_filesystem-vc142-mt-s-x64-1_74.lib
                |
                `-- BUILD_BOOST_WIN.txt (build instructions for vs2019 builds)
        

Does anybody know where I'm going wrong with this? Am I missing some configuration option somewhere? The output looks like it's finding the right libraries, but not the filesystem include directory, even though it's right there.


Solution

  • Found the problem. Long version is that I didn't have the same filesystem structure as I did with previous versions of boost.

    Short version is that all the includes need to be relative to include/boost, and I didn't have the boost part of that; everything was under include directly.