CMake generating vc projects with incorrect ordering of toolset props file causing the wrong compiler toolset to be used by msbuild in dev cmd prompt
Currently when using the Visual studio generators in CMake, when a specific toolset (e.g. toolset version 14.27) is specified, cmake is generating vc projects with an incorrect ordering of the toolset props file causing the wrong compiler toolset to be used by msbuild in dev cmd prompt. For example the below is a snippet from a generated vcxproj:
<Import Project="D:/Visual Studio 16 Main/VC/Auxiliary/Build/14.27/Microsoft.VCToolsVersion.14.27.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
this poses a problem because:
- Dev cmd prompt is setting VCToolsVersion to the latest MSVC, so for example Microsoft.VCToolsVersion.14.27.props does nothing as it only works when VCToolsVersion is empty: 14.27.29110
- Microsoft.Cpp.Default.props detects Dev cmd prompt and clears VCToolsVersion.
The fix would be for cmake to generate the project with reverse order of those two props files and then everything will work (in vanilla or dev cmd prompt) e.g.
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="D:/Visual Studio 16 Main/VC/Auxiliary/Build/14.27/Microsoft.VCToolsVersion.14.27.props" />