CMake generator differences also cause different results on static analysis?

In order to create a configuration file before the build-wrapper process, I first analysed it with the cmake .. -G "Unix Makefiles" command as a generator and then with the cmake .. -G "Visual Studio 17 2022" command. The result I got is as follows; Using Unix Makefiles, I found more than 450 code smells and 24 bugs in my source code. When I generated and analysed the same code with cmake .. (I did not specify the generator because the default Visual Studio 17 is 2022), it found only around 200 code smells and no bugs in the source code. What exactly is the reason for this difference?

My buildwrapper command is build-wrapper-linux-x86-64 --out-dir bw_output cmake --build Sonarqube_Analysis/ --config Release.

Hello @codeluyor,

Would you be able to share the build-wrapper.log generated for each run? Without them, I can only provide guesses, so I would rather have a look to verify what may be going on.

In any case, without more information, I would advise using two separate build directories (one per generator) and making sure the build in both cases is done from scratch. Otherwise, some files may not need to be rebuilt, and they will not be seen by the build wrapper.

If the only thing that changed is the generator, I would expect the compiler flags to be the same in both cases, but I would suggest double-checking. Some files may be skipped from the analysis depending on the compiler flags (extensions). You can check if you see something like Microsoft extension activated by ... on your scanner logs.

Before compiling with different generators, I completely clean the past processes.

I can send you a private message.

There is no difference in the compiler flags, exactly the same. I also checked the logs, but I couldn’t find a command like "Microsoft extension activated by ..." as you said.

Please, do! As I said, I could only speculate :slight_smile:

For future reference, when using Unix Makefiles, cmake picked the right embedded gcc compiler, and the compilation succeeded. When using the Visual Studio generator, cmake picked Microsoft’s compiler, which would fail to compile the source code. Hence the disappearing issues.

1 Like

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