Skip to content

Commit

Permalink
cmake COVERAGE option to enable gcov instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
akdor1154 authored and lasconic committed Dec 19, 2017
1 parent 0d22fd4 commit fe3e087
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ option(BUILD_PORTAUDIO "Build with support for PortAudio audio backend." ON)
option(BUILD_PORTMIDI "Build with support for PortAudio's MIDI features." ${BUILD_PORTAUDIO}) # PortAudio required
option(BUILD_PCH "Build using precompiled headers." ON)
option(BUILD_FOR_WINSTORE "Build for the Windows Store." OFF)
option(COVERAGE "Build with instrumentation to record code coverage." OFF)

set (ENABLE_COVERAGE (COVERAGE AND CMAKE_BUILD_TYPE MATCHES "DEBUG"))

if (APPLE)
set (CMAKE_CXX_COMPILER clang++)
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ BUILD_PULSEAUDIO="ON" # Override with "OFF" to disable.
BUILD_JACK="ON" # Override with "OFF" to disable.
BUILD_PORTAUDIO="ON" # Override with "OFF" to disable.
USE_SYSTEM_FREETYPE="OFF" # Override with "ON" to enable. Requires freetype >= 2.5.2.
COVERAGE="OFF" # Override with "ON" to enable.


UPDATE_CACHE="TRUE"# Override if building a DEB or RPM, or when installing to a non-standard location.
Expand All @@ -56,9 +57,9 @@ release:
-DBUILD_LAME="${BUILD_LAME}" \
-DBUILD_PULSEAUDIO="${BUILD_PULSEAUDIO}" \
-DBUILD_JACK="${BUILD_JACK}" \
-DBUILD_PORTAUDIO="${BUILD_PORTAUDIO}" \
-DUSE_SYSTEM_FREETYPE="${USE_SYSTEM_FREETYPE}" \
-DCMAKE_SKIP_RPATH="${NO_RPATH}" ..; \
-DBUILD_PORTAUDIO="${BUILD_PORTAUDIO}" \
-DUSE_SYSTEM_FREETYPE="${USE_SYSTEM_FREETYPE}" \
-DCMAKE_SKIP_RPATH="${NO_RPATH}" ..; \
make lrelease; \
make -j ${CPUS}; \

Expand All @@ -83,6 +84,7 @@ debug:
-DBUILD_JACK="${BUILD_JACK}" \
-DBUILD_PORTAUDIO="${BUILD_PORTAUDIO}" \
-DUSE_SYSTEM_FREETYPE="${USE_SYSTEM_FREETYPE}" \
-DCOVERAGE="${COVERAGE}" \
-DCMAKE_SKIP_RPATH="${NO_RPATH}" ..; \
make lrelease; \
make -j ${CPUS}; \
Expand Down
2 changes: 1 addition & 1 deletion build/travis/job1_Tests/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ set -e # exit on error
set -x # echo commands

make revision
make debug CPUS=2 PREFIX="$HOME/software"
make debug CPUS=2 PREFIX="$HOME/software" COVERAGE=ON
make installdebug CPUS=2 PREFIX="$HOME/software"
17 changes: 16 additions & 1 deletion libmscore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,25 @@ add_library (
bracketItem.cpp
)

##
## Code coverage. Only affects DEBUG builds.
##

set(COVERAGE_OPTIONS "")
if (NOT APPLE AND NOT MINGW)
if (ENABLE_COVERAGE)
set(COVERAGE_OPTIONS "-O0 --coverage")
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
target_link_libraries(libmscore gcov)
endif (ENABLE_COVERAGE)
endif (NOT APPLE AND NOT MINGW)



set_target_properties (
libmscore
PROPERTIES
COMPILE_FLAGS "-g ${PCH_INCLUDE} -Wall -Wextra -Winvalid-pch -Woverloaded-virtual"
COMPILE_FLAGS "-g ${PCH_INCLUDE} -Wall -Wextra -Winvalid-pch -Woverloaded-virtual ${COVERAGE_OPTIONS}"
)

xcode_pch(libmscore all)
Expand Down

0 comments on commit fe3e087

Please sign in to comment.