Compare commits
	
		
			5 Commits
		
	
	
		
			97ccbf69ac
			...
			d57bbeb634
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| d57bbeb634 | |||
| abfce824d2 | |||
| c9ac3f56ed | |||
| 499285d23b | |||
| a51a6fd9e7 | 
							
								
								
									
										38
									
								
								CMLibCodeCoverage.cmake
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								CMLibCodeCoverage.cmake
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,38 @@
 | 
			
		||||
function(add_code_coverage)
 | 
			
		||||
  list(GET ARGN 0 _target)
 | 
			
		||||
 | 
			
		||||
  if(CMAKE_CXX_COMPILER_IS_GCC)
 | 
			
		||||
    find_program(LCOV_EXE NAMES lcov)
 | 
			
		||||
    find_program(GENHTML_EXE NAMES genhtml)
 | 
			
		||||
    target_compile_options(${_target} PUBLIC "--coverage")
 | 
			
		||||
    get_target_property(LF ${_target} LINK_FLAGS)
 | 
			
		||||
    string(APPEND LF " --coverage")
 | 
			
		||||
    set_target_properties(${_target} PROPERTIES LINK_FLAGS ${LF})
 | 
			
		||||
 | 
			
		||||
    if(LCOV_EXE)
 | 
			
		||||
      add_custom_target(coverage-${_target}
 | 
			
		||||
                        WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
 | 
			
		||||
                        COMMAND ${LCOV_EXE}
 | 
			
		||||
                                --test-name
 | 
			
		||||
                                ${_target}
 | 
			
		||||
                                --output
 | 
			
		||||
                                "${_target}.lcov"
 | 
			
		||||
                                --capture
 | 
			
		||||
                                --directory
 | 
			
		||||
                                ${CMAKE_BINARY_DIR})
 | 
			
		||||
      add_dependencies(coverage-${_target} ${_target})
 | 
			
		||||
 | 
			
		||||
      if(GENHTML_EXE)
 | 
			
		||||
        add_custom_target(coverage-report-${_target}
 | 
			
		||||
                          WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
 | 
			
		||||
                          COMMAND ${GENHTML_EXE}
 | 
			
		||||
                                  --output-directory
 | 
			
		||||
                                  "report-${_target}"
 | 
			
		||||
                                  "${_target}.lcov")
 | 
			
		||||
        add_dependencies(coverage-report-${_target} coverage-${_target})
 | 
			
		||||
      endif()
 | 
			
		||||
    endif()
 | 
			
		||||
  else()
 | 
			
		||||
    message("Only GCC is supported for code coverage")
 | 
			
		||||
  endif()
 | 
			
		||||
endfunction()
 | 
			
		||||
@@ -35,6 +35,7 @@ include(CMLibCodeAnalysisPvsStudio)
 | 
			
		||||
include(CMLibCodeAnalysisClangAnalyze)
 | 
			
		||||
include(CMLibCodeAnalysisClangTidy)
 | 
			
		||||
include(CMLibCodeAnalysisClazy)
 | 
			
		||||
include(CMLibCodeCoverage)
 | 
			
		||||
include(CMLibSanitizers)
 | 
			
		||||
include(cotire)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user