1

I need to modify CMake scenario in order to have code coverage reporting in place.

For this purpose 2 checks should be done:
1. GCC should be available: CMAKE_COMPILER_IS_GNUCXX
2. lcov should be installed (lcov is a graphical front-end for GCC's coverage testing tool)

My question is: How to check if lcov is installed using CMake?
Target operating systems (to check condition): Ubuntu 16.04, Windows 10

olpo.graphy
  • 405
  • 8
  • 17

2 Answers2

2

Working solution

find_program(LCOV_BIN lcov)
IF (LCOV_BIN MATCHES "lcov$")
    MESSAGE("lcov found in ${LCOV_BIN}")
ELSE ()
    MESSAGE(FATAL_ERROR "lcov required, but not found!")
ENDIF ()
olpo.graphy
  • 405
  • 8
  • 17
1

I think this might work

find_package(lcov)
IF (NOT lcov_FOUND)
    message(FATAL_ERROR “lcov required!”)
ENDIF (NOT lcov_FOUND)
Alex Bondar
  • 1,167
  • 4
  • 18
  • 35