From b46f10a11fbb5a8426c28e9113fff57cb7405958 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 24 Nov 2010 00:34:50 -0600 Subject: [PATCH] cmake: Add coverage support. --- CMakeLists.txt | 22 ++++++++++++++++++++-- Makefile.cmake | 5 ++++- README.cmake | 4 ++++ cmake/configure.cmake | 9 ++++----- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 88feea7ef3..0ec17a115b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,20 @@ cmake_minimum_required(VERSION 2.6) project(node) +if(USE_GCOV) + set(CMAKE_BUILD_TYPE "Debug") + + # Set global c and c++ flags + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") + + # Link flags used for creating executables + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov -fprofile-arcs") + + # Link flags used for creating shared libraries + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lgcov -profile-arcs") +endif() + # # options # @@ -72,5 +86,9 @@ if(${OPENSSL_FOUND} MATCHES TRUE) message(" OpenSSL: ${OPENSSL_LIBRARIES}") endif() -# message(" CCFLAGS: ${CCFLAGS}") -# message(" CPPFLAGS: ${CPPFLAGS}") +if(USE_GCOV) + message(" gcov: enabled") +endif() + +message(" CCFLAGS: ${CCFLAGS}") +message(" CPPFLAGS: ${CPPFLAGS}") diff --git a/Makefile.cmake b/Makefile.cmake index d2a357756c..ce34f8f8ec 100644 --- a/Makefile.cmake +++ b/Makefile.cmake @@ -30,4 +30,7 @@ test: $(BUILD)/Makefile cdash: $(BUILD)/Makefile cd $(BUILD) && make Experimental -.PHONY: build install clean doc package test cdash +cdash-cov: $(BUILD)/Makefile + cd $(BUILD) && $(CMAKE) -DUSE_GCOV=True .. && make Experimental + +.PHONY: build install clean doc package test cdash cdash-cov diff --git a/README.cmake b/README.cmake index 5267baab9c..4c3d732a8a 100644 --- a/README.cmake +++ b/README.cmake @@ -30,6 +30,10 @@ To submit test results (see http://my.cdash.org/index.php?project=node): make -f Makefile.cmake cdash +To submit coverage test results: + + make -f Makefile.cmake cdash-cov + Using cmake directly: cd ~/your-node-source-dir mkdir name-of-build-dir (can be anything) diff --git a/cmake/configure.cmake b/cmake/configure.cmake index 2a4cf10d9a..eef89c5fdc 100644 --- a/cmake/configure.cmake +++ b/cmake/configure.cmake @@ -38,17 +38,16 @@ set(CMAKE_C_FLAGS_RELEASE "-g -O3 -DNDEBUG $ENV{CFLAGS}") set(CMAKE_CXX_FLAGS_RELEASE "-g -O3 -DNDEBUG $ENV{CXXFLAGS}") if(${node_platform} MATCHES sunos) - # shouldn't this be added to CMAE_C_FLAGS or something? add_definitions(-threads) elseif(NOT ${node_platform} MATCHES cygwin*) - # shouldn't this be added to CMAE_C_FLAGS or something? add_definitions(-pthread) - set(CMAKE_C_FLAGS -rdynamic) - set(CMAKE_EXE_LINKER_FLAGS -pthread) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -rdynamic") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread") endif() if(${node_platform} MATCHES darwin) - set(CMAKE_EXE_LINKER_FLAGS "-framework Carbon") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Carbon") endif() check_function_exists(fdatasync HAVE_FDATASYNC)