cmake: new option to enable compilations with coverage flags

Note that this will only work with gcc and clang.
v0.27.3
Luis Diaz Mas 7 years ago committed by Luis Díaz Más
parent 3d35b93fc0
commit 6521f7c4f9

@ -64,6 +64,7 @@ mark_as_advanced(
)
option( BUILD_WITH_CCACHE "Use ccache to speed up compilations" OFF )
option( BUILD_WITH_COVERAGE "Add compiler flags to generate coverage stats" OFF )
if ( EXIV2_ENABLE_WEBREADY )
set ( EXIV2_ENABLE_CURL ON )

@ -19,6 +19,15 @@ if ( MINGW OR UNIX ) # MINGW, Linux, APPLE, CYGWIN
endif()
if (COMPILER_IS_GCC OR COMPILER_IS_CLANG)
if(BUILD_WITH_COVERAGE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftest-coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wcast-align -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Woverloaded-virtual -W")
if ( CYGWIN OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0))

@ -63,6 +63,7 @@ OptionOutput( "Building samples: " EXIV2_BUILD_SAMPLES
OptionOutput( "Building PO files: " EXIV2_BUILD_PO )
OptionOutput( "Building unit tests: " EXIV2_BUILD_UNIT_TESTS )
OptionOutput( "Building doc: " EXIV2_BUILD_DOC )
OptionOutput( "Building with coverage flags: " BUILD_WITH_COVERAGE )
OptionOutput( "Using ccache: " BUILD_WITH_CCACHE )

Loading…
Cancel
Save