Vscode-cmake-tools: Toolset and Platform are swapped when reading from CMakeCache.txt

Created on 12 Feb 2020  路  5Comments  路  Source: microsoft/vscode-cmake-tools

Brief Issue Summary

When a cmake.toolset and cmake.platform are set in settings.json, they are used correctly on the first CMake configuration.

After restarting VS Code, on subsequent configurations, these values are mixed up when read from CMakeCache.txt.

In src/drivers/cmfileap-driveri.ts (line 68 in the develop branch), toolset should be platform and platform should be toolset.

      toolset: cache.get('CMAKE_GENERATOR_PLATFORM') ? cache.get('CMAKE_GENERATOR_PLATFORM')!.value : undefined,
      platform: cache.get('CMAKE_GENERATOR_TOOLSET') ? cache.get('CMAKE_GENERATOR_TOOLSET')!.value : undefined

May relate to #222.

Expected:

First CMake Configuration works, all subsequent CMake configurations work. CMake command line should be:

[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -Hc:/Code/myProj -Bc:/Code/myProj/build -G "Visual Studio 14 2015" -T v140 -A x64

Apparent Behavior:

For subsequent builds, platform and toolset are reversed, resulting in the error:

[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -Hc:/Code/myProj-Bc:/Code/myProj/build -G "Visual Studio 14 2015" -T x64 -A v140
[cmake] CMake Error: Error: generator platform: v140
[cmake] Does not match the platform used previously: x64

Example:

settings.json:

{
    "cmake.generator": "Visual Studio 14 2015",
    "cmake.toolset": "v140",
    "cmake.platform":"x64",
}

CMake Tools Log

[main] Configuring folder: myProj
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -Hc:/Code/myProj-Bc:/Code/myProj/build -G "Visual Studio 14 2015" -T x64 -A v140
[cmake] Not searching for unused variables given on the command line.
[cmake] CMake Error: Error: generator platform: v140
[cmake] Does not match the platform used previously: x64
[cmake] Either remove the CMakeCache.txt file and CMakeFiles directory or choose a different binary directory.

Platform and Versions

  • Operating System: Windows 10 x64
  • CMake Version: 3.16.2
  • VSCode Version: 1.42
  • CMake Tools Extension Version: 1.3.0
  • Compiler/Toolchain: Visual C++ 2015 amd64
configure bug fixed (release pending)

All 5 comments

Thanks for catching this. Should be an easy fix.

I confirm this bug which is pretty annoying since it forces me to recreate the build directory every time I restart VS Code.
However in my case I have nothing related to cmake.toolset and cmake.platform in settings.json (I checked workspace and user settings). I'm just using the "CMake: Select Kit" command the first time I configure, after that vscode-cmake-tools seems to be able to remember what to use even if it's not in my settings, but as mentionned in the issue it put "-T x64" in the command line instead of "-A x64".

@Celeborn2BeAlive I have been getting away with just deleting CMakeCache.txt from my build folder before opening VS Code again.

Still a pain, but at least you don't lose your built object files.

The bug may be temporarily worked around by enabling cmake server in preferences.
"cmake.useCMakeServer": true

Fixed in 1.3.1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BarrettLowe picture BarrettLowe  路  4Comments

amigo421 picture amigo421  路  3Comments

j-m picture j-m  路  5Comments

decimad picture decimad  路  6Comments

svenevs picture svenevs  路  5Comments