Supporting CMake in kondo

Hey! I maintain an open source polyglot project cleaning tool called kondo. Picture attached for clarity

kondo has had very basic support for cmake projects for a while, however with v2 of the project underway I’m looking to expand support to as many different ways of using cmake as possible. It would be great to get feedback from actual cmake users if possible :grinning:

A user helpfully described numerous ways of using cmake in this issue thread. I want to know which of these is the most common or standard use of cmake. I’ve inlined the relevant section below.

# All of these are valid ways to configure the project, even simultaneously.
(mkdir build && cd build && cmake ..)                    # 1. Currently supported.
(mkdir _ && cd _ && cmake ..)                            # 2. Unsupported.
(mkdir build/config1 && cd build/config1 && cmake ../..) # 3. Unsupported.
(mkdir /tmp/build && cd /tmp/build && cmake /project/)   # 4. Unsupported, assumes project tree in `/project/`.
cmake .                                                  # 5. Unsupported.

Secondly, how prevalent is the use of the clean target? I ran through the cmake tutorial and saw one was generated for me.

Is clean something I could expect the majority of cmake projects to have? kondo currently performs all clean logic itself, though I am investigating shelling out to tools like cmake to invoke their logic if the user desires. Would that behaviour be expected or preferred from your perspective?

Thank you for your time, Trent :slight_smile:

For configuring I suggest just using cmake -Ssourcedir -Bbuilddir from tooling. There’s no need to faff about with mkdir, mkdir -p, cd, or subshells. You might also be interested in the --fresh flag (CMake 3.24+).

The clean target is definitely fine for Makefiles and Ninja generators. I think the IDE generators have something like it, but it might be named something else. For Ninja generators, you might want to also consider ninja -t cleandead which removes files that the .ninja_log knows about but the build.ninja file doesn’t have rules for anymore (e.g., you disable Python support after performing a build with Python enabled).