CMake integration in Visual Studio Code
Перейти к файлу
vector-of-bool 2d83dcfe61 Clean up test imports and run a format pass over the codebase 2018-03-25 16:44:50 -06:00
.vscode
docs
images
res
schemas
scripts
src
test
.clang-format
.gitattributes
.gitignore
.travis.yml
.vscodeignore
CHANGELOG.md
LICENSE.txt
README.md
THIRD.md
appveyor.yml
package-lock.json
package.json
tsconfig.json
tslint.json

README.md

CMake Tools

CMake Tools provides the native developer a full-featured, convenient, and powerful configure+build workflow for CMake-based projects within the Visual Studio Code editor.

This extension itself does not provide language support for the CMake scripting language. For that I recommend this extension.

Calling All Users:

One of the number-one most important things I need help with is documentation. The changelog may mention all important changes and features, but it's hard for a new user to get acclimated and find all the features and options.

If you'd like to help, please head on over to the GitHub project's wiki, or add a PR for relevant information in the docs/ subdirectory.

What's New?

0.10.0

  • VS 2017 environment detection! Finally! Note: We use vswhere to find the local Visual Studio installation, and this program is only bundled with Visual Studio 2017 Update 2 (or newer). Please install (at least) update 2 for automatic detection to work
  • Lots of small bugfixes and tweaks, and debugging documentation updates. Many thanks to Yuri Timenkov!
  • 0.10.1:
    • Option cmake.buildBeforeRun to enable/disable building of a target before running/debugging it. (Default is enabled)
    • Changes in the way Visual Studio generators are loaded and detected. Now, generators for detected build environments are added to the preferred list. (Thanks to Yuri Timenkov!)
    • Fix issue where cmake-server could be restarted too quickly and break itself.
    • ${variable} substitution is now supported in the cmake.*Environment settings. (Thanks to Damien Courtois!)
  • 0.10.2:
    • Support for Emscripten environment detection. Set the cmake.emscriptenSearchDirs setting or the EMSCRIPTEN environment variable to the root path of the Emscripten SDK (Contains cmake/Modules/Platform/Emscripten.cmake)
    • Fix environment variables not passing from settings.json to configuration.

As always: Please report any issues, questions, or comments to the GitHub project issues list!

Issues? Questions? Feature requests?

PLEASE, if you experience any problems, have any questions, or have an idea for a new feature, create an issue on the GitHub page!

I'm only one person with no QA team, so I can't test all the different possible configurations you may have, but I'll gladly help anyone fix issues relating to this extension.

Getting Started

CMake Tools provides several pieces of functionality to make it easier to work with CMake-based projects within Visual Studio Code. For example, it adds a "CMake: Build" command to the command palette, which is bound to the F7 key by default.

By default, CMake Tools assumes that you place your CMake build tree in a subdirectory of the source tree called build. This can be configured with the cmake.buildDirectory configuration option, which can be set globally or on a per-project basis. If you try to build but do not yet have a build directory, CMake Tools will prompt you to configure the project.

CMake Tools uses a configuration setting cmake.configureSettings to define options to pass to CMake when configuring the project. In this way, build settings can be stored as part of the project in settings.json in the .vscode directory.

The Status bar

CMake Status Bar Items

CMake Tools provides a few buttons on the statusbar:

  1. The name of the current project, the current build type (Debug, Release, etc.), and the current status of CMake Tools. Click this button to change the active configuration.
  2. A build button. Click this button to build the default target. Quickly invoking a build is also bound to the F7 key by default. While building, this button changes into a stop button. Clicking the stop button will cancel the currently running build/configure process.
  3. The default/active target. This is the target that will be invoked if run the build command. Clicking on this button will let you select a different target to be built by default.
  4. The Target Debugging launcher (must be explicitly enabled, see below).
  5. The active debug target (must be explicitly enabled).
  6. The CTest results button. Click this button to rebuild and run CTest tests.

CMake Tools will also show the most recent line of CMake output as a status message to the right of the buttons. Invoking a command will open the CMake/Build output channel, where the progress and output of the build/configure commands can be seen.

Target Debugging

Target Debugging, allows developers to easily use the Visual Studio Code Debugger with their CMake targets without having to write a launch.json. Read about enabling and using the feature here.

Compiler Diagnostics

CMake Tools also parses the compiler output of GCC, Clang, and MSVC looking for diagnostics. It will populate the diagnostics for files which produce any warnings or errors.

CTest Tests

CMake Tools also features integration with CTest, both executing and displaying results, even inline in the editor:

Failing Check

(Currently, only Catch test output is supported)

Other Features

  • Command to quickly generate a very basic CMakeLists.txt and C++ source file.
  • Set CMake configuration values in settings.json.
  • Provides diagnostics for CMake scripts.
  • Quickly jump into CMakeCache.txt