Skip to content

Commit 8453906

Browse files
Merge branch '147-sonar-config' into 142-setup-travis-ci
2 parents 74d7cbb + 29bfa1c commit 8453906

File tree

5 files changed

+48
-26
lines changed

5 files changed

+48
-26
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ compile_commands.json
7272
CTestTestfile.cmake
7373

7474
# layout
75+
.scannerwork
7576
doxyfile
7677
*.tar
7778
sonar-project.properties

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ matrix:
3737
env:
3838
BUILD_DIRECTORY=cmake-sonar-build
3939
CMAKE_COMMAND_LINE_ARGS="-DSONAR=yes"
40-
MAKE_TARGETS="code-quality"
40+
MAKE_TARGETS="all test code-quality"
4141
- name: default
4242
env:
4343
BUILD_DIRECTORY=cmake-default-build

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ endif()
2323

2424
find_package(GTestExt PATHS cmake)
2525

26+
# This part MUST be executed before the loading of the CMake package
27+
set(SONAR_PROPERTIES_FILE ${CMAKE_CURRENT_BINARY_DIR}/sonar-project.properties)
28+
message(STATUS "Generating SONAR properties file ${SONAR_PROPERTIES_FILE}")
29+
configure_file(${CMAKE_CURRENT_LIST_DIR}/sonar-project.properties.in ${SONAR_PROPERTIES_FILE})
30+
find_package(SonarCloud PATHS cmake)
31+
2632
# main targets --------------------------------------------------
2733
#
2834
if( CMAKE_BUILD_TYPE MATCHES Release )

cmake/SonarCloudConfig.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ if ( SONAR )
4343
add_dependencies(code-quality build-wrapper)
4444
endif()
4545

46+
find_program(SONAR_GCOV gcov)
47+
if(SONAR_GCOV)
48+
add_custom_target( sonar-gcov-report
49+
COMMAND find ./CMakeFiles/ -type f -name "*.gcno" -exec ${SONAR_GCOV} {} -m \; > /dev/null 2>&1
50+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
51+
COMMENT "Built sonar GCOV report (${SONAR_GCOV})"
52+
VERBATIM
53+
)
54+
message(STATUS "Added custom target [sonar-gcov-report]...")
55+
add_dependencies(code-quality sonar-gcov-report)
56+
endif()
4657

4758
else()
4859
message(SEND_ERROR "Failed to find the program [sonar_scanner], make sure sonar tools are installed.")

sonar-project.properties.in

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,41 @@
1+
# Sonar cloud configuration fo @PROJECT_NAME@ - @PROJECT_VERSION@
12
#
2-
# Project Configuration
3-
# Customize & run /path/to/sonar-runner/bin/sonar-runner -Dproject.settings=/path/to/sonar-project.properties
4-
#
3+
# Description: @PROJECT_DESCRIPTION@
4+
55
# Add more detail to both client and server-side analysis logs.
66
sonar.verbose=false
77

8-
# Specify not the the source directory, but some parent of the source directory
9-
#sonar.projectBaseDir=/path/to/project/root
10-
#sonar.working.directory=/path/to/working/folder/.sonar
8+
#-----------------------------------------------------------------------------
9+
#
10+
# Sonar cloud (sonarcloud.io) related settings.
11+
#
12+
#-----------------------------------------------------------------------------
1113

1214
# The project key that is unique for each project.
13-
sonar.projectKey=cpp-pthread
15+
sonar.projectKey=HerbertKoelman_cpp-pthread
16+
sonar.organization=herbertkoelman-github
17+
sonar.host.url=https://sonarcloud.io
1418

15-
# Name of the project that will be displayed on the web interface.
16-
sonar.projectName=cpp-pthread
17-
sonar.projectVersion=@BUILD@
19+
# Sonar cloud access token.
20+
sonar.login=d9888da64996176bfb1c39145242d78052b37be0
1821

19-
# Comma-separated paths to directories containing source files
20-
sonar.sources=src,include/pthread
21-
sonar.cfamily.build-wrapper-output.bypass=true
22+
# wrapper MUSt use this directory to produce it's data
23+
sonar.cfamily.build-wrapper-output=@CMAKE_CURRENT_BINARY_DIR@/bw-output
24+
sonar.cfamily.gcov.reportsPath=.
2225

23-
# Set the language of the source code to analyze. If not set, a multi-language analysis will be triggered.
24-
#sonar.language=
25-
# to exclude source code files
26-
sonar.exclusions=**/TST/**/*,**/TST/*
26+
#-----------------------------------------------------------------------------
27+
#
28+
# Project related properties.
29+
#
30+
#-----------------------------------------------------------------------------
2731

28-
# Comma-separated list of suffixes for files to analyze. To not filter, leave the list empty.
29-
#sonar.cobol.file.suffixes=cbl,kbl,sqb,kqb,cpy
30-
#sonar.cobol.copy.directories=
31-
#sonar.cobol.copy.suffixes=
32+
# Name of the project that will be displayed on the web interface.
33+
sonar.projectName=@PROJECT_NAME@
34+
sonar.projectVersion=@PROJECT_VERSION@
35+
sonar.links.homepage==https://github.com/HerbertKoelman/cpp-pthread
3236

33-
#sonar.c.file.suffixes=.c,.h
34-
#sonar.cpp.file.suffixes=.cc,.cpp,.cxx,.c++,.hh,.hpp,.hxx,.h++,.ipp,.kpp,.sqC,.kqp
35-
#sonar.cfamily.predefinedMacros=#include "requiredMacros.h"
36-
#sonar.cfamily.library.directories=/path/to/requiredMacros.h,/path/to/include/files
37+
# Base directory
38+
sonar.projectBaseDir=@CMAKE_SOURCE_DIR@
3739

40+
# directories that contain code to analyze
41+
sonar.sources=src,include

0 commit comments

Comments
 (0)