ePrivacy and GPDR Cookie Consent by Cookie Consent

CMake

The build with CMake is currently tested with Linux (Fedora, gcc and clang) and for Windows (Microsoft Visual Studio).

The following were used:

  • Fedora 25

  • Linux Kernel 4.04

  • gcc 6.3.1

  • clang 3.8.0

The CMakeFileLists.txt files are located in the solution folder, in the hermes project folder.

Generating with CMake

Create a folder where the CMake output and the results of the build are supposed to be stored. For example, create the cmake_build folder.

Linux

In a terminal go to the directory to which you extracted hermes to and run the following commands:

cmake -G "Unix Makefiles" .
make VERBOSE=1

gcc and clang

Using clang is very similar to using gcc. If both compilers are installed on a Linux machine, you can switch between them and run the same CMake script. After you choose which compiler should be used, you can use the commands listed above to build hermes.

Switching from gcc to clang

The switch can be made running these commands in terminal:

export CC=/usr/bin/clang
export CXX=/usr/bin/clang++

Switching from clang to gcc

The switch can be made running these commands in terminal:

export CC=/usr/bin/gcc
export CXX=/usr/bin/g++

Choosing the architecture

The default build architecture is x86. To choose the x64 architecture for the Linux build, we need to add the value m64 to the CMAKE_CXX_FLAGS variable:

cmake -G "Unix Makefiles" -DCMAKE_CXX_FLAGS=-m64 ..

Windows

Open a console, switch into the folder you've created (e.g. cmake_build) and run the command (for a release build):

cmake -G "Visual Studio 14 Win32" -DCMAKE_BUILD_TYPE=Release ..

Under Windows, as default, CMake uses the newest Visual Studio installation. But a compiler can be used by explicitly specifying it on calling CMake.

By running the following command (among other informations) the available the generators that are available your platform will be listed:

cmake --help

For example using Visual Studio 2013 as generator, the command will look like this:

cmake -G "Visual Studio 12 2013" -DCMAKE_BUILD_TYPE=Release ..

Choosing the architecture

The architecture defaults to x86. To switch to x64 just specify the x64 platform after the generator, according to the following example:

cmake -G "Visual Studio 14 2015 x64" -DCMAKE_BUILD_TYPE=Release ..

Release/Debug

Choosing between release and debug builds is the same for both Windows and Linux. On invoking CMake, pass the parameter -DCMAKE_BUILD_TYPE as in the following examples:

# for Windows
cmake -G "Visual Studio 14 2015 x64" -DCMAKE_BUILD_TYPE=Release ..
cmake -G "Visual Studio 14 2015 x64" -DCMAKE_BUILD_TYPE=Debug ..
 
# for Linux
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ..

Preprocessor definition

Using hermes's preprocessor definition with CMake is also possible by passing it as parameters in the console/terminal.

Definition

Description

CPP_VERSION=[VALUE]

Sets the standard for the C++ compiler to C++03. Accepted value: 03. When it is not used, C++11 will be used.

Example

# for Windows
cmake -G "Visual Studio 14 2015 x64" -DCPP_VERSION=03 ..
 
# for Linux
cmake -G "Unix Makefiles" -DCPP_VERSION=03 ..