This repository has been archived by the owner on Jun 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
misc: refactor cmake scripts to support gcov (#165)
- Loading branch information
Showing
9 changed files
with
120 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,39 @@ | ||
cmake_minimum_required(VERSION 2.8.8) | ||
|
||
project(dsn C CXX) | ||
|
||
include(bin/dsn.cmake) | ||
|
||
project(dsn C CXX) | ||
set(DSN_BUILD_RUNTIME TRUE) | ||
add_definitions(-DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=0) | ||
if(DEFINED WARNING_ALL) | ||
#add_compile_options("-Wall") | ||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall") | ||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall") | ||
endif() | ||
OPTION(ENABLE_GCOV "Enable gcov (debug, Linux builds only)" OFF) | ||
if(ENABLE_GCOV AND UNIX) | ||
#add_compile_options("-fprofile-arcs" "-ftest-coverage") | ||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -DENABLE_GCOV") | ||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -DENABLE_GCOV") | ||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage -lgcov") | ||
endif() | ||
dsn_common_setup() | ||
|
||
# add custom target for gcov | ||
if(ENABLE_GCOV) | ||
find_program(GCOV_PATH gcov) | ||
find_program(GCOVR_PATH gcovr) | ||
|
||
if(NOT GCOV_PATH) | ||
message(FATAL_ERROR "gcov not found! Aborting...") | ||
endif() # NOT GCOV_PATH | ||
|
||
if(NOT GCOVR_PATH) | ||
message(FATAL_ERROR "gcovr not found! Aborting...") | ||
endif() # NOT GCOVR_PATH | ||
|
||
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" | ||
|
||
set(COVERAGE_COMPILER_FLAGS "-g -O0 --coverage -fprofile-arcs -ftest-coverage" CACHE INTERNAL "") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_COMPILER_FLAGS}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}") | ||
message(STATUS "Appending code coverage compiler flags: ${COVERAGE_COMPILER_FLAGS}") | ||
|
||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov") | ||
endif() | ||
|
||
# install rdsn/include to ${CMAKE_INCLUDE_PREFIX}/include | ||
install(DIRECTORY include/ DESTINATION include) | ||
|
||
add_subdirectory(src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.