question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feature] MSBuildDeps generator: CAExcludePath

See original GitHub issue

In most cases if one wants to run the code analysis included in Visual Studio, one is not interested in findings in external code.

This is possible via the (poorly documented) CAExcludePath property, see e.g. https://stackoverflow.com/questions/43755499/suppress-warnings-for-external-headers-in-vs2017-code-analysis.

It would be nice if the MSBuildDeps generator could populate the CAExcludePath with the include paths of the dependencies.

Depending on how well the visual_studio/visual_studio_multi generators are still maintained, consider adding it there too.

Note that the few examples usages I found on the internet with a quick search seem to have the property under a <PropertyGroup Condition="'$(Language)'=='C++'"> group. A quick test suggest this is not needed, e.g. if I manually modify conan_boost.props to

...
<PropertyGroup>
	<LocalDebuggerEnvironment>PATH=%PATH%;$(ConanboostBinaryDirectories)$(LocalDebuggerEnvironment)</LocalDebuggerEnvironment>
	<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
	<CAExcludePath>$(ConanboostIncludeDirectories);$(CAExcludePath)</CAExcludePath>
</PropertyGroup>
...

the exclude seems to works fine.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
liesercommented, Mar 30, 2021

Thanks a lot for adding this this fast.

Did a quick test configuring it using profiles, and seems to works as expected. As we currently do not use the generate method in our recipes, I did not yet test setting the exclude_code_analysis property in a recipe instead of the profile.

Do I see it correctly that the [conf] settings can currently not be directly set via an argument then calling e.g. conan install, but instead always have to be in a profile or the global config?

1reaction
memshardedcommented, Mar 13, 2021

Thanks for the feedback @lieser

Based on the discussion, the approach should be:

  • Lets leave as-is by default. Code-analysis, same as compiler warnings should always be enabled by default. It is clear that there is no unique absolute default, users using Conan mostly for third-parties will want those excluded, but most users using Conan for their own packages, including header-only, will want them included.
  • Users can opt-out in recipes:
    def generate(self):
          msbuilddeps = MSBuildDeps(self)
          msbuilddeps.exclude_code_analysis = ["*"]  # we could define a ``True`` meaning "all", just the idea
    
  • This behavior can also be configured downstream by users, overriding the declared behavior
    [conf]
    tools.msbuild.msbuilddeps:exclude_code_analysis = False  # or True, or different patterns
    
    All the [conf] behavior can also applied selective to particular packages so mypkg:tools.msbuild.... is also possible.
Read more comments on GitHub >

github_iconTop Results From Across the Web

[bug] generator 'MSBuildDeps': 'settings.build_type' doesn't exist
This seems expected. The MSBuildDeps generator is multi-configuration, and it needs the build_type to be defined. It should be both defined as a ......
Read more >
conan.tools.microsoft — conan 1.44.1 documentation
The MSBuildDeps is the dependency information generator for Microsoft MSBuild build system. It will generate multiple xxxx.props properties files one per ...
Read more >
CAExcludePath ignored by static analyzer when using /external:I
CAExcludePath.png [severity:It's more difficult to complete my work] When performing static analysis, warnings from system headers can be silenced using the ...
Read more >
Add target property to set CAExcludePath in Visual Studio ...
My suggestion is to automatically set all default headers and all target include directories marked as SYSTEM to be excluded. Another solution ...
Read more >
C Runtime, Compiler and Build System Generator
The table below lists the different C runtime implementations, compilers and their usual distribution mechanisms for each operating systems. Linux. MacOSX.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found