What are the advantages of using Sonar's Build Wrapper to generate compilation databases?

Please provide

  • Operating system: Linux, Windows
  • SonarLint plugin version: 4.11.1
  • Programming language you’re coding in: C, C++
  • Is connected mode used:
    • Connected to: SonarQube Developer Edition v10.6

According to this article in order to analyze C and C++ code with SonarLint, it is necessary to generate a compilation database. The article then presents alternatives to do so, including the use of the build system (CMake in my case) or Sonar’s Build Wrapper.

However the article does not recommend either method. Are there reasons why I should prefer using Sonar’s Build Wrapper to generate compilation databases for C/C++ projects using CMake, or will SonarLint work equivalently well (in terms of coding feedbacks) if I simply use the CMAKE_EXPORT_COMPILE_COMMANDS feature of CMake?

Additionally, what is the answer to the same question for analysis run in a SonarQube server?

1 Like

Hey there.

Tucked away in the docs (under Using the build system), there’s this line:

When different choices are available, generating a compilation database through the build system should be preferred.

Stated another way, the build system is preferred to the build wrapper.

So I think that’s your answer.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.