question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Toolset and Platform are swapped when reading from CMakeCache.txt

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bobbrowcommented, Feb 25, 2020

Fixed in 1.3.1

1reaction
glenvancommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

cmake-gui makes CMakeCache.txt before a menu is ... - GitLab
Selecting the compiler or variant of compiler is a bit different because it affects the outcome of try-compile commands. In the Tools menu...
Read more >
Remote build and deployment excluded path resets. Cannot ...
I am using the remote build and deployment tools to develop for a local arm64 machine. ... Cannot read CMakeCache.txt Follow. Completed.
Read more >
CMake 3.25.1 Documentation
CMake will write a CMakeCache.txt file to identify the directory as a build tree and store persistent information such as buildsystem configuration options....
Read more >
CMake Tutorial - Medium
I have read numerous documentations and tutorials to understand CMake and its ... with CMakeCache.txt and some other artefects about build configuration.
Read more >
Ubuntu Manpage: cmake - Cross-Platform Makefile Generator.
Use with care, you can make your CMakeCache.txt non-working. ... Some CMake generators support a toolset name to be given to the native...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found