Commit 270c7797 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Made code coverage configurable and disabled by default

parent 6690d06d
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -265,9 +265,10 @@ if( WITH_TESTS STREQUAL "yes" )
   # build gtest libs
   include( BuildGtest )

   if( WITH_COVERAGE STREQUAL "yes" AND CMAKE_BUILD_TYPE STREQUAL "Debug" )
      # enable code coverage reports
   set( ENABLE_CODECOVERAGE ON )
      include( UseCodeCoverage )
   endif()
endif( WITH_TESTS STREQUAL "yes" )

find_package( PythonInterp 3 )
+5 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ PREFIX=${HOME}/.local
WITH_CLANG="no"
WITH_CUDA="yes"
WITH_TESTS="yes"
WITH_COVERAGE="no"

WITH_CUDA_ARCH="auto"
WITH_TEMPLATE_INSTANTIATION="yes"
@@ -29,6 +30,7 @@ do
        --build=*                        ) BUILD="${option#*=}" ;;
        --with-clang=*                   ) WITH_CLANG="${option#*=}" ;;
        --with-tests=*                   ) WITH_TESTS="${option#*=}" ;;
        --with-coverage=*                ) WITH_COVERAGE="${option#*=}" ;;
        --with-cuda=*                    ) WITH_CUDA="${option#*=}" ;;
        --with-cuda-arch=*               ) WITH_CUDA_ARCH="${option#*=}";;
        --with-templates-instantiation=* ) WITH_TEMPLATE_INSTANTIATION="${option#*=}" ;;
@@ -63,7 +65,8 @@ then
    echo ""
    echo "   --prefix=PATH                         Prefix for the installation directory. ${HOME}/local by default."
    echo "   --build=Debug/Release                 Build type."
    echo "   --with-tests=yes/no                   Enable unit tests. 'yes' by default (libcppunit-dev is required)."
    echo "   --with-tests=yes/no                   Enable unit tests. 'yes' by default."
    echo "   --with-coverage=yes/no                Enable code coverage reports for unit tests. 'no' by default (lcov is required)."
    echo "   --with-cuda=yes/no                    Enable CUDA. 'yes' by default (CUDA Toolkit is required)."
    echo "   --with-cuda-arch=all/auto/30/35/...   Choose CUDA architecture."   
    echo "   --with-templates-instantiation=yes/no Some TNL templates are precompiled during the build. 'yes' by default."
@@ -92,6 +95,7 @@ ${CMAKE} ${ROOT_DIR} \
         -DWITH_CUDA=${WITH_CUDA} \
         -DWITH_CUDA_ARCH=${WITH_CUDA_ARCH} \
         -DWITH_TESTS=${WITH_TESTS} \
         -DWITH_COVERAGE=${WITH_COVERAGE} \
         -DPETSC_DIR=${PETSC_DIR} \
         -DDCMTK_DIR=${DCMTK_DIR} \
         -DWITH_TEMPLATE_INSTANTIATION=${WITH_TEMPLATE_INSTANTIATION} \
+22 −28
Original line number Diff line number Diff line
#http://www.cmake.org/pipermail/cmake/2010-March/036063.html


OPTION( ENABLE_CODECOVERAGE "Enable code coverage testing support" )

if ( ENABLE_CODECOVERAGE )

if ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
    message( WARNING "Code coverage results with an optimised (non-Debug) build may be misleading" )
endif ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
@@ -17,7 +13,7 @@ if ( ENABLE_CODECOVERAGE )
    set( CODECOV_HTMLOUTPUTDIR coverage_results )
endif ( NOT DEFINED CODECOV_HTMLOUTPUTDIR )

    if ( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCXX )
if ( CMAKE_COMPILER_IS_GNUCXX )
    find_program( CODECOV_GCOV gcov )
    find_program( CODECOV_LCOV lcov )
    find_program( CODECOV_GENHTML genhtml )
@@ -26,6 +22,4 @@ if ( ENABLE_CODECOVERAGE )
    set( CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} --coverage )
    add_custom_target( coverage_init ALL ${CODECOV_LCOV} --base-directory .  --directory ${CMAKE_SOURCE_DIR} --no-external --output-file ${CODECOV_OUTPUTFILE} --capture --initial --quiet )
    add_custom_target( coverage ${CODECOV_LCOV} --base-directory .  --directory ${CMAKE_SOURCE_DIR} --no-external --output-file ${CODECOV_OUTPUTFILE} --capture --quiet COMMAND genhtml --quiet -o ${CODECOV_HTMLOUTPUTDIR} ${CODECOV_OUTPUTFILE} )
    endif ( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCXX )

endif (ENABLE_CODECOVERAGE )
endif ( CMAKE_COMPILER_IS_GNUCXX )