Skip to content

Commit 839a370

Browse files
committed
cmake: add option for GCC profiling
using `-ggdb3` and `-gp` with GCC enables verbose debugging and profiling abilities useful for further analysis; also the tests will get compiled with `-ftest-coverage` if both CMake variables (`pfasst_BUILD_TESTS` and `pfasst_WITH_GCC_PROF`) are enabled and you are compiling with GCC
1 parent 6199696 commit 839a370

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ option(pfasst_DISABLE_LIBCXX "Disable use of LLVM's libc++ when compiling with C
1313
option(pfasst_BUILD_EXAMPLES "Build example programs." ON )
1414
option(pfasst_BUILD_TESTS "Build test suite for PFASST." ON )
1515
option(pfasst_WITH_MPI "Build with MPI enabled." OFF)
16+
option(pfasst_WITH_GCC_PROF "Enable excessive debugging & profiling output with GCC." OFF)
1617

1718
# Set output directories
1819
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${pfasst_SOURCE_DIR}/dist/bin")
@@ -32,6 +33,9 @@ if(${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
3233
else()
3334
message(FATAL_ERROR "No advanced standard C++ support of your GCC (-std=c++11 not defined).")
3435
endif()
36+
if(pfasst_WITH_GCC_PROF)
37+
add_to_string_list("${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS "-ggdb3 -pg")
38+
endif(pfasst_WITH_GCC_PROF)
3539
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
3640
check_cxx_compiler_flag(-std=c++11 HAVE_STD11)
3741
if(HAVE_STD11)
@@ -72,6 +76,9 @@ set(pfasst_DEPENDEND_LIBS)
7276

7377
if(pfasst_BUILD_TESTS)
7478
enable_testing()
79+
if(pfasst_WITH_GCC_PROF)
80+
add_to_string_list("${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS "-ftest-coverage")
81+
endif(pfasst_WITH_GCC_PROF)
7582
endif(pfasst_BUILD_TESTS)
7683

7784
# Add / include 3rd-party libraries

0 commit comments

Comments
 (0)