Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
MANTA-1235 Add build option for code cov profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
ctsa committed Sep 28, 2017
1 parent fc54af5 commit 3be0c34
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -73,7 +73,7 @@ endif ()
#
set(CMAKE_CONFIGURATION_TYPES_TMP Debug Release RelWithDebInfo)
if (NOT WIN32)
set(CMAKE_CONFIGURATION_TYPES_TMP ${CMAKE_CONFIGURATION_TYPES_TMP} ASan)
set(CMAKE_CONFIGURATION_TYPES_TMP ${CMAKE_CONFIGURATION_TYPES_TMP} ASan GCov)
endif ()
set(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES_TMP} CACHE STRING "" FORCE)

Expand Down
5 changes: 3 additions & 2 deletions configure
Expand Up @@ -49,11 +49,12 @@ Configuration:
allow version control within eclipse
--build-type=TYPE specify the build type for CMake (affects compiler
options). Allowed values are "Debug", "Release",
"RelWithDebInfo", "ASan" [$build_type]
"RelWithDebInfo", "ASan", "GCov" [$build_type]
Debug: No optimization and all debug symbols
Release: All portable optimization
RelWithDebInfo: Most optimizations, try to keep stack trace info
ASan: Light optimization with google addresss sanitizer on
ASan: Light optimization with google address sanitizer on
GCov: Debug mode with code coverage options to enable gcov
Directory and file names:
--prefix=PREFIX install files in tree rooted at PREFIX
Expand Down
23 changes: 15 additions & 8 deletions src/cmake/cxxConfigure.cmake
Expand Up @@ -264,7 +264,7 @@ set (GNU_COMPAT_COMPILER ( (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${IS_CL
if (${GNU_COMPAT_COMPILER})
append_args(CXX_WARN_FLAGS "-Wall -Wextra -Wshadow -Wunused -Wpointer-arith -Winit-self -pedantic -Wunused-parameter")
append_args(CXX_WARN_FLAGS "-Wundef -Wno-unknown-pragmas")
append_args(CXX_WARN_FLAGS "-Wdeprecated")
append_args(CXX_WARN_FLAGS "-Wdeprecated -Woverloaded-virtual -Wwrite-strings")

if ((NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel") OR (NOT ${COMPILER_VERSION} VERSION_LESS "14.0"))
append_args(CXX_WARN_FLAGS "-Wdisabled-optimization")
Expand Down Expand Up @@ -434,19 +434,15 @@ if (${GNU_COMPAT_COMPILER})
else ()
append_args (CMAKE_CXX_FLAGS "-std=c++11")
endif ()

set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g")

# The NDEBUG macro is intentionally removed from release. One discussion on this is:
# http://www.drdobbs.com/an-exception-or-a-bug/184401686
set (CMAKE_CXX_FLAGS_RELEASE "-O3 -fomit-frame-pointer")
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
set (CMAKE_CXX_FLAGS_ASAN "-O1 -g -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls")
#set (CMAKE_CXX_FLAGS_PROFILE "-O0 -g -pg -fprofile-arcs -ftest-coverage")

# this doesn't seem to impact performance, taking out for now:
#if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto")
#endif ()
set (CMAKE_CXX_FLAGS_GCOV "-O0 -g -fprofile-arcs -ftest-coverage")
endif()

if (MSVC)
Expand Down Expand Up @@ -475,6 +471,18 @@ if (CMAKE_BUILD_TYPE STREQUAL "ASan")
endif ()
endif ()

# if GCov build type is requested, check that the compiler supports it:
if (CMAKE_BUILD_TYPE STREQUAL "GCov")
set (IS_GCOV_SUPPORTED false)
if (${GNU_COMPAT_COMPILER})
set (IS_GCOV_SUPPORTED true)
endif ()

if (NOT ${IS_GCOV_SUPPORTED})
message(FATAL_ERROR "GCov build type requested, but this is not supported by compiler.")
endif ()
endif ()

#
# take advantage of analyze on VS
#
Expand Down Expand Up @@ -521,7 +529,6 @@ if (${GNU_COMPAT_COMPILER})
append_args (CMAKE_CXX_FLAGS "-ffloat-store")
endif ()
endif ()

endif()

# cmake configure-time c++ configuration:
Expand Down

0 comments on commit 3be0c34

Please sign in to comment.