Getting started with Bazel

Nov 20, 2015

I have spent the last month playing with a new build framework called [Bazel] ( Bazel is the open source version of Google’s Blaze build system. This particular build system markets itself as:

Correct, reproducible, fast builds for everyone

After using it for the last month, it is pretty bad ass. There are some quirks which come along with using it in beta form but they haven’t been too bad (yet). Prior to using Bazel for C++, I had been using a mixture of build systems for larger projects such as CMake, scons, make, Gradle, etc.

My thoughts so far:

  • Bazel is way faster than the others

  • Migration from any build system to Bazel sucks.

  • Java install on the dev box, ugh but I’ll deal with it….

  • No tightly integrated plugin system like CMake or Gradle. Honestly, I don’t miss it either. As an example, instead of using CMake’s externalproject_add, I just use git submodules.

  • Hand-rolling BUILD files for external projects (dependencies) can suck.

  • For the above issue, this example project has been great.

All this being said, I’ve drank the Bazel kool aide and ain’t going back….well until I need to use Windows again.

Installing it:

git clone

cd bazel

git checkout tags/0.1.0


sudo cp output/bazel /usr/bin

Useful terminal alias:

alias bzb="bazel build //..." 

alias bzt="bazel test //..."

Transitioning from CMake to Bazel:

Figure out all the third party dependencies, add git submodules, and create BUILD files. See the above mentioned GitHub repository for concrete examples.

  1. Delete every CMakeLists.txt file

  2. Add a top level WORKSPACE file

  3. Add BUILD files for libraries, executables, etc

The biggest pain that I am really having with this process as my favorite IDE, CLion, doesn’t support non-CMake projects so I am back to VIM.