Starting with version 0.5.0 yasmine support builds on different platforms using CMake.

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

The CMakeFileLists.txt files can be found in solution folder, in the yasmine project folder and in folders of the three examples: hello yasmine!, classic farmroad and forty two.

Generating with CMake

Create a folder where the CMake output and the results of build are generated. For example, create the cmake_build folder.


In a terminal, go to directory which you extracted yasmine 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 the Linux OS, 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 yasmine.

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. It's looking like this:

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


In console, go to the location of the folder you've created (cmake_build) and run the command:

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, will be listed the generators that are available on the platform you use:

cmake --help

For example, using Visual Studio 2013 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 the 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 ..


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 definitions

Using yasmine's preprocessor definitions with CMake is also possible by passing them as parameters in the console/terminal.




Use when you want to use no logging at all (no logging code is created).


When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.


If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.


If this is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.


Sets the optimization type. Supported values: SPEED (optimizes the code for fast execution) and SIZE (optimizes the code for low memory consumption). Default value is SPEED.


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


Sets the path to the include directory for boost.


Sets the path to the boost libraries.

How to use

# for Windows
# for Linux

C++03 compatibility

For compiling yasmine using the C++03 standard, the CPP_VERSION flag must be set to value '03'. This option is the same for Linux and Windows.

The path to boost library can be passed using Y_BOOST_LIB_INCLUDE and Y_BOOST_LIB_PATH.