Build wrapper cmake / ninja / Qt - Header files not found

Hi,

Sonar analyser could not find any Qt header, so the analysis doesn’t work well.

The analyzer was not able to find file
  QAbstractItemModel
  included from file C:/azp/agent/_work/1/s/sources/Sources/precompiled_headers.h
  included from file C:/azp/agent/_work/1/b/builddir/Sources/Common/XLProToolkit/CMakeFiles/XLProToolkit.dir/cmake_pch.hxx
  included from file <built-in>

We’ve got the issue since we have migrated our build system to cmake/ninja. Our previous build system was based on qmake/jom.
The analysis run on Windows 10 VM with azure agent, the analysis is triggered from our Azure DevOps Pipeline.

SonarQube : 8.9
CFamily plugin version: 6.20.2.38358
Logs :
issue-file-not-found-logs.zip (1.1 MB)

Hello @matthieug,

In your build-wrapper json I see that you are using -external:I. The header files that aren’t found reside in the directories added by that option:

"-external:I",
"C:\\qt\\5.15.7\\msvc2019_64\\include",
"-external:I",
"C:\\qt\\5.15.7\\msvc2019_64\\include\\QtCore",
"-external:I",
"C:\\qt\\5.15.7\\msvc2019_64\\.\\mkspecs\\win32-msvc",

The support of this option is coming in CFamily 6.31.

Until then you can try one of these temporary options:

  • Add these include directory twice using “-external:I” and “-I”. This should be functionally equivalent since the directory will still be considered external.

  • Avoid using this option for the analysis build.

  • Write a script that replace -external:I with -I in the build-wrapper.json before running the scanner.

Thanks,

Hi @Abbas_Sabra

I added a DevOps pipeline task to replace the flag in the build-wrapper-dump.json. It works :slight_smile: !
Here the DevOps task :

- bash: |
          cd "$(Build.SourcesDirectory)/bw-output"
          sed -i 's/external:I/I/g' build-wrapper-dump.json

Thank you.

2 Likes

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