I’m trying to scan a C++ project built with CMake, but the scan fails with java.lang.IllegalStateException: The Compilation Database JSON file was found but 0 C/C++/Objective-C files were analyzed.
Here are the properties I’m using
> sonar.cfamily.cache.enabled=true
> sonar.cfamily.compile-commands=target/compile_commands.json
> sonar.sources=src/
> sonar.exclusions=src/test/**/*
> sonar.tests=src/test/
> sonar.test.inclusions=src/test/**/*
> sonar.verbose=true
Removing the cache property, removing the test properties or adding the src files via “sonar.inclusions” doesn’t make a difference.
The file paths in compile_commands match the real paths.
Some logged info that confirms my files are detected:
- “1 language detected in 165 preprocessed files”
- During “indexing files”, all relevant files are indexed (running with “debug” lists them, and it says “165 files indexed”).
- During “Analyzing language associated files and files included via “sonar.text.inclusions” that are tracked by git”, all files are listed with UTF-8 encoding (“164/164 source files have been analyzed”)
- I have many entries of “Skipping entry with non-existing directory: /__w/1/s/target/src”, which I guess is to be expected, since my files are in /__w/1/s/src, not in the “target” dir – again, compile_commands.json shows the correct paths.
The error starts with:
INFO: Detected compilers: c++=187;cc=1
INFO: Number of compilation units in the provided Compilation Database: 188
INFO: Number of skipped unsupported compilation units: 188
DEBUG: unsupported compilation units:
It then lists all the files that should be included, followed by the Java exception saying 0 files are found.
What is happening? Why doesn’t it recognize my C++ files?