~xnox/ubuntu-app-launch/sync-archive

« back to all changes in this revision

Viewing changes to cmake/Coverage.cmake

  • Committer: Tarmac
  • Author(s): Ted Gould
  • Date: 2013-08-12 01:25:10 UTC
  • mfrom: (33.5.12 libupstart-app-launch)
  • Revision ID: tarmac-20130812012510-j53gf9xxk1sxgn4l
Switch to CMake and add stub library.

Approved by Charles Kerr, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
if (CMAKE_BUILD_TYPE MATCHES coverage)
 
2
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
 
3
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
 
4
  set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage")
 
5
  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
 
6
 
 
7
  find_program(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin")
 
8
  if (NOT GCOVR_EXECUTABLE)
 
9
    message(STATUS "Gcovr binary was not found, can not generate XML coverage info.")
 
10
  else ()
 
11
    message(STATUS "Gcovr found, can generate XML coverage info.")
 
12
    add_custom_target (coverage-xml
 
13
      WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
 
14
      COMMAND "${GCOVR_EXECUTABLE}" --exclude="test.*" --exclude="obj.*" -x -r "${CMAKE_SOURCE_DIR}" 
 
15
      --object-directory=${CMAKE_BINARY_DIR} -o coverage.xml)
 
16
  endif()
 
17
 
 
18
  find_program(LCOV_EXECUTABLE lcov HINTS ${LCOV_ROOT} "${GCOVR_ROOT}/bin")
 
19
  find_program(GENHTML_EXECUTABLE genhtml HINTS ${GENHTML_ROOT})
 
20
  if (NOT LCOV_EXECUTABLE)
 
21
    message(STATUS "Lcov binary was not found, can not generate HTML coverage info.")
 
22
  else ()
 
23
    if(NOT GENHTML_EXECUTABLE)
 
24
      message(STATUS "Genthml binary not found, can not generate HTML coverage info.")
 
25
    else()
 
26
      message(STATUS "Lcov and genhtml found, can generate HTML coverage info.")
 
27
      add_custom_target (coverage-html
 
28
        WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
 
29
        COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture --output-file coverage.info --no-checksum
 
30
        COMMAND "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
 
31
        )
 
32
    endif()
 
33
  endif()
 
34
endif()