vscode-cmake-tools
vscode-cmake-tools copied to clipboard
Platform (cmake.platform) and toolset (cmake.toolset) options are not passed to CMake and/or active kit ignored when generator is set explicitly
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:
- Command palette / CMake: Select a Kit / "VisualStudio.14.0 - amd64".
- Set the following configuration in CMake Tools / Extension Settings: "cmake.generator": "Visual Studio 16 2019", "cmake.platform": "x64", "cmake.toolset": "v140"
- 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
As a workaround, between step 2 and 3, you need to delete the build folder and reload the project. Not only delete the build folder (which equals to a 'delete cache and reconfigure'). Not only reload project without deleting the cache. Delete cache and reload project.
We fixed this problem (the need to delete the cache before a reload) for 'cmake.generator', but we weren't aware that the same happens for 'cmake.platform' and 'cmake.toolset'.
Then, we plan to fix for all 3 settings the need to reload.
What do you mean by "reload the project"?
If there is an issue with settings changes being reflected, then you can run the Developer: Reload Window
command in VS Code.
I just hit this,
Repro:
- change/add these settings. "cmake.platform": "arm64", "cmake.toolset": "host=x64",
Bug: They aren't used when Delect Cache and Reconfigure are used until CMakeCache.txt is deleted from the build folder and then Reload Window is done.