diff options
author | redfish <redfish@galactica.pw> | 2016-08-29 14:23:57 -0400 |
---|---|---|
committer | redfish <redfish@galactica.pw> | 2016-09-01 10:47:43 -0400 |
commit | e374ae7eebedebced6147f78d4027f510f77e25a (patch) | |
tree | 0d427bcd2efb89a69dffc495cfb6d222973b372c /CMakeLists.txt | |
parent | Merge pull request #1022 (diff) | |
download | monero-e374ae7eebedebced6147f78d4027f510f77e25a.tar.xz |
cmake: option+target for profiling for coverage
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index fb587f9a1..e1ac8422a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -358,8 +358,15 @@ else() set(STATIC_ASSERT_FLAG "-Dstatic_assert=_Static_assert") endif() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG}") + option(COVERAGE "Enable profiling for test coverage report" 0) + + if(COVERAGE) + message(STATUS "Building with profiling for test coverage report") + set(COVERAGE_FLAGS "-fprofile-arcs -ftest-coverage --coverage") + endif() + + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG} ${COVERAGE_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG} ${COVERAGE_FLAGS}") # With GCC 6.1.1 the compiled binary malfunctions due to aliasing. Until that # is fixed in the code (Issue #847), force compiler to be conservative. @@ -459,10 +466,12 @@ else() if(APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTEST_HAS_TR1_TUPLE=0") endif() + + set(DEBUG_FLAGS "-g3") if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8)) - set(DEBUG_FLAGS "-g3 -Og -fprofile-arcs -ftest-coverage --coverage") + set(DEBUG_FLAGS "${DEBUG_FLAGS} -Og ") else() - set(DEBUG_FLAGS "-g3 -O0 -fprofile-arcs -ftest-coverage --coverage") + set(DEBUG_FLAGS "${DEBUG_FLAGS} -O0 ") endif() if(NOT DEFINED USE_LTO_DEFAULT) |