From 6613a952d5b4dee72c95360898dc5f3cf279ffd3 Mon Sep 17 00:00:00 2001 From: herbert koelman Date: Sun, 14 Jul 2019 15:25:48 +0200 Subject: [PATCH 1/7] Fixes #143 @1h - Upgraded Google Test cmake module - Raw copy of sonar cloud cmake module (need to be taylored later) --- CMakeLists.txt | 7 ++-- cmake/GTestConfig.cmake | 46 ------------------------- cmake/GTestExtConfig.cmake | 56 +++++++++++++++++++++++++++++++ cmake/SonarCloudConfig.cmake | 54 +++++++++++++++++++++++++++++ cmake/sonar-project.properties.in | 12 +++++++ tests/CMakeLists.txt | 1 + 6 files changed, 126 insertions(+), 50 deletions(-) delete mode 100644 cmake/GTestConfig.cmake create mode 100644 cmake/GTestExtConfig.cmake create mode 100644 cmake/SonarCloudConfig.cmake create mode 100644 cmake/sonar-project.properties.in diff --git a/CMakeLists.txt b/CMakeLists.txt index a18c0cd..7249def 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ configure_file(src/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h) # uncomment if you have a conanfile.txt and run 'conan install ...' include(conan_paths) #find_package(Git CONFIG) #find_package(Conan) +find_package(GTestExt PATHS cmake) # main targets -------------------------------------------------- # @@ -60,11 +61,9 @@ set_target_properties(cpp-pthread-shared PROPERTIES OUTPUT_NAME cpp-pthread) # Testing ------------------------------------------------------- # -# Load and compile GTest -# Aliases: GTest::GTest, GTest::gtest_main, GMock::GMock -find_package(GTest PATHS cmake) -if (GTest_FOUND) +if (GTestExt_FOUND AND BUILD_TESTS) enable_testing() + message(STATUS "Adding project's unit tests (in ./tests)...") add_subdirectory(tests) endif() diff --git a/cmake/GTestConfig.cmake b/cmake/GTestConfig.cmake deleted file mode 100644 index d380c65..0000000 --- a/cmake/GTestConfig.cmake +++ /dev/null @@ -1,46 +0,0 @@ -set(__GTEST_DOWNLOAD ${CMAKE_BINARY_DIR}/googletest-download) -file(MAKE_DIRECTORY ${__GTEST_DOWNLOAD}) -if (EXISTS ${__GTEST_DOWNLOAD}) - - option(INSTALL_GMOCK "Install Googletest's GMock?" OFF) - option(INSTALL_GTEST "Install Googletest's GTest?" OFF) - - message(STATUS "Generating GoogleTest CMakeLists.txt") - configure_file(${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in ${__GTEST_DOWNLOAD}/CMakeLists.txt) - - message(STATUS "Setup build for GoogleTest") - execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . - WORKING_DIRECTORY "${__GTEST_DOWNLOAD}" ) - - message(STATUS "Building GoogleTest") - execute_process(COMMAND "${CMAKE_COMMAND}" --build . - WORKING_DIRECTORY "${__GTEST_DOWNLOAD}" ) - - # Prevent GoogleTest from overriding our compiler/linker options - # when building with Visual Studio - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - - # Add googletest directly to our build. This adds - # the following targets: gtest, gtest_main, gmock - # and gmock_main - add_subdirectory("${CMAKE_BINARY_DIR}/googletest-src" - "${CMAKE_BINARY_DIR}/googletest-build") - - # The gtest/gmock targets carry header search path - # dependencies automatically when using CMake 2.8.11 or - # later. Otherwise we have to add them here ourselves. - if(CMAKE_VERSION VERSION_LESS 2.8.11) - message(STATUS "GoogleTest include directory ${gtest_SOURCE_DIR}/include ${gmock_SOURCE_DIR}/include)") - include_directories("${gtest_SOURCE_DIR}/include" - "${gmock_SOURCE_DIR}/include") - endif() - - add_library(GTest::GTest ALIAS gtest) - add_library(GTest::gtest_main ALIAS gtest_main) - - add_library(GMock::GMock ALIAS gmock) - add_library(GMock::gmock_main ALIAS gmock_main) - -else() - message(STATUS "Failed to create GoogleTest download directory") -endif() \ No newline at end of file diff --git a/cmake/GTestExtConfig.cmake b/cmake/GTestExtConfig.cmake new file mode 100644 index 0000000..ea0d53d --- /dev/null +++ b/cmake/GTestExtConfig.cmake @@ -0,0 +1,56 @@ +set(BUILD_TESTS True CACHE BOOL "if set, then GoogleTest is download and built.") + +if (BUILD_TESTS) + message(STATUS "Download and build Google Test (GTest)...") + + set(__GTEST_DOWNLOAD ${CMAKE_BINARY_DIR}/googletest-download) + file(MAKE_DIRECTORY ${__GTEST_DOWNLOAD}) + if (EXISTS ${__GTEST_DOWNLOAD}) + + option(INSTALL_GMOCK "Install Googletest's GMock?" OFF) + option(INSTALL_GTEST "Install Googletest's GTest?" OFF) + + message(STATUS "Generating GoogleTest CMakeLists.txt") + configure_file(${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in ${__GTEST_DOWNLOAD}/CMakeLists.txt) + + message(STATUS "Setup build for GoogleTest") + execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . + WORKING_DIRECTORY "${__GTEST_DOWNLOAD}" ) + + message(STATUS "Building GoogleTest") + execute_process(COMMAND "${CMAKE_COMMAND}" --build . + WORKING_DIRECTORY "${__GTEST_DOWNLOAD}" ) + + # Prevent GoogleTest from overriding our compiler/linker options + # when building with Visual Studio + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + + # Add googletest directly to our build. This adds + # the following targets: gtest, gtest_main, gmock + # and gmock_main + add_subdirectory("${CMAKE_BINARY_DIR}/googletest-src" + "${CMAKE_BINARY_DIR}/googletest-build") + + # The gtest/gmock targets carry header search path + # dependencies automatically when using CMake 2.8.11 or + # later. Otherwise we have to add them here ourselves. + if(CMAKE_VERSION VERSION_LESS 2.8.11) + message(STATUS "GoogleTest include directory ${gtest_SOURCE_DIR}/include ${gmock_SOURCE_DIR}/include)") + include_directories("${gtest_SOURCE_DIR}/include" + "${gmock_SOURCE_DIR}/include") + endif() + + add_library(GTest::GTest ALIAS gtest) + add_library(GTest::gtest_main ALIAS gtest_main) + + add_library(GMock::GMock ALIAS gmock) + add_library(GMock::gmock_main ALIAS gmock_main) + + message(STATUS "Defined GoogleTest aliases: GTest::GTest, GTest::gtest_main, GMock::GMock") + + else() + message(STATUS "Failed to create GoogleTest download directory. Make sure you have Internet access or use -DBUILD_TESTS=off") + endif() +else() + message(STATUS "Disabled unit testing (BUILD_TESTS is ${BUILD_TESTS})") +endif() \ No newline at end of file diff --git a/cmake/SonarCloudConfig.cmake b/cmake/SonarCloudConfig.cmake new file mode 100644 index 0000000..f22ab0d --- /dev/null +++ b/cmake/SonarCloudConfig.cmake @@ -0,0 +1,54 @@ +message(STATUS "Loading SonarCloud module found here: ${CMAKE_CURRENT_LIST_DIR}") + +option(SONAR "Generate sonar setup" ) # default is OFF + +set(SONAR_CLOUD_HOME https://sonarcloud.io CACHE STRING "Sonar cloud home URL(default is https://sonarcloud.io)") +set(SONAR_PROJECT_KEY ${PROJECT_NAME} CACHE STRING "Sonar project key property (default is ${PROJECT_NAME})") +set(SONAR_ORGANIZATION CACHE STRING "Organization (default is empty)") +set(SONAR_ACCESS_TOKEN CACHE STRING "Access/login token (default is empty)") + +set(SONAR_WRAPPER_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/bw-output CACHE STRING "Sonar C/C++ wrapper output directory (default is bw-output)") + +set(SONAR_PROPERTIES_FILE ${SONAR_PROPERTIES_FILE} CACHE STRING "If file exists, it will used as is (default is empty)") + +if ( SONAR ) + + find_program(SONAR_SCANNER sonar-scanner) + + if ( SONAR_SCANNER ) + + if(NOT EXISTS ${SONAR_PROPERTIES_FILE} ) + message(STATUS "Generating SONAR properties file (${CMAKE_CURRENT_BINARY_DIR}/sonar-project.properties)") + configure_file(${CMAKE_CURRENT_LIST_DIR}/sonar-project.properties.in sonar-project.properties) + set(SONAR_PROPERTIES_FILE ./sonar-project.properties) + else() + message(STATUS "Sonar scanner property file was provided (${SONAR_PROPERTIES_FILE})") + endif() + + add_custom_target( code-quality + COMMAND ${SONAR_SCANNER} -Dproject.settings=${SONAR_PROPERTIES_FILE} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "run ${SONAR_SCANNER} -Dproject.settings=${SONAR_PROPERTIES_FILE} " + ) + message(STATUS "Added custom target [code-quality]...") + + find_program(SONAR_BUILD_WRAPPER build-wrapper-linux-x86-64) + if ( SONAR_BUILD_WRAPPER ) + add_custom_target( build-wrapper + COMMAND ${SONAR_BUILD_WRAPPER} --out-dir ${SONAR_WRAPPER_OUTPUT_DIR} make clean all + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "run SONAR's ${SONAR_BUILD_WRAPPER}" + ) + message(STATUS "Added custom target [build-wrapper]...") + add_dependencies(code-quality build-wrapper) + endif() + + + else() + message(SEND_ERROR "Failed to find the program [sonar_scanner], make sure sonar tools are installed.") + endif() + +#else() +# message(WARNING "SONAR cloud build is turned off, use -DSONAR=yes to turn in ON") +endif() + diff --git a/cmake/sonar-project.properties.in b/cmake/sonar-project.properties.in new file mode 100644 index 0000000..06ab8d0 --- /dev/null +++ b/cmake/sonar-project.properties.in @@ -0,0 +1,12 @@ +# Project Configuration @PROJECT_NAME@ version @PROJECT_VERSION@ +sonar.verbose=false +sonar.projectBaseDir=@CMAKE_SOURCE_DIR@ +sonar.projectKey=@SONAR_PROJECT_KEY@ +sonar.organization=@SONAR_ORGANIZATION@ +sonar.links.homepage=@SONAR_PROJECT_HOME@ +sonar.host.url=@SONAR_CLOUD_HOME@ +sonar.login=@SONAR_ACCESS_TOKEN@ +sonar.cfamily.build-wrapper-output=@SONAR_WRAPPER_OUTPUT_DIR@ +sonar.projectName=@PROJECT_NAME@ +sonar.projectVersion=@PROJECT_VERSION@ +sonar.sources=src,include diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index af29e90..7d35e06 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,5 @@ +# Aliases: GTest::GTest, GTest::gtest_main, GMock::GMock #enable_testing() message(STATUS "Add GoogleTest cpp_thread_tests") From 099aacb16015913b55001a4ab3c918d7e2af0b09 Mon Sep 17 00:00:00 2001 From: herbert koelman Date: Sun, 14 Jul 2019 16:33:21 +0200 Subject: [PATCH 2/7] fixes #144 --- .travis.yml | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..bf3987a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,54 @@ +# autho: Herbert Koelman +# created on: 1/6/2019 +os: linux + +# use Ubuntu Xenial (version 16) +# This comes with cmake 3.11 which is required to build GoogleTest +dist: xenial +language: cpp +compiler: gcc + +env: + CODECOV_TOKEN="6fa05a9c-1a01-4123-b726-d493275017cd" + +# Run travis on these branches only... +branches: + only: + - master + - develop + +addons: + sonarcloud: + organization: "herbertkoelman-github" + + apt: + packages: + - doxygen + - graphviz + +matrix: + include: + - name: coverage jobs + env: + BUILD_DIRECTORY=cmake-gcov-build + CMAKE_COMMAND_LINE_ARGS="-DGCOV=yes" + MAKE_TARGETS="all test" + - name: sonar code quality checks + env: + BUILD_DIRECTORY=cmake-sonar-build + CMAKE_COMMAND_LINE_ARGS="-DSONAR=yes" + MAKE_TARGETS="code-quality" + - name: default + env: + BUILD_DIRECTORY=cmake-default-build + CMAKE_COMMAND_LINE_ARGS="-DCMAKE_BUILD_TYPE=Release" + MAKE_TARGETS="all doxygen package" + +script: + - mkdir $BUILD_DIRECTORY && cd $BUILD_DIRECTORY && cmake $CMAKE_COMMAND_LINE_ARGS .. && make $MAKE_TARGETS + +after_success: + # create gcov files + - find ./CMakeFiles/ -type f -name "*.gcno" -exec gcov {} -m \; + # upload data to codecav + - bash <(curl -s https://codecov.io/bash) From 015b3d05f256a044311d7b61ec87032da980d09e Mon Sep 17 00:00:00 2001 From: herbert koelman Date: Sun, 14 Jul 2019 16:59:25 +0200 Subject: [PATCH 3/7] fixes #145 @1h --- CMakeLists.txt | 32 +++++++++++++++++--------------- README.md | 2 ++ tests/CMakeLists.txt | 7 ++++--- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7249def..d57a7e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,14 +10,17 @@ project( DESCRIPTION "Simple C++ wrapper to pthread functions (${GIT_LOG})") option(BUILD_TESTS "enable/disable tests (default is enabled)" ON) -set(CMAKE_CXX_STANDARD 11) +option(GCOV "Activate GCOV options") -configure_file(src/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h) +if ( GCOV ) + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + message(STATUS "Setting GCOV compiler options") + add_compile_options(--coverage) + else() + message(SEND_ERROR "The GCOV option is only supported when using GNU...") + endif() +endif() -# this works because we've extended CMAKE_MODULE_PATH -# uncomment if you have a conanfile.txt and run 'conan install ...' include(conan_paths) -#find_package(Git CONFIG) -#find_package(Conan) find_package(GTestExt PATHS cmake) # main targets -------------------------------------------------- @@ -49,6 +52,9 @@ set(PTHREAD_SOURCE_CODE src/thread.cpp src/mutex.cpp ) + +set(CMAKE_CXX_STANDARD 11) + add_library(cpp-pthread-static STATIC ${PTHREAD_SOURCE_CODE}) target_link_libraries(cpp-pthread-static pthread) set_target_properties(cpp-pthread-static PROPERTIES OUTPUT_NAME cpp-pthread) @@ -71,11 +77,11 @@ endif() # find_package(Doxygen REQUIRED dot OPTIONAL_COMPONENTS mscgen dia) if (Doxygen_FOUND) - # set(DOXYGEN_OUTPUT_DIRECTORY doxygen) - # set(DOXYGEN_GENERATE_MAN YES) - # set(DOXYGEN_GENERATE_HTML YES) + + set(DOXYGEN_PROJECT_NUMBER ${CPP_PTHREAD_VERSION}) set(DOXYGEN_EXAMPLE_PATH tests) - set(DOXYGEN_PROJECT_BRIEF "Simple C++ wrapper to pthread functions.") + set(DOXYGEN_EXTRACT_ALL yes) + set(DOXYGEN_PROJECT_BRIEF ${PROJECT_DESCRIPTION}) set(DOXYGEN_USE_MDFILE_AS_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md") doxygen_add_docs(doxygen README.md src include COMMENT "generate on-line documentation") @@ -85,7 +91,7 @@ endif() # install( TARGETS cpp-pthread-static cpp-pthread-shared DESTINATION lib ) install( DIRECTORY include DESTINATION include COMPONENT Devel) -# install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc) +install( DIRECTORY ${PROJECT_BINARY_DIR}/html/ DESTINATION doc/cpp-pthread COMPONENT Documentation) # CPACK --------------------------------------------------------- # @@ -98,7 +104,3 @@ set(CPACK_PACKAGE_VENDOR "Urbix Software") set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) include(CPack) - -# misc ------------------------------------------------------------ -# -find_program(RM rm) diff --git a/README.md b/README.md index 15dcb55..53a2ca4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ ### What it does +[![Build Status](https://travis-ci.com/HerbertKoelman/cpp-pthread.svg?branch=master)](https://travis-ci.com/HerbertKoelman/cpp-pthread) + Some C/C++ compilers are not implementing all of C++11 and above standard, it's often lacking the concurrency features that the standard brings. These compilers will at some point be updated. I was therefore looking for a way to reduce the effort of switching from a specific implementation to the C++11 standard one. This projetc is the resulting code. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7d35e06..939a626 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,9 +1,10 @@ -# Aliases: GTest::GTest, GTest::gtest_main, GMock::GMock -#enable_testing() +if (GCOV AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")) + set(GCOV_LIB gcov) +endif() message(STATUS "Add GoogleTest cpp_thread_tests") add_executable(cpp_thread_tests concurrency_tests.cpp exceptions_tests.cpp synchronized_queue_tests.cpp) -target_link_libraries(cpp_thread_tests GTest::GTest GTest::gtest_main cpp-pthread-shared) +target_link_libraries(cpp_thread_tests GTest::GTest GTest::gtest_main cpp-pthread-shared ${GCOV_LIB}) add_test(NAME cpp_thread_tests COMMAND cpp_thread_tests) From 962b5400009e73583c1f15cf51bbf8437bf898eb Mon Sep 17 00:00:00 2001 From: herbert koelman Date: Sun, 14 Jul 2019 17:04:39 +0200 Subject: [PATCH 4/7] Added CodeCover access token --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bf3987a..a9ca879 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ language: cpp compiler: gcc env: - CODECOV_TOKEN="6fa05a9c-1a01-4123-b726-d493275017cd" + CODECOV_TOKEN="73b7985a-7b2d-40fa-a025-65906959f9c2" # Run travis on these branches only... branches: From 6a75770ce4b0a6bea9a42992e1e740de5a5ea5db Mon Sep 17 00:00:00 2001 From: herbert koelman Date: Sun, 14 Jul 2019 17:07:59 +0200 Subject: [PATCH 5/7] config file is still used... --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d57a7e8..83c866b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,8 @@ else() endif() endif() +configure_file(src/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h) + # project's public headers include_directories(include src) From 649ebb63a033c56f440cc1048821b81a066b64db Mon Sep 17 00:00:00 2001 From: herbert koelman Date: Sun, 14 Jul 2019 17:19:36 +0200 Subject: [PATCH 6/7] fixes #146 Use static library... --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 939a626..6cde357 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,6 +5,6 @@ endif() message(STATUS "Add GoogleTest cpp_thread_tests") add_executable(cpp_thread_tests concurrency_tests.cpp exceptions_tests.cpp synchronized_queue_tests.cpp) -target_link_libraries(cpp_thread_tests GTest::GTest GTest::gtest_main cpp-pthread-shared ${GCOV_LIB}) +target_link_libraries(cpp_thread_tests GTest::GTest GTest::gtest_main cpp-pthread-static ${GCOV_LIB}) add_test(NAME cpp_thread_tests COMMAND cpp_thread_tests) From 29bfa1cc34e4fed5c174dbb66f4c80aea7fd9a7f Mon Sep 17 00:00:00 2001 From: herbert koelman Date: Sun, 14 Jul 2019 18:43:47 +0200 Subject: [PATCH 7/7] fixes #147 @2h --- .gitignore | 1 + .travis.yml | 2 +- CMakeLists.txt | 6 ++++ cmake/SonarCloudConfig.cmake | 11 ++++++++ sonar-project.properties.in | 54 +++++++++++++++++++----------------- 5 files changed, 48 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index dc31282..d52bcbf 100644 --- a/.gitignore +++ b/.gitignore @@ -72,6 +72,7 @@ compile_commands.json CTestTestfile.cmake # layout +.scannerwork doxyfile *.tar sonar-project.properties diff --git a/.travis.yml b/.travis.yml index a9ca879..e8113c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,7 +37,7 @@ matrix: env: BUILD_DIRECTORY=cmake-sonar-build CMAKE_COMMAND_LINE_ARGS="-DSONAR=yes" - MAKE_TARGETS="code-quality" + MAKE_TARGETS="all test code-quality" - name: default env: BUILD_DIRECTORY=cmake-default-build diff --git a/CMakeLists.txt b/CMakeLists.txt index 83c866b..361c8c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,12 @@ endif() find_package(GTestExt PATHS cmake) +# This part MUST be executed before the loading of the CMake package +set(SONAR_PROPERTIES_FILE ${CMAKE_CURRENT_BINARY_DIR}/sonar-project.properties) +message(STATUS "Generating SONAR properties file ${SONAR_PROPERTIES_FILE}") +configure_file(${CMAKE_CURRENT_LIST_DIR}/sonar-project.properties.in ${SONAR_PROPERTIES_FILE}) +find_package(SonarCloud PATHS cmake) + # main targets -------------------------------------------------- # if( CMAKE_BUILD_TYPE MATCHES Release ) diff --git a/cmake/SonarCloudConfig.cmake b/cmake/SonarCloudConfig.cmake index f22ab0d..bdf3f27 100644 --- a/cmake/SonarCloudConfig.cmake +++ b/cmake/SonarCloudConfig.cmake @@ -43,6 +43,17 @@ if ( SONAR ) add_dependencies(code-quality build-wrapper) endif() + find_program(SONAR_GCOV gcov) + if(SONAR_GCOV) + add_custom_target( sonar-gcov-report + COMMAND find ./CMakeFiles/ -type f -name "*.gcno" -exec ${SONAR_GCOV} {} -m \; > /dev/null 2>&1 + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Built sonar GCOV report (${SONAR_GCOV})" + VERBATIM + ) + message(STATUS "Added custom target [sonar-gcov-report]...") + add_dependencies(code-quality sonar-gcov-report) + endif() else() message(SEND_ERROR "Failed to find the program [sonar_scanner], make sure sonar tools are installed.") diff --git a/sonar-project.properties.in b/sonar-project.properties.in index f79f49a..e7bcb6a 100644 --- a/sonar-project.properties.in +++ b/sonar-project.properties.in @@ -1,37 +1,41 @@ +# Sonar cloud configuration fo @PROJECT_NAME@ - @PROJECT_VERSION@ # -# Project Configuration -# Customize & run /path/to/sonar-runner/bin/sonar-runner -Dproject.settings=/path/to/sonar-project.properties -# +# Description: @PROJECT_DESCRIPTION@ + # Add more detail to both client and server-side analysis logs. sonar.verbose=false -# Specify not the the source directory, but some parent of the source directory -#sonar.projectBaseDir=/path/to/project/root -#sonar.working.directory=/path/to/working/folder/.sonar +#----------------------------------------------------------------------------- +# +# Sonar cloud (sonarcloud.io) related settings. +# +#----------------------------------------------------------------------------- # The project key that is unique for each project. -sonar.projectKey=cpp-pthread +sonar.projectKey=HerbertKoelman_cpp-pthread +sonar.organization=herbertkoelman-github +sonar.host.url=https://sonarcloud.io -# Name of the project that will be displayed on the web interface. -sonar.projectName=cpp-pthread -sonar.projectVersion=@BUILD@ +# Sonar cloud access token. +sonar.login=d9888da64996176bfb1c39145242d78052b37be0 -# Comma-separated paths to directories containing source files -sonar.sources=src,include/pthread -sonar.cfamily.build-wrapper-output.bypass=true +# wrapper MUSt use this directory to produce it's data +sonar.cfamily.build-wrapper-output=@CMAKE_CURRENT_BINARY_DIR@/bw-output +sonar.cfamily.gcov.reportsPath=. -# Set the language of the source code to analyze. If not set, a multi-language analysis will be triggered. -#sonar.language= -# to exclude source code files -sonar.exclusions=**/TST/**/*,**/TST/* +#----------------------------------------------------------------------------- +# +# Project related properties. +# +#----------------------------------------------------------------------------- -# Comma-separated list of suffixes for files to analyze. To not filter, leave the list empty. -#sonar.cobol.file.suffixes=cbl,kbl,sqb,kqb,cpy -#sonar.cobol.copy.directories= -#sonar.cobol.copy.suffixes= +# Name of the project that will be displayed on the web interface. +sonar.projectName=@PROJECT_NAME@ +sonar.projectVersion=@PROJECT_VERSION@ +sonar.links.homepage==https://github.com/HerbertKoelman/cpp-pthread -#sonar.c.file.suffixes=.c,.h -#sonar.cpp.file.suffixes=.cc,.cpp,.cxx,.c++,.hh,.hpp,.hxx,.h++,.ipp,.kpp,.sqC,.kqp -#sonar.cfamily.predefinedMacros=#include "requiredMacros.h" -#sonar.cfamily.library.directories=/path/to/requiredMacros.h,/path/to/include/files +# Base directory +sonar.projectBaseDir=@CMAKE_SOURCE_DIR@ +# directories that contain code to analyze +sonar.sources=src,include