1
0

code_coverage.cmake 1.1 KB

1234567891011121314151617181920212223242526272829
  1. # Code coverage
  2. if(CPR_BUILD_TESTS AND CPR_GENERATE_COVERAGE)
  3. set(CMAKE_BUILD_TYPE COVERAGE CACHE INTERNAL "Coverage enabled build")
  4. message(STATUS "Enabling gcov support")
  5. if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  6. set(COVERAGE_FLAG "--coverage")
  7. endif()
  8. set(CMAKE_CXX_FLAGS_COVERAGE
  9. "-g -O0 ${COVERAGE_FLAG} -fprofile-arcs -ftest-coverage"
  10. CACHE STRING "Flags used by the C++ compiler during coverage builds."
  11. FORCE)
  12. set(CMAKE_C_FLAGS_COVERAGE
  13. "-g -O0 ${COVERAGE_FLAG} -fprofile-arcs -ftest-coverage"
  14. CACHE STRING "Flags used by the C compiler during coverage builds."
  15. FORCE)
  16. set(CMAKE_EXE_LINKER_FLAGS_COVERAGE
  17. ""
  18. CACHE STRING "Flags used for linking binaries during coverage builds."
  19. FORCE)
  20. set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
  21. ""
  22. CACHE STRING "Flags used by the shared libraries linker during coverage builds."
  23. FORCE)
  24. mark_as_advanced(
  25. CMAKE_CXX_FLAGS_COVERAGE
  26. CMAKE_C_FLAGS_COVERAGE
  27. CMAKE_EXE_LINKER_FLAGS_COVERAGE
  28. CMAKE_SHARED_LINKER_FLAGS_COVERAGE)
  29. endif()