Menu

Specifying a project file and explicit source files

Chard
2024-04-27
2024-05-01
  • Chard

    Chard - 2024-04-27

    Some recent develoment using cmake resulted in a cutover to invoke cppcheck via the in-built CMAKE_CPPCHECK support.
    Having recently gone through a similar process for clang-tidy, making use of compile_commands.json, I blindly added this file via --project. However, cmake invokes cppcheck for every source file (as part of its co-compile process), passing each for a single file analysis.
    The version of cppcheck I was using (2.3) ignores the source file if a project file has been specified. The outcome was that a full cppcheck project analysis was invoked for every source file invocation 😅
    I see in the latest version that specifying a file and project now generates an error - presumably I'm not the first.
    Naturally, the answer is: do not specify the project file.

    However, given that the project file provides the compilation settings, etc., it would be useful if cppcheck could behave in the same way as clang-tidy does here; i.e. if an explicit source file is provided on the command-line, then look it up in the project file and perform a single file analysis with the settings found for it (or a switch to activate that behaviour).

     
  • Oliver Stöneberg

    I think you need to use --project= with --file-filter= to get the expected result.

    That is actually a nice trick we should document (in case it works as expected).

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.