Skip to content
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

121 lines (94 sloc) 3.8 KB


The following references shows how to use FSeam



CMake required to use the cmake tooling (version minimum required is the 3.10.0)

Usage of cpp 17, it is needed to compile with gcc 7 or later.

# bash command line
g++ <sources> -std=c++17
# cmake command
set_target_properties(target PROPERTIES CXX_STANDARD 17)

Usage of Python for the generator, if not installed yet :

# fedora
sudo yum install python

# unbuntu
sudo apt-get install python

Usage of python package ply because of which has a dependency on python ply.lex

sudo apt-get install python3-pip
sudo pip install ply

Usage of catch2 into the test (v2.7.0 at this day 31/03/2019), if not installed yet you can do either :
-- install the latest version from the repo directly

git clone
cd Catch2 && mkdir build && cd build
sudo make install

-- or download the file directly from the selected version (here v2.7.0):

cd /path/to/your/fseam/clone/test/
curl -O

Installation of FSeam

Use the following commands in order to install FSeam

  git clone  
  cd FSeam  
  mkdir build  
  cd build  
  cmake ..  
  make && make test && sudo make install

This will install the cmake helper file, the header only library, and the generator python script on your machine.

CMake with FSeam

Add FSeam Test in project

After including FSeamModule.cmake, FSeam helper function become available,

The addFSeamTests cmake function is a to call in order to generate a test executable from the generated FSeam mock and the provided test source


  • arg DESTINATION_TARGET: target name of the test executable generated via this method
  • arg TST_SRC: catch2 test files containing the actual test to compile
  • arg TO_MOCK: files to mock for this specific given test


  • arg TARGET_AS_SOURCE: target of the library that contains the code to test
  • arg FILES_AS_SOURCE: source file containing the code to test
  • arg FOLDER_INCLUDES: includes folder to attach to the test target DESTINATION_TARGET


  • arg MAIN_FILE: file containing the main (if any), this file will be removed from the compilation of the test



# Create a executable/library target called binaryWithContentToTest with the code you want to test 

        DESTINATION_TARGET fseamTargetName
        TARGET_AS_SOURCE binaryWithContentToTest
                ${CMAKE_CURRENT_SOURCE_DIR}/catch2TestFile.cpp          #Or any other framework
                ${CMAKE_CURRENT_SOURCE_DIR}/src/DependencyToMock.hh     #Give header to mock


  • If using Google Test, you can specify it as an option, by doing so the library will be linked by default to the test target and logging will be using standard output (iostream std::cout / std::cerr)
  • If using Catch2, you can specify it as an option, by doing so the header will be linked (add_include_directory), and loggin will be using Catch2 logging (useful for debugging as it will be scoped in the section that produced the log).

If both options are specified, Catch2 is prioritized (because I prefer catch2 NAaah :p !~)

Pratical Example

The FSeam tutorial provides examples on how to use the CMake helper function.

You can’t perform that action at this time.