Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolset and Platform are swapped when reading from CMakeCache.txt #1065

Closed
glenvan opened this issue Feb 12, 2020 · 5 comments
Closed

Toolset and Platform are swapped when reading from CMakeCache.txt #1065

glenvan opened this issue Feb 12, 2020 · 5 comments
Assignees
Labels
bug a bug in the product Feature: configure fixed (release pending) fixed in pre-release and is pending official release
Milestone

Comments

@glenvan
Copy link

glenvan commented Feb 12, 2020

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
@bobbrow
Copy link
Member

bobbrow commented Feb 12, 2020

Thanks for catching this. Should be an easy fix.

@bobbrow bobbrow added bug a bug in the product Feature: configure labels Feb 12, 2020
@andreeis andreeis added this to the 1.4.0 milestone Feb 12, 2020
@Celeborn2BeAlive
Copy link

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".

@glenvan
Copy link
Author

glenvan commented Feb 18, 2020

@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.

@avkudrin
Copy link

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

@bobbrow bobbrow modified the milestones: 1.4.0, 1.3.1 Feb 18, 2020
@bobbrow bobbrow added the fixed (release pending) fixed in pre-release and is pending official release label Feb 24, 2020
@bobbrow
Copy link
Member

bobbrow commented Feb 25, 2020

Fixed in 1.3.1

@bobbrow bobbrow closed this as completed Feb 25, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug a bug in the product Feature: configure fixed (release pending) fixed in pre-release and is pending official release
Projects
None yet
Development

No branches or pull requests

5 participants