From ca1c1a03d774e1017c8110127fc71814e4be89df Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Sun, 21 Feb 2016 15:44:41 +0100 Subject: [PATCH] Add build option to enable gprof-based profiling instrumentation. --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c1a12c87..20a898dfb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,6 +99,7 @@ option (WITH_BZIP "Build with Bzip2 support" ON) option (WITH_MYFILE_MMAP "Build using memory mapped file" ON) option (WITH_LTO "Build with link-time optimizations" OFF) option (WITH_SAN "Build with run-time sanitizer" OFF) +option (WITH_PROF "Build with profiling instrumentation" OFF) option (OPTION_OMP "Build with OpenMP support" ON) option (STRICT_MUTEX "True (recommended): MyMutex will behave like POSIX Mutex; False: MyMutex will behave like POSIX RecMutex; Note: forced to ON for Debug builds" ON) option (TRACE_MYRWMUTEX "Trace RT's custom R/W Mutex (Debug builds only); redirecting std::out to a file is strongly recommended!" OFF) @@ -281,6 +282,12 @@ if (WITH_SAN) SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${WITH_SAN}") endif (WITH_SAN) +if (WITH_PROF) + SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") + SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") + SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") +endif (WITH_PROF) + if (OPTION_OMP) find_package(OpenMP) if (OPENMP_FOUND)