Part 4 : Several useful CMake functions



Before going further in this tutorial, we have to develop two small functions which will simplify the rest of the tutorial.

  • A function to lauch automatically the programs to be timed (runExample).
  • A function to plot the result of the timer to have a automatic vizualisation of what we are doing (plotPerf).


These two functions will be in the file runExample.cmake.



First we have to defined two target :

  • A target to run all the timing process (run_all).
  • A target to plot all the results (plot_all).


We have also to define the output directory of all the produced files.

The header of the file runExample.cmake is :



1
2
3
4
5
6
add_custom_target(run_all)
add_custom_target(plot_all)

add_dependencies(plot_all run_all)

set(OUTPUT_PERF_DIR "${CMAKE_BINARY_DIR}/Performances")