I am attempting to create a CMake project with Visual Studio 2017. I want to add Boost to the project. While I can find Boost, it is unable to find the required components. My CMake looks like so.
# CMakeList.txt : Top-level CMake project file, do global configuration
# and include sub-projects here.
#
cmake_minimum_required (VERSION 3.10)
project ("FirstProject")
#This project heavily uses C++ 17
set (CMAKE_CXX_STANDARD 17)
#TESTING various flags to try and get it to work.
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
#Error calls for setting this, but doesn't work regardless.
set(BOOST_LIBRARYDIR "${BOOST_ROOT}/stage/lib")
find_package(Boost 1.66.0 REQUIRED COMPONENTS filesystem)
if(Boost_FOUND)
message(WARNING "HERE!!")
endif()
# Include sub-projects.
add_subdirectory ("TestSubProject")
Given that I am Visual Studio it is compiling it like so.
cmake.exe -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\User\CMakeBuilds\Hash\install\x86-Debug" \
-DBOOST_ROOT="D:/Programming_Projects/C++/Dir/ProjectDir/3rdPartyLibraries/boost_1_66_0" \
-DBoost_COMPILER="vc141" \
-DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.13.26128/bin/HostX86/x86/cl.exe" \
-DCMAKE_C_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.13.26128/bin/HostX86/x86/cl.exe" \
-DCMAKE_BUILD_TYPE="Debug" \
-DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "D:\Programming_Projects\C++\Dir\ProjectDir"
My Boost Library directory looks like
The output from Visual Studio CMake is:
CMake Warning at C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.10/Modules/FindBoost.cmake:796 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
Call Stack (most recent call first):
C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.10/Modules/FindBoost.cmake(902): (_Boost_COMPONENT_DEPENDENCIES)
C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.10/Modules/FindBoost.cmake(1537): (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt(20): (find_package)
CMake Warning at C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.10/Modules/FindBoost.cmake:796 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
Call Stack (most recent call first):
C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.10/Modules/FindBoost.cmake(902): (_Boost_COMPONENT_DEPENDENCIES)
C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.10/Modules/FindBoost.cmake(1537): (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt(20): (find_package)
CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.10/Modules/FindBoost.cmake:1923 (message):
Unable to find the requested Boost libraries.
Boost version: 1.66.0
Boost include path:
D:/Programming_Projects/C++/Dir/ProjectDir/3rdPartyLibraries/boost_1_66_0
Could not find the following static Boost libraries:
boost_filesystem
Some (but not all) of the required Boost libraries were found. You may
need to install these additional Boost libraries. Alternatively, set
BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
to the location of Boost.
Call Stack (most recent call first):
CMakeLists.txt(20): (find_package)
-- Configuring incomplete, errors occurred!
See also "C:/Users/User/CMakeBuilds/57d076a1-4dfa-ba3f-98a5-b87b55e6d381/build/x86-Debug/CMakeFiles/CMakeOutput.log".
C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\Christopher\CMakeBuilds\57d076a1-4dfa-ba3f-98a5-b87b55e6d381\install\x86-Debug" -DBOOST_ROOT="D:/Programming_Projects/C++/Dir/ProjectDir/3rdPartyLibraries/boost_1_66_0" -DBoost_COMPILER="vc141" -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.13.26128/bin/HostX86/x86/cl.exe" -DCMAKE_C_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.13.26128/bin/HostX86/x86/cl.exe" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "D:\Programming_Projects\C++\Dir\ProjectDir" returned with exit code: 1
CMake Warning at C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.10/Modules/FindBoost.cmake:796 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
Call Stack (most recent call first):
C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.10/Modules/FindBoost.cmake:902 (_Boost_COMPONENT_DEPENDENCIES)
C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.10/Modules/FindBoost.cmake:1537 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:20 (find_package)
CMake Warning at C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.10/Modules/FindBoost.cmake:796 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
Call Stack (most recent call first):
C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.10/Modules/FindBoost.cmake:902 (_Boost_COMPONENT_DEPENDENCIES)
C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.10/Modules/FindBoost.cmake:1537 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:20 (find_package)
CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.10/Modules/FindBoost.cmake:1923 (message):
Unable to find the requested Boost libraries.
Boost version: 1.66.0
Boost include path:
D:/Programming_Projects/C++/Dir/ProjectDir/3rdPartyLibraries/boost_1_66_0
Could not find the following static Boost libraries:
boost_filesystem
Some (but not all) of the required Boost libraries were found. You may
need to install these additional Boost libraries. Alternatively, set
BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
to the location of Boost.
Call Stack (most recent call first):
CMakeLists.txt:20 (find_package)
Reformulating my previous comments as answer:
Boost 1.66.0
does not work on pre3.11.0
CMake
versions because of changes in the naming scheme. If you have to use this specific version then you need to install a suitableCMake
version (3.11.0
or newer) and generate the solution with it. OtherwiseBoost 1.65.1
is the last known version to work out of the box and flawlessly withCMake 3.10
.To find out what
Boost
versions yourCMake
can handle please have a look into FindBoost.cmake in Modules directory and search for_Boost_KNOWN_VERSIONS
variable.