Does it make sense to set cmakeMinimimRequired in CMakePresets.json?

Hi all,

I am wondering if it makes sense to set the option field cmakeMinimumRequired in CMakePresets.json in addition to cmake_minimum_required() in the top-level CMakeLists.txt.

I made some experiments and it turned out that the JSON field does not has any influence on the project. It does not overwrite or set the minimum required version. It is still necessary to call the function cmake_minimuim_required(). Also the JSON field does not support version ranges.

Could the JSON field be used in a useful manner?

The cmakeMinimumRequired field in CMake presets is rarely useful. The version field is what matters for the preset itself, and as you’ve observed, the cmake_minimum_required() command in the top level CMakeLists.txt enforces the CMake version requirement and policies.

About the only use for cmakeMinimumRequired that I came across was where a presets file needed to use some feature only available in a later CMake version than what the project’s own minimum was. I forget what the feature was, probably something like a CMake cache variable or an option to ctest or cpack. Outside of that sort of use case, it’s hard to come up with a reason to bother putting cmakeMinimumRequired in a presets file. Frankly, I almost never do.

1 Like

Thanks for the clarification, Craig!