[mlpack-git] master: Merge pull request #720 from sumedhghaisas/coverage (82cf865)
gitdub at mlpack.org
gitdub at mlpack.org
Thu Jul 21 09:59:11 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/57a24a9d9fbdb4687ea0e0fef85bc2a133420dcc...82cf86500e8ad98b32db9fd9cceca4a844f4bb19
>---------------------------------------------------------------
commit 82cf86500e8ad98b32db9fd9cceca4a844f4bb19
Merge: 57a24a9 8cc01d5
Author: Ryan Curtin <ryan at ratml.org>
Date: Thu Jul 21 09:59:11 2016 -0400
Merge pull request #720 from sumedhghaisas/coverage
Added test coverage framework
>---------------------------------------------------------------
82cf86500e8ad98b32db9fd9cceca4a844f4bb19
CMake/mlpack_coverage.in | 125 ++++++++++++++++++++++++++++++++++++++++++++++
CMakeLists.txt | 35 ++++++++++++-
src/mlpack/CMakeLists.txt | 2 +
3 files changed, 160 insertions(+), 2 deletions(-)
diff --cc CMakeLists.txt
index 2004a12,b54696a..e793998
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@@ -74,14 -74,42 +74,45 @@@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -lm")
endif()
+ set(COMPILER_SUPPORT_LIBRARIES "")
+
+ # Setup build for test coverage
+ if(BUILD_WITH_COVERAGE)
+ # Currently coverage only works with GNU g++
+ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+ # Find gcov and lcov
+ find_program(GCOV gcov)
+ find_program(LCOV lcov)
+
+ if(NOT GCOV)
+ message(FATAL_ERROR "gcov not found! Aborting...")
+ endif()
+
+ set(COMPILER_SUPPORT_LIBRARIES "supc++")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fno-inline -fno-inline-small-functions -fno-default-inline -fprofile-arcs -fkeep-inline-functions")
+ message(WARNING "Adding debug options for coverage")
+ # Remove optimizations for better line coverage
+ set(DEBUG ON)
+
+ if(LCOV)
+ configure_file(CMake/mlpack_coverage.in mlpack_coverage @ONLY)
+ add_custom_target(mlpack_coverage DEPENDS mlpack_test COMMAND ${PROJECT_BINARY_DIR}/mlpack_coverage)
+ else()
+ message(WARNING "'lcov' not found, local coverage report is disabled. Install 'lcov' and rerun cmake to generate local coverage report.")
+ endif()
+ else()
+ message(FATAL_ERROR "Coverage will only work with GNU environment.")
+ endif()
+ endif()
+
# Debugging CFLAGS. Turn optimizations off; turn debugging symbols on.
if(DEBUG)
- add_definitions(-DDEBUG)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -ftemplate-backtrace-limit=0")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -g -O0")
+ if (NOT MSVC)
+ add_definitions(-DDEBUG)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -ftemplate-backtrace-limit=0")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -g -O0")
+ endif ()
+
# mlpack uses it's own mlpack::backtrace class based on Binary File Descriptor
# <bfd.h> and linux Dynamic Loader <libdl.h> and more portable version in future
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
More information about the mlpack-git
mailing list