microsoft / microsoft/vscode-cmake-tools

Platform (cmake.platform) and toolset (cmake.toolset) options are not passed to CMake and/or active kit ignored when generator is set explicitly

Open
#1,334 4 comments 1 reaction 1 assignee View on GitHub

@andreeis is already working on this.

Since May 20, 2024.

bug Feature: configure Feature: kits
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

Brief Issue Summary

I am trying to configure a project to be built with Visual Studio 2019 using a non-default toolchain (MSVC 2015 amd64), but cannot achieve the required configuration command via VSCode interface and CMake Tools configuration.

As far as I understood, it should work by selecting a kit and/or or by configuring generator / platform / toolset in the settings, but neither option gives the desired result.

Expected

When launching cmake manually as the following:
D:\DevTools\CMake\bin\cmake.EXE --no-warn-unused-cli -DSTATIC:STRING=ON -DBUILD_UNIT_TESTS:STRING=ON -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -Hd:/Source -Bd:/Source/build -G "Visual Studio 16 2019" -A x64 -T v140

I get:

-- The C compiler identification is MSVC 19.0.24245.0
-- The CXX compiler identification is MSVC 19.0.24245.0
Apparent Behavior:
  1. Command palette / CMake: Select a Kit / "VisualStudio.14.0 - amd64".
  2. Set the following configuration in CMake Tools / Extension Settings:
    "cmake.generator": "Visual Studio 16 2019",
    "cmake.platform": "x64",
    "cmake.toolset": "v140"
  3. Command palette / CMake: Delete Cache and Reconfigure

[proc] Executing command: D:\DevTools\CMake\bin\cmake.EXE --no-warn-unused-cli -DSTATIC:STRING=ON -DBUILD_UNIT_TESTS:STRING=ON -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -Hd:/Source -Bd:/Source/build -G "Visual Studio 16 2019"

-A and -T options are missing, so the default toolchain for Visual Studio 2019 is used:

[cmake] -- The C compiler identification is MSVC 19.26.28806.0
[cmake] -- The CXX compiler identification is MSVC 19.26.28806.
Other tested options

I get the same result if platform and toolset are omitted, and/or if cmake.ignoreKitEnv is selected.

I could override the configuration by passing -A x64 -T v140 via cmake.configureArgs, but when I close and reopen VSCode they appear twice on the command line, which results in a cmake error:

[proc] Executing command: D:\DevTools\CMake\bin\cmake.EXE --no-warn-unused-cli -A x64 -T v140 -DSTATIC:STRING=ON -DBUILD_UNIT_TESTS:STRING=ON -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -Hd:/Source -Bd:/Source/build -G "Visual Studio 16 2019" -T v140 -A x64
[cmake] Not searching for unused variables given on the command line.
[cmake] CMake Error: Multiple -T options not allowed
Platform and Versions
  • Operating System: Windows 10
  • CMake Version: 3.17.3
  • VSCode Version: 1.46.1
  • CMake Tools Extension Version: 1.4.1
  • Compiler/Toolchain: Visual Studio 2019 and Visual C++ 2015

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.