1

We have several C++ projects that use clang-format and clang-tidy and other similar tools. Currently the config files for these tools are stored in each project's Git repository. Now I'm trying to put these files into a separate repository so that they can be shared between all projects, so that all projects use the same config.

I have tried to deliver the config files from the separate repository as a Conan package that is downloaded during CMake configure phase. This works fine when the clang-format config is used only by some CMake target (we have a target that checks that all files are formatted correctly); but I also want to have this config available in Visual Studio Code, so that Ctrl+Shift+I reformats the current file correctly.
Problem is that the Conan package is unpacked into the build directory; but VS Code expects the config file in source directory.

I guess I can find workarounds or settings so that VS Code still finds the config file in build directory; but I'm wondering if I'm entirely on the wrong path here.

Clang-format was the tool where I noticed this first; but in the long run this will probably come up for many tools, because I think we want to have most analysis tools integrated both into the IDE (for quick feedback cycles) and into the build system (so that the checks are definitely run during local builds and during CI).

My requirements are basically:

  • have config files for analysis tools (like clang-format, clang-tidy) as single copy
  • have these files used by different CMake projects
  • in each project, have these config files available both for CMake targets and also for IDEs like VS Code
  • have the IDE use the correct config file without manual configuration

This seems like a problem that should come up in many software projects; so I wonder if there is a common way to solve this that I'm not seeing?

Edit: I'd prefer a solution that is independent of the exact IDE used; but if that's not possible, I'm mainly looking for a solution that works with Visual Studio Code.

oliver
  • 111
  • 4
  • I doubt there is a general solution here. IDEs handle configuration differently, and usually have different places where project config is stored. In the Java community, the two most common build tools (Maven and Gradle) have plugins to generate and update IDE project files for specific IDEs. Typically the main ones used in that world (Eclipse and IDEA). A similar approach can work here, but it's not guaranteed. – Berin Loritsch Jun 28 '22 at 19:50
  • You'd definitely need to scope down the problem to a couple IDEs tops. – Berin Loritsch Jun 28 '22 at 19:50
  • I'm not too familiar with Conan. It would be nice if you could copy files upon installing a Conan package. – Greg Burghardt Jul 04 '22 at 02:18

0 Answers0