CMakeBuilder
Configure, build and test a CMake project right from within Sublime Text 3.
Details
Installs
- Total 11K
- Win 4K
- Mac 2K
- Linux 4K
Dec 21 | Dec 20 | Dec 19 | Dec 18 | Dec 17 | Dec 16 | Dec 15 | Dec 14 | Dec 13 | Dec 12 | Dec 11 | Dec 10 | Dec 9 | Dec 8 | Dec 7 | Dec 6 | Dec 5 | Dec 4 | Dec 3 | Dec 2 | Dec 1 | Nov 30 | Nov 29 | Nov 28 | Nov 27 | Nov 26 | Nov 25 | Nov 24 | Nov 23 | Nov 22 | Nov 21 | Nov 20 | Nov 19 | Nov 18 | Nov 17 | Nov 16 | Nov 15 | Nov 14 | Nov 13 | Nov 12 | Nov 11 | Nov 10 | Nov 9 | Nov 8 | Nov 7 | Nov 6 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 1 | 1 | 1 | 1 | 6 | 0 | 0 | 2 | 1 | 1 | 4 | 2 | 1 | 0 | 2 | 0 | 1 | 0 | 1 | 1 | 1 | 1 | 2 | 1 | 0 | 0 | 0 | 0 | 2 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 2 | 4 | 2 |
Mac | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 | 0 | 0 | 1 |
Linux | 3 | 4 | 0 | 1 | 1 | 0 | 3 | 0 | 2 | 0 | 2 | 2 | 0 | 2 | 0 | 0 | 0 | 0 | 3 | 0 | 2 | 0 | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 1 | 3 | 1 |
Readme
- Source
- raw.githubusercontent.com
CMakeBuilder
Configure, build and test a CMake project right from within Sublime Text 3.
Installation
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.
TL;DR
Open a
.sublime-project
.Add this to the project file in your
"settings"
:"cmake": { "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.
Reference
The CMake Dictionary
By “CMake dictionary” we mean the JSON dictionary that you define in your
"settings"
of your sublime project file with key "cmake"
. The CMake
dictionary accepts the following keys:
build_folder
[required string]
A string pointing to the directory where you want to build the project. A
good first choice is $folder/build
.
command_line_overrides
[optional dictionary]
A dictionary where each value is either a string or a boolean. The key-value
pairs are passed to the CMake invocation when you run cmake_configure
as
-D
options. For example, if you have the key-value pair "MY_VAR": "BLOB"
in the dictionary, the CMake invocation will contain -D MY_VAR=BLOB
. Boolean
values are converted to ON
or OFF
. For instance, if you have the key-value
pair "BUILD_SHARED_LIBS": true
in the dictionary, the CMake invocation will
contain -D BUILD_SHARED_LIBS=ON
.
generator
[optional string]
A JSON string specifying the CMake generator.
Available generators for osx: “Ninja” and “Unix Makefiles”.
If no generator is specified on osx, “Unix Makefiles” is the default generator. For “Ninja”, you must have ninja installed. Install it with brew.
Available generators for linux: “Ninja” and “Unix Makefiles”.
If no generator is specified on linux, “Unix Makefiles” is the default generator. For “Ninja”, you must have ninja installed. Install it with your package manager.
Available generators for windows: “Ninja” and “Visual Studio”.
If no generator is specified on windows, “Visual Studio” is the default generator. You need Microsoft Visual Studio C++ in order to configure your project wether you're using Ninja or Visual Studio.
root_folder
[optional string]
The directory where the root CMakeLists.txt file resides. If this key is not present, the directory where the sublime project file is located is assumed to have the root CMakeLists.txt file.
env
[optional dictionary]
This is a dict of key-value pairs of strings. Place your environment variables at configure time in here. For example, to select clang as your compiler if you have gcc set as default, you can use
"env": { "CC": "clang", "CXX": "clang++" }
platform
[optional string]
For generators that support a platform argument. In the case of this plugin
that would be Visual Studio. In practise, set this to “x64” to build 64-bit
binaries instead of the default 32-bit. This is the -A
argument passed to
CMake.
toolset
[optional dictionary]
For generators that support a toolset argument. In the case of this plugin
that would be Visual Studio. In practise, set this to { "host": "x64" }
to
use the 64-bit compiler instead of the 32-bit compiler. This is the -T
argument passed to CMake. As in the case of command_line_overrides
, the
dictionary is converted into a string as in key1=value1;key2=value2
.
vs_major_version
[optional integer]
When using the Ninja generator on Windows, by default it will use the most
recent Visual Studio SDK on the system. If you need another SDK, define
the vs_major_version
number to be 15 or 16.
Any key 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.
{
"folders":
[
{
"path": "."
}
],
"settings":
{
"cmake":
{
"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" }
}
}
}
}
Available Scripting Commands
cmake_clear_cache
, arguments:{ with_confirmation : bool }
.cmake_configure
, arguments:None
.cmake_diagnose
, arguments:None
.cmake_open_build_folder
, arguments:None
.
Available Commands in the Command Palette
CMakeBuilder: Clear Cache
CMakeBuilder: Configure
CMakeBuilder: Diagnose
CMakeBuilder: Browse Build Folder...
All commands are accessible via both the command palette as well as the tools menu at the top of the window.
Available Settings
silence_developer_warnings
: JSON bool
If true, will add the option -Wno-dev
to the CMake invocation of the
cmake_configure
command.
always_clear_cache_before_configure
: JSON bool
If true, always clears the CMake cache before the cmake_configure
command is
run.
ctest_command_line_args
: JSON string
Command line arguments passed to the CTest invocation when you run
cmake_run_ctest
.
Clearing the cache
To force CMake files re-generation run
CMakeBuilder: Clear Cache
and then run
CMakeBuilder: Configure
Diagnostics/Help
If you get stuck and don't know what to do, try running
CMakeBuilder: Diagnose
Tools Menu
All commands are also visible in the Tools menu under “CMakeBuilder”.
Running unit tests with CTest
If you have unit tests configured with the add_test function of CMake, then you can run those with the “ctest” build variant.
Using multiple cores with make
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
MAKEFLAGS
variable in your .bashrc.
Syntax highlighting for various generators
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.
List of Valid Variable Substitutions
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