Configure, build and test a CMake project right from within Sublime Text 3.
Run the command
Package Control: Install Package
and look for CMakeBuilder.
Version 1.0.1 and lower do not have server functionality. What follows is the documentation for version 1.0.1 and lower.
-
Open a
.sublime-project. -
Add this to the project file in your
"settings":"CMakeBuilder": { "build_folder": "$folder/build" }
-
Run the command "CMakeBuilder: Configure" from the command palette.
-
Check out your new build system in your
.sublime-project. -
Press CTRL + B or ⌘ + B.
-
Hit F4 to jump to errors and/or warnings.
See the example project below for more options.
Please see the description of all settings in CMakeBuilder.sublime-settings.
Any of these settings can be changed in your project file, by adding an entry in
{
"settings":
{
"CMakeBuilder":
{
}
}
}
Furthermore, any setting may be overridden by a platform-specific override.
The platform keys are one of `"linux"`, `"osx"` or `"windows"`. For an example
on how this works, see below.
## Example Project File
Here is an example Sublime project to get you started.
```json
{
"folders":
[
{
"path": "."
}
],
"settings":
{
"CMakeBuilder":
{
"build_folder": "$folder/build",
"command_line_overrides":
{
"BUILD_SHARED_LIBS": true,
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": true
},
"generator": "Unix Makefiles",
"windows":
{
"generator": "Visual Studio 15 2017",
"platform": "x64",
"toolset": { "host": "x64" }
}
}
}
}
cmake_clear_cache, arguments:{ with_confirmation : bool }.cmake_configure, arguments:None.cmake_diagnose, arguments:None.cmake_open_build_folder, arguments:None.
CMakeBuilder: Clear CacheCMakeBuilder: ConfigureCMakeBuilder: DiagnoseCMakeBuilder: Browse Build Folder...
All commands are accessible via both the command palette as well as the tools menu at the top of the window.
To force CMake files re-generation run
CMakeBuilder: Clear Cache
and then run
CMakeBuilder: Configure
If you get stuck and don't know what to do, try running
CMakeBuilder: Diagnose
All commands are also visible in the Tools menu under "CMakeBuilder".
If you have unit tests configured with the add_test function of CMake, then you can run those with the "ctest" build variant.
This package invokes cmake --build to build your targets. If you are using the
"Unix Makefiles" generator (make), and you want to use multiple cores, then
you have a few options:
- Don't use
make, instead useninja. - Put
"env": {"CMAKE_BUILD_PARALLEL_LEVEL": 8}as an environment variable in the"cmake"configuration. - Export a
MAKEFLAGSvariable in your .bashrc.
There is syntax highlighting when building a target, and a suitable line regex is set up for each generator so that you can press F4 to go to an error.
This is a reference list for the valid variable substitutions for your
.sublime-project file.
- packages
- platform
- file
- file_path
- file_name
- file_base_name
- file_extension
- folder
- project
- project_path
- project_name
- project_base_name
- project_extension



