vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

VS build environment is not set when using clang

Open bobbrow opened this issue 4 years ago • 3 comments

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

bobbrow avatar Dec 13 '21 17:12 bobbrow

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

bobbrow avatar Dec 16 '21 19:12 bobbrow

My current workaround:

export CMAKE_C_COMPILER=clang
export CMAKE_CXX_COMPILER=clang++
cd build
cmake ..
cd ..

SupinePandora43 avatar Dec 28 '21 04:12 SupinePandora43

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.

Diyou avatar Aug 14 '22 20:08 Diyou

Does this issue have a solution now?

aiyolo avatar Jul 20 '23 10:07 aiyolo