
# Include guard
if(SCAF_CPPCHECK_DONE)
  return()
endif()
set(SCAF_CPPCHECK_DONE ON)

if(NOT ${CMAKE_COMPILER_IS_GCC} AND NOT ${CMAKE_COMPILER_IS_CLANG})
  message(STATUS "")
  message(STATUS "------------------------------------------------------------------")
  message(STATUS "| Codecov is enabled but is only supported by clang and gcc.     |")
  message(STATUS "| Codecov is disabled for use.                                   |")
  message(STATUS "------------------------------------------------------------------")
  message(STATUS "")
  set(SF_DISABLE_CODECOV true)
endif()

if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
  if(NOT SF_DISABLE_CODECOV)
    message(STATUS "")
    message(STATUS "------------------------------------------------------------------")
    message(STATUS "| Codecov requires debug symbols to be generated. Must set       |")
    message(STATUS "| The CMAKE_BUILD_TYPE to be 'Debug'                             |")
    message(STATUS "------------------------------------------------------------------")
    message(STATUS "")
    set(SF_DISABLE_CODECOV true)
  endif()
endif()

if(NOT SF_DISABLE_CODECOV)
  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()
