Search code examples
linuxvisual-studio-codesshcmake

How do I set the CMake executable in VS Code?


I'm using the CMake Tools extension in VS Code to build and run a C++ project on WSL ssh remote.

Where do I set the cmake executable to use?

On Build, CMake Tools executes

[proc] Executing command: /usr/bin/cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++ /remote/work/private/software/repo -G "Unix Makefiles"

But the issue is I need to call cmake3 directly. I do not control the ssh remote machine, and cannot remove cmake2 (which is what the default proc is calling).

When I run this on the remote host I explicitly call cmake3, and would like to do the same here, should be easy enough to change the proc command to cmake3 instead of cmake but I cannot find the option anywhere.

Searched around the settings, and tried calling cmake3 in terminal then just build, but doesn't work.


Solution

  • Use the cmake.cmakePath setting. Quoting the docs:

    Setting Description Default value Supports substitution
    cmake.cmakePath Specify location of the cmake executable. cmake (causes CMake Tools to search the PATH environment variable, as well as some hard-coded locations.) Supports substitution for workspaceRoot, workspaceFolder, workspaceRootFolderName, userHome, ${command:...} and ${env:...}. Other substitutions result in an empty string.

    Check also if your IDE supports the cmakeExecutable member of a configure preset in a CMake preset file.