The series of events here is supposed to work as follows:
To add profiling flags, you must add to your CMakeLists.txt:
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg")
That must add flags to compile and link, and use after execute the program:
gprof ./my_exe
If you get an error like:
gmon.out: No such file or directory
That means that compilation didn't add profiling info properly.