title: CMake: failed to run MSBuild command: MSBuild.exe
body: <p>I am trying to build <a href="https://ethiy.github.io/FastImageAnnotationTool/" rel="noreferrer">FIAT</a> using <code>CMake</code> GUI on windows 10. </p>
  
  <pre><code>CMake Error at CMakeLists.txt:3 (project):
    Failed to run MSBuild command:
  
      MSBuild.exe
  
    to get the value of VCTargetsPath:
  Configuring incomplete, errors occurred!
  </code></pre>
  
  <p>I configured CMake to use Visual Studio 15 2017 compiler.</p>
  
  <p>How can I fix this? </p>
  
  <p>If needed, here is the CMakeLists.txt file</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.2)
  include(CheckCXXCompilerFlag)
  project(FIAT CXX)
  
  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
  
  if(CHECK_CXX_COMPILER_USED1)
  # Using Visual Studio C++
  elseif("${CMAKE_CXX_COMPILER_ID}x" STREQUAL "MSVCx")
  # Using Intel C++
  elseif("${CMAKE_CXX_COMPILER_ID}x" STREQUAL "Intelx")
  else(CHECK_CXX_COMPILER_USED1)
      # GCC or Clang
      # At least C++11
      CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
      CHECK_CXX_COMPILER_FLAG("-std=c++1z" COMPILER_SUPPORTS_CXX1Z)
      CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
      CHECK_CXX_COMPILER_FLAG("-std=c++1y" COMPILER_SUPPORTS_CXX1Y)
      CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
      if(COMPILER_SUPPORTS_CXX17)
          set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
      elseif(COMPILER_SUPPORTS_CXX1Z)
          set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z")
      elseif(COMPILER_SUPPORTS_CXX14)
          set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
      elseif(COMPILER_SUPPORTS_CXX1Y)
          set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y")
      elseif(COMPILER_SUPPORTS_CXX11)
          set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
      else(COMPILER_SUPPORTS_CXX17)
          message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
      endif(COMPILER_SUPPORTS_CXX17)
  
      if(CHECK_CXX_COMPILER_USED2)
      elseif("${CMAKE_CXX_COMPILER_ID}x" MATCHES "Clangx")
          # Using Clang
          set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-global-constructors")
      elseif("${CMAKE_CXX_COMPILER_ID}x" STREQUAL "GNUx")
          # Using GCC
          set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
      endif(CHECK_CXX_COMPILER_USED2)
  endif(CHECK_CXX_COMPILER_USED1)
  
  #OpenCV
  FIND_PACKAGE(OpenCV REQUIRED core imgproc highgui imgcodecs)
  if(OpenCV_Found)
      INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIR})
  endif(OpenCV_Found)
  
  #Boost
  FIND_PACKAGE(Boost REQUIRED program_options filesystem)
  if(Boost_FOUND)
      INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
  else(Boost_FOUND)
      set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "C:/local/boost_1_60_0/")
      set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "C:/local/boost_1_60_0/lib64-msvc-14.0")
      Find_PACKAGE(Boost)
      if(Boost_FOUND)
          INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
      endif(Boost_FOUND)
  endif(Boost_FOUND)
  
  set(Boost_USE_STATIC_LIBS        OFF)
  set(Boost_USE_MULTITHREADED      ON)
  set(Boost_USE_STATIC_RUNTIME     OFF)
  set(BOOST_ALL_DYN_LINK           OFF)
  
  # Annotation Lib
  file(GLOB_RECURSE FIAT_LIB_HEADERS
      "${FIAT_SOURCE_DIR}/src/image/*.h" "${FIAT_SOURCE_DIR}/src/annotation/*.h" "${FIAT_SOURCE_DIR}/src/tools/*.h"
  )
  
  file(GLOB_RECURSE FIAT_LIB_SRC
      "${FIAT_SOURCE_DIR}/src/image/Image.cpp" "${FIAT_SOURCE_DIR}/src/annotation/*.cpp" "${FIAT_SOURCE_DIR}/src/tools/*.cpp"
  )
  
  add_library(utilities ${INCLUDE_DIRECTORIES} ${FIAT_LIB_HEADERS} ${FIAT_LIB_SRC})
  target_link_libraries (utilities ${Boost_LIBRARIES} ${OpenCV_LIBRARIES} )
  
  if(CHECK_CXX_COMPILER_USED_UTILITIES)
  
  elseif("${CMAKE_CXX_COMPILER_ID}x" STREQUAL "MSVCx")
    # using Visual Studio C++
  elseif("${CMAKE_CXX_COMPILER_ID}x" STREQUAL "Intelx")
    # using Intel C++
  else()
    # GCC or Clang
      target_link_libraries (utilities m )
  endif(CHECK_CXX_COMPILER_USED_UTILITIES)
  
  # Annotate
  file(GLOB_RECURSE FIAT_ANNOTATE_HEADERS
  )
  
  file(GLOB_RECURSE FIAT_ANNOTATE_SRC
      "${FIAT_SOURCE_DIR}/src/app/annotate.cpp"
  )
  
  add_executable(annotate ${INCLUDE_DIRECTORIES} ${FIAT_LIB_HEADERS} ${FIAT_ANNOTATE_HEADERS} ${FIAT_ANNOTATE_SRC})
  target_link_libraries(annotate utilities ${Boost_LIBRARIES} ${OpenCV_LIBRARIES})
  
  
  if(CHECK_CXX_COMPILER_USED_ANNOTATE)
  elseif("${CMAKE_CXX_COMPILER_ID}x" STREQUAL "MSVCx")
    # using Visual Studio C++
  elseif("${CMAKE_CXX_COMPILER_ID}x" STREQUAL "Intelx")
    # using Intel C++
  else()
    # GCC or Clang
      target_link_libraries (annotate m)
  endif(CHECK_CXX_COMPILER_USED_ANNOTATE)
  </code></pre>
  
  <p>As per your recommendation, I tried building from the <code>Developer Command Prompt for VS2015</code> but still got the following error:</p>
  
  <pre><code>msbuild FIAT.vcxproj /p:configuration=debug
  Microsoft (R) Build Engine version 14.0.25420.1
  Copyright (C) Microsoft Corporation. All rights reserved.
  
  Build started 6/12/2017 5:16:26 AM.
  Project "E:\Work\FastImageAnnotationTool-master\FIAT.vcxproj" on node 1 (default targets).
  E:\Work\FastImageAnnotationTool-master\FIAT.vcxproj(1,1): error MSB4067: The element &lt;#text&gt; beneat
  h element &lt;Project&gt; is unrecognized.
  Done Building Project "E:\Work\FastImageAnnotationTool-master\FIAT.vcxproj" (default targets) -- FA
  ILED.
  
  
  Build FAILED.
  
  "E:\Work\FastImageAnnotationTool-master\FIAT.vcxproj" (default target) (1) -&gt;
    E:\Work\FastImageAnnotationTool-master\FIAT.vcxproj(1,1): error MSB4067: The element &lt;#text&gt; bene
  ath element &lt;Project&gt; is unrecognized.
  
      0 Warning(s)
      1 Error(s)
  
  Time Elapsed 00:00:00.03
  </code></pre>
  
  <p>Here is my project's <code>.vcxproj</code> file</p>
  
  <pre><code>&lt;Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;  
    &lt;ItemGroup&gt;  
      &lt;ProjectConfiguration Include="Debug|Win32"&gt;  
        &lt;Configuration&gt;Debug&lt;/Configuration&gt;  
        &lt;Platform&gt;Win32&lt;/Platform&gt;  
      &lt;/ProjectConfiguration&gt;  
      &lt;ProjectConfiguration Include="Release|Win32"&gt;  
        &lt;Configuration&gt;Release&lt;/Configuration&gt;  
        &lt;Platform&gt;Win32&lt;/Platform&gt;  
      &lt;/ProjectConfiguration&gt;  
    &lt;/ItemGroup&gt;  
    &lt;Import Project="$(VCTargetsPath)\Microsoft.Cpp.default.props" /&gt;  
    &lt;PropertyGroup&gt;  
      &lt;ConfigurationType&gt;Application&lt;/ConfigurationType&gt;  
      &lt;PlatformToolset&gt;v120&lt;/PlatformToolset&gt;  
    &lt;/PropertyGroup&gt;  
    &lt;Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /&gt;  
    Annotation.cpp Annotations.cpp app/annotate.cpp - image/Image.cpp test/image-test.cpp - tools/tools.cpp
  
    &lt;ItemGroup&gt;  
      &lt;ClInclude Include="/src/annotation/Annotation.cpp" /&gt;  
    &lt;/ItemGroup&gt;  
    &lt;ItemGroup&gt;  
      &lt;ClInclude Include="/src/annotation/Annotation.h" /&gt;  
    &lt;/ItemGroup&gt;  
  
    &lt;ItemGroup&gt;  
      &lt;ClInclude Include="/src/annotation/Annotations.cpp" /&gt;  
    &lt;/ItemGroup&gt;  
    &lt;ItemGroup&gt;  
      &lt;ClInclude Include="/src/annotation/Annotation.h" /&gt;  
    &lt;/ItemGroup&gt;  
  
    &lt;ItemGroup&gt;  
      &lt;ClInclude Include="/src/app/annotate.cpp" /&gt;  
    &lt;/ItemGroup&gt;  
  
    &lt;ItemGroup&gt;  
      &lt;ClInclude Include="/src/image/Image.cpp" /&gt;  
    &lt;/ItemGroup&gt;  
    &lt;ItemGroup&gt;  
      &lt;ClInclude Include="/src/image/Image.h" /&gt;  
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;  
      &lt;ClInclude Include="/src/test/image-test.cpp" /&gt;  
    &lt;/ItemGroup&gt; 
  
    &lt;ItemGroup&gt;  
      &lt;ClInclude Include="/src/tools/tools.cpp" /&gt;  
    &lt;/ItemGroup&gt;  
    &lt;ItemGroup&gt;  
      &lt;ClInclude Include="/src/tools/tools.h" /&gt;  
    &lt;/ItemGroup&gt; 
  
    &lt;Import Project="$(VCTargetsPath)\Microsoft.Cpp.Targets" /&gt;  
  &lt;/Project&gt;  
  </code></pre>