"Fossies" - the Fresh Open Source Software Archive

Member "evolution-mapi-3.46.1/cmake/modules/CodeCoverageGCOV.cmake" (2 Dec 2022, 2033 Bytes) of package /linux/misc/evolution-mapi-3.46.1.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) CMake source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 # CodeCoverageGCOV.cmake
    2 #
    3 # Adds options ENABLE_CODE_COVERAGE, which builds the project with
    4 # code coverage support
    5 #
    6 # It sets variables:
    7 # CODE_COVERAGE_DEFINES - to be used with target_compile_definitions() and similar
    8 # CODE_COVERAGE_CFLAGS - to be used with target_compile_options() and similar for C code
    9 # CODE_COVERAGE_CXXFLAGS - to be used with target_compile_options() and similar for C++ code
   10 # CODE_COVERAGE_LDFLAGS - to be used with target_link_libraries() and similar
   11 #
   12 # These variables should be added as the last in the options, because they change compilation
   13 
   14 include(CheckLibraryExists)
   15 include(PrintableOptions)
   16 
   17 add_printable_option(ENABLE_CODE_COVERAGE "Enable build with GCOV code coverage" OFF)
   18 
   19 if(ENABLE_CODE_COVERAGE)
   20     if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
   21         CHECK_LIBRARY_EXISTS("gcov" "gcov_exit" "" HAVE_GCOV_LIBRARY)
   22         if(HAVE_GCOV_LIBRARY)
   23             set(CODE_COVERAGE_CFLAGS "-O0 -g -fprofile-arcs -ftest-coverage")
   24             set(CODE_COVERAGE_LDFLAGS "-lgcov")
   25 
   26             add_definitions(-DNDEBUG)
   27             set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CODE_COVERAGE_CFLAGS}")
   28             set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CODE_COVERAGE_CFLAGS}")
   29             set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CODE_COVERAGE_LDFLAGS}")
   30             set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${CODE_COVERAGE_LDFLAGS}")
   31             set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CODE_COVERAGE_LDFLAGS}")
   32             set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} ${CODE_COVERAGE_LDFLAGS}")
   33         else(HAVE_GCOV_LIBRARY)
   34             message(FATAL_ERROR "Cannot fing gcov library, use -DENABLE_CODE_COVERAGE=OFF disable it")
   35         endif(HAVE_GCOV_LIBRARY)
   36 
   37     else("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
   38         message(FATAL_ERROR "Code coverage requires gcc compiler, use -DENABLE_CODE_COVERAGE=OFF disable it")
   39     endif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
   40 else(ENABLE_CODE_COVERAGE)
   41     set(CODE_COVERAGE_DEFINES "")
   42     set(CODE_COVERAGE_CFLAGS "")
   43     set(CODE_COVERAGE_CXXFLAGS "")
   44     set(CODE_COVERAGE_LDFLAGS "")
   45 endif(ENABLE_CODE_COVERAGE)