Analyzing header-only C++ library on Bitbucket


I’m trying to run an cfamily Sonarcloud analysis on a header-only C++ library, while the files are correctly detected, the sonar-scanner complains that there are no c/c++ files.

The structure of said project is the following:


I am using Bitbucket Cloud pipelines to run the analysis with the following configuration:

mkdir build && cd build
build-wrapper-linux-x86-64 --out-dir $BW_OUTPUT cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON && make -j`nproc --ignore=2`
cd ..
sonar-scanner -X$BW_OUTPUT -Dsonar.cfamily.threads=4 -Dsonar.cfamily.cache.enabled=false -Dsonar.sources=./include,./tests/

And I get the output in my pipeline:

13:13:16.971 INFO: ------------------------------------------------------------------------
java.lang.IllegalStateException: The "build-wrapper-dump.json" file was found but 0 C/C++/Objective-C files were analyzed.

I would like to figure out:

  • why it doesn’t detect the .cpp is the tests/ repository
  • if it’s only possible to analyze header-only library with sonarcloud


Hi @Arnaud_Saunier ,

could you please share the log of the analysis? If you prefer to share it privately I can send you a private message.

Hi, @mpaladin

Yes, I can send you in a private message.


The issue was found.

In the following command, only the cmake part is done under the build-wrapper not the make:

build-wrapper-linux-x86-64 --out-dir $BW_OUTPUT cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON && make -j`nproc --ignore=2`

So it needs to be two separate steps like this:

build-wrapper-linux-x86-64 --out-dir $BW_OUTPUT  make -j`nproc --ignore=2`

Thanks for your help!

1 Like

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