Не удалось запустить команду MSBuild для получения значения VCTargetsPath - PullRequest
0 голосов
/ 20 ноября 2018

Я получаю эту ошибку при использовании cmake для создания проекта Visual Studio.Для контекста я пытаюсь выполнить некоторые упражнения на Упражнение (требуется регистрация).Я установил v141 в VS (см. Скриншот ниже).В чем проблема?

ОС: Windows 10 CMake: 3.12.4 Повышение: 1.55.0 Visual Studio Enterprise 2017 15.8.4

enter image description here

CMakeLists.txt

# Get the exercise name from the current directory
get_filename_component(exercise ${CMAKE_CURRENT_SOURCE_DIR} NAME)

# Basic CMake project
cmake_minimum_required(VERSION 2.8.11)

# Name the project after the exercise
project(${exercise} CXX)

# Locate Boost libraries: unit_test_framework, date_time and regex
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework date_time regex)

# Enable C++11 features on gcc/clang
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)")
    set(CMAKE_CXX_FLAGS "-std=c++11")
endif()

# Configure to run all the tests?
if(${EXERCISM_RUN_ALL_TESTS})
    add_definitions(-DEXERCISM_RUN_ALL_TESTS)
endif()

# Get a source filename from the exercise name by replacing -'s with _'s
string(REPLACE "-" "_" file ${exercise})

# Implementation could be only a header
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.cpp)
    set(exercise_cpp ${file}.cpp)
else()
    set(exercise_cpp "")
endif()

# Build executable from sources and headers
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h)

# We need boost includes
target_include_directories(${exercise} PRIVATE ${Boost_INCLUDE_DIRS})

# We need boost libraries
target_link_libraries(${exercise} ${Boost_LIBRARIES})

# Tell MSVC not to warn us about unchecked iterators in debug builds
if(${MSVC})
    set_target_properties(${exercise} PROPERTIES
        COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
endif()

# Run the tests on every build
add_custom_command(TARGET ${exercise} POST_BUILD COMMAND ${exercise})

Ошибка

C:\Users\hurrjae\Exercism\cpp\hello-world>cmake -DBOOST_INCLUDEDIR:PATH="C:\Program Files\Boost\boost_1_55_0"
CMake Error at CMakeLists.txt:8 (project):
Failed to run MSBuild command:

    C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/MSBuild.exe

to get the value of VCTargetsPath:

    Microsoft (R) Build Engine version 15.8.168+ga8fba1ebd7 for .NET Framework
    Copyright (C) Microsoft Corporation. All rights reserved.

    Build started 20/11/2018 9:50:14 PM.
    Project "C:\Users\hurrjae\Exercism\cpp\hello-world\CMakeFiles\3.12.4\VCTargetsPath.vcxproj" on node 1 (default targets).
    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140\Microsoft.Cpp.Platform.targets(57,5): error MSB8020: The build tools for v141 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install v141 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\hurrjae\Exercism\cpp\hello-world\CMakeFiles\3.12.4\VCTargetsPath.vcxproj]
    Done Building Project "C:\Users\hurrjae\Exercism\cpp\hello-world\CMakeFiles\3.12.4\VCTargetsPath.vcxproj" (default targets) -- FAILED.

    Build FAILED.

    "C:\Users\hurrjae\Exercism\cpp\hello-world\CMakeFiles\3.12.4\VCTargetsPath.vcxproj" (default target) (1) ->
    (PlatformPrepareForBuild target) ->
    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140\Microsoft.Cpp.Platform.targets(57,5): error MSB8020: The build tools for v141 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install v141 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\hurrjae\Exercism\cpp\hello-world\CMakeFiles\3.12.4\VCTargetsPath.vcxproj]

        0 Warning(s)
        1 Error(s)

    Time Elapsed 00:00:00.18


Exit code: 1



-- Configuring incomplete, errors occurred!
See also "C:/Users/hurrjae/Exercism/cpp/hello-world/CMakeFiles/CMakeOutput.log".

CMakeOutput.log

The system is: Windows - 10.0.17134 - AMD64

1 Ответ

0 голосов
/ 08 апреля 2019

Сообщения об ошибках, которые вы включили в свой отчет, содержат предложение о том, что вы можете перенастроить проект (ы), и сообщают вам, как это сделать.У меня это получилось.Кроме того, вы можете установить инструменты сборки v141, которые отсутствуют в сообщениях об ошибках, и не нужно перенаправлять их.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...