Building

Let’s cover building the project. There are many ways to build the project (e.g. for documentation, for debug, for production, Linux vs Windows, etc…). Let’s cover how to build the project in Linux. In general, the basic way to build the project is as follows.

Creating Build Directory

Make a directory in which cmake will generate the build instructions. Note the build directory is called cmake-build-debug after the convention of the CLion IDE.

mkdir cmake-build-debug
cd cmake-build-debug

Generating Make Instructions

Now, generate the build instructions.

cmake ..

If you want to build instructions for code coverage, then type in the following.

cmake -DCODE_COVERAGE=on ..

If you want to build a static library, then type in the following. By default, a shared library is created.

cmake -DMAKE_STATIC=on ..

Compiling the Code

To actually compile and link the code, type in the following.

make -j 8

Note the parameter -j 8 signals the number of jobs to use for the build. Here, we signal to use 8 jobs. If you have more cores, increase the number accordingly. By default, the CXX_FLAGS is set to -O3.

Code Testing

make test

Code Coverage

Code coverage requires -DCODE_COVERAGE=on with cmake (available on Linux only).

make ccov-all

Memory Leak Test

Memory leak test requires -DCODE_COVERAGE=on with cmake (available on Linux only).

ctest -T memcheck -j 8

Documentation

Generating documentation is available on Linux with the right dependencies installed. If you are using conda, you will need a few dependencies installed.

conda install -y sphinx sphinx_rtd_theme breathe -c conda-forge

# this package does not exists in the conda repos
pip install sphinx-sitemap

Then, build the doxygen and sphinx documentations as follows. The final documentations will land with sphinx. Sphinx requires doxygen documentation to be generated and the Python breathe package bridges between the two to make C++ documentation via sphinx to work.

make Doxygen Sphinx

Integrated Development Environments

Three Integrated Development Environments (IDEs) are used for development and testing: CLion, XCode and Visual Studio (v2019). CLion is used for development on Linux, XCode is used for development on MacOS and Visual Studio is used for development on Windows. Here are some tips to bring up a development environment to work with these IDEs and the corresponding operating systems.

Please know that only certain targets are available on Linux (and not Windows) such as documentation, profiling and memory leak testing.

CLion

In Linux (Ubuntu), you will need to install the following packages.

sudo apt-get -y install build-essential \
    cmake \
    libboost-all-dev \
    gcc \
    clang \
    gdb \
    libblkid-dev \
    e2fslibs-dev \
    libaudit-dev \
    valgrind \
    ninja-build \
    doxygen \
    graphviz \
    mscgen \
    dia \
    lcov

You may then load up the project with CLion and start to develop.

XCode

On Mac OS, you will need to install homebrew and install the following packages.

brew install git boost python doxygen graphviz

After Python 3.x is installed with homebrew, then install the following Python packages.

pip3 install sphinx sphinx-rtd-theme breathe sphinx-sitemap

Visual Studio

In Windows, you will need a way to install the boost library. The recommended way is to use vspkg. After you clone vspkg, perform the following steps.

git clone https://github.com/microsoft/vcpkg.git
cd vckpg
bootstrap-vcpkg.bat
vcpkg install boost:x64-windows
vcpkg integrate install