TheLartians/Format.cmake

Respect Skipping CMake Formatting Based on Setting in Top Level Project

DeveloperPaul123 opened this issue · 3 comments

I'm not sure how this would work, or if it's technically feasible, but I'm going to describe my issue through a hypothetical project.

Let's assume we have projects A and B. Project A depends on project B and pulls it in with CPM.

Both projects use Format.cmake; project A does not allow Cmake formatting, but project B does have that enabled.

Right now, when running "check-format" from project A, it will always fail because Format.cmake thinks that the CMakeLists files need to be formated even though FORMAT_SKIP_CMAKE is set to YES in project A.

Is there any way to work around this?

Just realized that one option is to just use check-clang-format in project A instead of check-format 🤦‍♂️

Currently I don't think per-project formatting rules are supported.

The recommended usage is to add Format.cmake not as a direct dependency of B but as a dependency of a subproject, e.g. the test suite. That way the dependency will not be included by default, but only when explicitly building the test cases. You can see an example of this in the ModernCppStarter.

Ok no problem, we can work around this for now.

And yes, I've seen that strategy already in your ModernCppStarter, but the issue would still remain if we want to disable CMake formatting in a downstream project if it's enabled upstream.