Visual Studio wants to build with wrong platform toolset

I have met the same issue as @Greg and @Jahmic when building OpenCV on Windows using CMake and VS 15 2017 (toolset v141).

I get this error:

error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found.

It happens when the target config is not the first specified for DCMAKE_CONFIGURATION_TYPES in the CMAKE_ARGS.


EDIT (12/01/2020): clarification for Stanislav

It's been a while, so I hope I will not say wrong things or confuse you more since I am no expert... So take this answer very carefully please.

In my case, I was when building my project solution in a CI after adding OpenCV in our Superbuild.

The configuration of the Superbuild was done by these lines:

cmake.exe -G "Visual Studio 15 2017" -A "x64" ../myProject/Superbuild
cmake.exe --build . --config RelWithDebInfo --target ALL_BUILD

But OpenCV doesn't support the config RelWithDebInfo. Indeed, in our External-OpenCV.cmake file I can find:

ExternalProject_Add(OpenCV GIT_REPOSITORY "https://github.com/opencv/opencv.git" GIT_TAG "${OPENCV_TAG}" SOURCE_DIR OpenCV BINARY_DIR OpenCV-build #CMAKE_GENERATOR ${gen} #CMAKE_GENERATOR_PLATFORM "x64" CMAKE_ARGS ${ep_common_args} -DCMAKE_CONFIGURATION_TYPES:STRING=Release;Debug; -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_WITH_STATIC_CRT:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_WITH_DEBUG_INFO:BOOL=ON -DBUILD_DOCS:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF -DBUILD_PERF_TESTS:BOOL=OFF -DBUILD_TESTS:BOOL=OFF -DCMAKE_INSTALL_PREFIX:PATH=${OPENCV_INSTALL_DIR}

So the lines have been changed to these ones:

cmake.exe -G "Visual Studio 15 2017" -A "x64" -T v141 ../myProject/Superbuild
cmake.exe --build . --config Release --target ALL_BUILD

Now we have understood that we didn't need to add the target platform option (-T v141) so it has been removed.


Same error for me recently with VS2017.

Turned out the solution was merely missing a dependent project.
If this is the cause, you should see something like:

Done building project "someproject.vcxproj" -- FAILED.  

on the next line after the error message:

error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found.

This error can be confusing since your projects may have already been retargeted.


The project is set to build with VS2010 compilers (platform toolset). You might have uninstalled VS2010 and got this error.

You can change the platform toolset in project properties->General->Platform Toolset. Change it Visual Studio 2012.