VS build environment is not set when using clang
So what is the trick to get VSCode to call vcvars? My preset:
{
"name": "win-ninja-release",
"displayName": "win-ninja-release",
"description": "Ninja generator release",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/ninja/release",
"inherits": ["ninja-general" , "win-vcpkg_settings" ],
"cacheVariables": {
"CMAKE_C_COMPILER" : "$penv{LLVMInstallDir}/bin/clang-cl.exe",
"CMAKE_CXX_COMPILER" : "$penv{LLVMInstallDir}/bin/clang-cl.exe",
"CMAKE_BUILD_TYPE": "Release",
},
"architecture": {
"value": "x64",
"strategy": "external"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": [ "Windows" ],
"intelliSenseMode" : "windows-clang-x64",
"enableMicrosoftCodeAnalysis" : true
}
}
},
Originally posted by @Neumann-A in https://github.com/microsoft/vscode-cmake-tools/issues/1885#issuecomment-991155721
(Copied from #1885)
We currently only auto-configure the vcvars env for you if your clang-cl corresponds to a Visual Studio Kit we've previously scanned.
My current workaround:
export CMAKE_C_COMPILER=clang
export CMAKE_CXX_COMPILER=clang++
cd build
cmake ..
cd ..
Without calling vcvars I'm getting
[cmake] -- The C compiler identification is unknown
[cmake] -- The CXX compiler identification is unknown
And
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set.
When ninja is not in path eventhough it's installed with visual studio.
Seems to be unrelated to clang ... the environment just does not get set. I need to launch vscode from a Visual Studio Developer Command Prompt (the x64 specifically because it defaults to x86 for some reason)
I'd like to keep the presets platform agnostic and free of absolute paths.
Does this issue have a solution now?