Skip to content

Commit b46f10a

Browse files
thughesry
authored andcommitted
cmake: Add coverage support.
1 parent a1138c6 commit b46f10a

4 files changed

Lines changed: 32 additions & 8 deletions

File tree

CMakeLists.txt

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
cmake_minimum_required(VERSION 2.6)
22
project(node)
33

4+
if(USE_GCOV)
5+
set(CMAKE_BUILD_TYPE "Debug")
6+
7+
# Set global c and c++ flags
8+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
9+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
10+
11+
# Link flags used for creating executables
12+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov -fprofile-arcs")
13+
14+
# Link flags used for creating shared libraries
15+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lgcov -profile-arcs")
16+
endif()
17+
418
#
519
# options
620
#
@@ -72,5 +86,9 @@ if(${OPENSSL_FOUND} MATCHES TRUE)
7286
message(" OpenSSL: ${OPENSSL_LIBRARIES}")
7387
endif()
7488

75-
# message(" CCFLAGS: ${CCFLAGS}")
76-
# message(" CPPFLAGS: ${CPPFLAGS}")
89+
if(USE_GCOV)
90+
message(" gcov: enabled")
91+
endif()
92+
93+
message(" CCFLAGS: ${CCFLAGS}")
94+
message(" CPPFLAGS: ${CPPFLAGS}")

Makefile.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,7 @@ test: $(BUILD)/Makefile
3030
cdash: $(BUILD)/Makefile
3131
cd $(BUILD) && make Experimental
3232

33-
.PHONY: build install clean doc package test cdash
33+
cdash-cov: $(BUILD)/Makefile
34+
cd $(BUILD) && $(CMAKE) -DUSE_GCOV=True .. && make Experimental
35+
36+
.PHONY: build install clean doc package test cdash cdash-cov

README.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ To submit test results (see http://my.cdash.org/index.php?project=node):
3030

3131
make -f Makefile.cmake cdash
3232

33+
To submit coverage test results:
34+
35+
make -f Makefile.cmake cdash-cov
36+
3337
Using cmake directly:
3438
cd ~/your-node-source-dir
3539
mkdir name-of-build-dir (can be anything)

cmake/configure.cmake

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,16 @@ set(CMAKE_C_FLAGS_RELEASE "-g -O3 -DNDEBUG $ENV{CFLAGS}")
3838
set(CMAKE_CXX_FLAGS_RELEASE "-g -O3 -DNDEBUG $ENV{CXXFLAGS}")
3939

4040
if(${node_platform} MATCHES sunos)
41-
# shouldn't this be added to CMAE_C_FLAGS or something?
4241
add_definitions(-threads)
4342
elseif(NOT ${node_platform} MATCHES cygwin*)
44-
# shouldn't this be added to CMAE_C_FLAGS or something?
4543
add_definitions(-pthread)
46-
set(CMAKE_C_FLAGS -rdynamic)
47-
set(CMAKE_EXE_LINKER_FLAGS -pthread)
44+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -rdynamic")
45+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic")
46+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread")
4847
endif()
4948

5049
if(${node_platform} MATCHES darwin)
51-
set(CMAKE_EXE_LINKER_FLAGS "-framework Carbon")
50+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Carbon")
5251
endif()
5352

5453
check_function_exists(fdatasync HAVE_FDATASYNC)

0 commit comments

Comments
 (0)