[英]CMake unable to find Boost Libraries(VS 2017)
I am attempting to create a CMake project with Visual Studio 2017. I want to add Boost to the project. 我正在尝试使用Visual Studio 2017创建CMake项目。我想将Boost添加到项目中。 While I can find Boost, it is unable to find the required components.
虽然可以找到Boost,但找不到所需的组件。 My CMake looks like so.
我的CMake看起来像这样。
# 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. 鉴于我是Visual Studio,所以它像这样编译。
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 我的Boost库目录看起来像
The output from Visual Studio CMake is: Visual Studio CMake的输出是:
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 pre 3.11.0
CMake
versions because of changes in the naming scheme. 由于命名方案的更改,
Boost 1.66.0
在3.11.0
CMake
版本上3.11.0
。 If you have to use this specific version then you need to install a suitable CMake
version ( 3.11.0
or newer) and generate the solution with it. 如果必须使用此特定版本,则需要安装合适的
CMake
版本( 3.11.0
或更高版本)并使用它生成解决方案。 Otherwise Boost 1.65.1
is the last known version to work out of the box and flawlessly with CMake 3.10
. 否则,
Boost 1.65.1
是最后一个已知的版本,可以立即使用,并且可以与CMake 3.10
完美结合。
To find out what Boost
versions your CMake
can handle please have a look into FindBoost.cmake in Modules directory and search for _Boost_KNOWN_VERSIONS
variable. 要找出您的
CMake
可以处理的Boost
版本,请在Modules目录中查找_Boost_KNOWN_VERSIONS
并搜索_Boost_KNOWN_VERSIONS
变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.