Debug CMake Project Creation

778 views Asked by At

I am facing a specific problem, and want advice or a way to debug it.

I am building the Allegro library from source, using: Windows 10, CMake, and Visual Studio 2015 build tools (msbuild).

Source: https://github.com/liballeg/allegro5

The problem is that when I run `cmake --build .' I am getting errors stating that the v100 toolset isn't installed, however I'm making it for Visual Studio 2015, and not 2010. If I open up the solution, or run msbuild directly, it builds perfectly fine.

Is there a way to Debug CMake that will help me see the issue?

Failing Commands:

mkdir _build
pushd _build
cmake.exe ..
cmake --build .
popd

Error:

"C:\Users\matthew\repos\allegro5_build\ALL_BUILD.vcxproj" (default target) (1) -> "C:\Users\matthew\repos\allegro5_build\ZERO_CHECK.vcxproj" (default target) (2) -> (PlatformPrepareForBuild target) -> C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(55,5): error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, please install Visual Studio 2010 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\matthew\repos\allegro5 _build\ZERO_CHECK.vcxproj]

Working Commands:

mkdir _build
pushd _build
cmake.exe ..
msbuild ALLEGRO.sln
popd

I've also tried forcing it to Visual Studio 2015 with commands like:

cmake.exe -G "Visual Studio 14" ..

Note: I've built my own small project with CMake and it builds correctly using CMake --build

To me it seems like something crazy with the allegro cmake build. I have searched through the source to try and find references to v100 and MSVC_2010, but found nothing of concern. I don't want to directly use MSBuild as a work-around because I want to include allegro with ExternalProject_Add, and that fails for the same reason as building it with cmake --build.

How can I go about solving this issue?

1

There are 1 answers

1
morph208 On

I had a similar problem with another library (Zipper, a C++ wrapper around minizip). I was also using CMake and ExternalProject_Add in particular. Exact same error. I spent a lot of time researching the issue. I found a similar problem with another project using Gyp (have a look at the "Known issue" section). For me, the error was occurring during the install target. Changing

BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release

to

BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release --target install INSTALL_COMMAND ""

fixed the issue. Not sure what the problem is. It seems like the default install command CMake uses in an ExternalProject picks the wrong toolset somehow...