Urghs, thanks for doing the research here. So they first enabled comment support intentionally, then disabled it intentionally. Currently, it just works by accident.
I’m not sure how we should deal with this. Having the comments is risky because future versions may not support them. (This PR here uses presets only for dev mode, but we may add other presets, e.g., for coverage….)
It seems that CMake’s parser defeats all the hacks I could imagine or find in https://stackoverflow.com/questions/244777/can-comments-be-used-in-json. Things we could do:
- Have a template file and strip
//
lines using grep, generating the actual .json
from it. But this needs some mechanism to make sure that the file is up to date etc… All doable but seems overkill for this tiny issue.
- (https://hjson.github.io/ is an entire off-the-shelf solution for this, but that adds a maintainer dependency and is hard to remember.)
- We could just drop the comments. CMake templates support a
cmakeMinimumRequired
field which I think is enough to document the need for CMake 3.21. A better warning should then be added to build docs (to be written :D). The comment about the missing generator thing can be in the commit message (not optimal but okayish).
I lean towards dropping comments. Sad that we need to spend time on this…