celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1650165 - /celix/trunk/cmake/cmake_celix/CodeCoverage.cmake
Date Wed, 07 Jan 2015 21:09:39 GMT
Author: abroekhuis
Date: Wed Jan  7 21:09:39 2015
New Revision: 1650165

URL: http://svn.apache.org/r1650165
Log:
CELIX-199: Moved the code coverage CMake macros inside an option that can be enabled using
the CMake cache (ENABLE_CODE_COVERAGE).

Modified:
    celix/trunk/cmake/cmake_celix/CodeCoverage.cmake

Modified: celix/trunk/cmake/cmake_celix/CodeCoverage.cmake
URL: http://svn.apache.org/viewvc/celix/trunk/cmake/cmake_celix/CodeCoverage.cmake?rev=1650165&r1=1650164&r2=1650165&view=diff
==============================================================================
--- celix/trunk/cmake/cmake_celix/CodeCoverage.cmake (original)
+++ celix/trunk/cmake/cmake_celix/CodeCoverage.cmake Wed Jan  7 21:09:39 2015
@@ -44,41 +44,49 @@
 # 6. Removed unneeded Cobertura function
 #
 
-# Check prereqs
-FIND_PROGRAM( GCOV_PATH gcov )
-FIND_PROGRAM( LCOV_PATH lcov )
-FIND_PROGRAM( GENHTML_PATH genhtml )
-FIND_PROGRAM( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests)
+# Option to enable/disable coverage
+option(ENABLE_CODE_COVERAGE "Enables code coverage" FALSE)
 
-IF(NOT GCOV_PATH)
-	MESSAGE(FATAL_ERROR "gcov not found! Aborting...")
-ENDIF() # NOT GCOV_PATH
+# Check if coverage is enabled
+IF(ENABLE_CODE_COVERAGE)
 
-#IF(NOT CMAKE_COMPILER_IS_GNUCXX)
-#	MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...")
-#ENDIF() # NOT CMAKE_COMPILER_IS_GNUCXX
-
-IF ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
-  MESSAGE( WARNING "Code coverage results with an optimised (non-Debug) build may be misleading"
)
-ENDIF() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug"
-
-# Setup compiler options
-ADD_DEFINITIONS(--coverage)
-set(CMAKE_SHARED_LINKER_FLAGS "--coverage")
-set(CMAKE_EXE_LINKER_FLAGS "--coverage")
-
-IF(NOT TARGET coverage)
-    add_custom_target(coverage
-	    COMMAND ${CMAKE_COMMAND} -E make_directory coverage_results
-	    COMMAND ${GENHTML_PATH} -o coverage_results coverage/*.info.cleaned
-	    COMMAND ${CMAKE_COMMAND} -E remove_directory coverage
-	
-	    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
-	    COMMENT "Generating report.\nOpen ./${_outputname}/index.html in your browser to view
the coverage report."
-    )
-
-    SET_TARGET_PROPERTIES(coverage PROPERTIES COVERAGE_TARGET_ADDED "")
-ENDIF()
+    # Check prereqs
+    FIND_PROGRAM( GCOV_PATH gcov )
+    FIND_PROGRAM( LCOV_PATH lcov )
+    FIND_PROGRAM( GENHTML_PATH genhtml )
+    FIND_PROGRAM( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests)
+    
+    IF(NOT GCOV_PATH)
+    	MESSAGE(FATAL_ERROR "gcov not found! Aborting...")
+    ENDIF() # NOT GCOV_PATH
+    
+    #IF(NOT CMAKE_COMPILER_IS_GNUCXX)
+    #	MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...")
+    #ENDIF() # NOT CMAKE_COMPILER_IS_GNUCXX
+    
+    IF ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
+      MESSAGE( WARNING "Code coverage results with an optimised (non-Debug) build may be
misleading" )
+    ENDIF() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug"
+    
+    # Setup compiler options
+    ADD_DEFINITIONS(--coverage)
+    set(CMAKE_SHARED_LINKER_FLAGS "--coverage")
+    set(CMAKE_EXE_LINKER_FLAGS "--coverage")
+    
+    IF(NOT TARGET coverage)
+        add_custom_target(coverage
+    	    COMMAND ${CMAKE_COMMAND} -E make_directory coverage_results
+    	    COMMAND ${GENHTML_PATH} -o coverage_results coverage/*.info.cleaned
+    	    COMMAND ${CMAKE_COMMAND} -E remove_directory coverage
+    	
+    	    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+    	    COMMENT "Generating report.\nOpen ./${_outputname}/index.html in your browser to
view the coverage report."
+        )
+    
+        SET_TARGET_PROPERTIES(coverage PROPERTIES COVERAGE_TARGET_ADDED "")
+    ENDIF()
+    
+ENDIF(ENABLE_CODE_COVERAGE)
 
 # Param _targetname     The name of new the custom make target
 # Param _testrunner     The name of the target which runs the tests
@@ -87,31 +95,32 @@ ENDIF()
 # Optional fourth parameter is passed as arguments to _testrunner
 #   Pass them in list form, e.g.: "-j;2" for -j 2
 FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname)
-
-	IF(NOT LCOV_PATH)
-		MESSAGE(FATAL_ERROR "lcov not found! Aborting...")
-	ENDIF() # NOT LCOV_PATH
-
-	IF(NOT GENHTML_PATH)
-		MESSAGE(FATAL_ERROR "genhtml not found! Aborting...")
-	ENDIF() # NOT GENHTML_PATH
-
-	# Setup target
-	ADD_CUSTOM_TARGET(${_targetname}
-		
-		# Cleanup lcov
-		${LCOV_PATH} --directory . --zerocounters
-		
-		# Run tests
-		COMMAND ${_testrunner} ${ARGV3}
-		
-		# Capturing lcov counters and generating report
-		COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/coverage
-		COMMAND ${LCOV_PATH} --directory . --capture --output-file ${_outputname}.info
-		COMMAND ${LCOV_PATH} --remove ${_outputname}.info 'mock/*' 'test/*' '/usr/*' --output-file
${_outputname}.info.cleaned
-		
-		WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-		COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and
generating report."
-	)
-	ADD_DEPENDENCIES(coverage ${_targetname})
+    IF(ENABLE_CODE_COVERAGE)
+    	IF(NOT LCOV_PATH)
+    		MESSAGE(FATAL_ERROR "lcov not found! Aborting...")
+    	ENDIF() # NOT LCOV_PATH
+    
+    	IF(NOT GENHTML_PATH)
+    		MESSAGE(FATAL_ERROR "genhtml not found! Aborting...")
+    	ENDIF() # NOT GENHTML_PATH
+    
+    	# Setup target
+    	ADD_CUSTOM_TARGET(${_targetname}
+    		
+    		# Cleanup lcov
+    		${LCOV_PATH} --directory . --zerocounters
+    		
+    		# Run tests
+    		COMMAND ${_testrunner} ${ARGV3}
+    		
+    		# Capturing lcov counters and generating report
+    		COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/coverage
+    		COMMAND ${LCOV_PATH} --directory . --capture --output-file ${_outputname}.info
+    		COMMAND ${LCOV_PATH} --remove ${_outputname}.info 'mock/*' 'test/*' '/usr/*' --output-file
${_outputname}.info.cleaned
+    		
+    		WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+    		COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters
and generating report."
+    	)
+    	ADD_DEPENDENCIES(coverage ${_targetname})
+    ENDIF(ENABLE_CODE_COVERAGE)
 ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE
\ No newline at end of file



Mime
View raw message