From 7f8b9134061b334ad2b64e3d48e294d4f9dba192 Mon Sep 17 00:00:00 2001 From: Cole Gannaway <156719330+cole-gannaway-sonarsource@users.noreply.github.com> Date: Wed, 22 May 2024 10:23:01 -0500 Subject: [PATCH] fixed build directory in scan --- .github/workflows/sonar.yaml | 5 +++++ CMakeLists.txt | 12 ++++++------ sonar-project.properties | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 7d628a4971be..679d2e64d220 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -30,7 +30,12 @@ jobs: node-version: '18' - name: Run build-wrapper run: | + rm -rf build + mkdir build + cd build + cmake .. cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON . + cd .. - name: Run sonar-scanner env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 565856365010..136de5c79f8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,12 +6,12 @@ # # ---------------------------------------------------------------------------- # Disable in-source builds to prevent source tree corruption. -# if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}") -# message(FATAL_ERROR " -# FATAL: In-source builds are not allowed. -# You should create a separate directory for build files. -# ") -# endif() +if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}") + message(FATAL_ERROR " +FATAL: In-source builds are not allowed. + You should create a separate directory for build files. +") +endif() include(cmake/OpenCVMinDepVersions.cmake) diff --git a/sonar-project.properties b/sonar-project.properties index e73dd6da3836..e03ad696388d 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,3 +1,3 @@ sonar.projectKey=SonarSource-Demos_opencv_552f564f-bcdb-47eb-abb2-4ba7feb428ee -sonar.cfamily.compile-commands=compile_commands.json +sonar.cfamily.compile-commands=build/compile_commands.json sonar.exclusions=**/*.java