Skip to content

Commit

Permalink
cmake: Add coverage support.
Browse files Browse the repository at this point in the history
  • Loading branch information
thughes authored and ry committed Dec 2, 2010
1 parent a1138c6 commit b46f10a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
22 changes: 20 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
#
Expand Down Expand Up @@ -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}")
5 changes: 4 additions & 1 deletion Makefile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions README.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions cmake/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b46f10a

Please sign in to comment.