CMakeUserPresets.json: how to store Cmake options usually passed to the command line with -D ??

Hello,
after playing for hours in trying to do what is supposed to be the main purpose of the user presets, I have no other chances than opening a topic here.

I would like to store the options variables in CMakeUserPresets (rather then hardcoding them in scripts or whatever) and get them automatically merged to the main cmake configuration.
I normally pass the main option through the command line with -DMAINOPTION=ON and I have automatically loaded all the dependent options. If I also pass a dependent option with -DOPTIONOFMAINOPTION=value it also gets automatically populated.
How I can obtain the same through user presets?

I tried with cacheVariables, but when I click configure I just get such variable in the ungrouped entries and related dependent options don’t appear at all.
Many thanks

Please post the CMakeUserPresets.json that you’re using, the CMakeLists.txt, an explanation of what you expect to happen, and what is actually happening. Please strip CMakeUserPresets.json and CMakeLists.txt down to minimal illustrative examples.

Hello @kyle.edwards,
I spent the last couple of days in trials and documentation and I finally managed to understand how the whole thing works. Basically I need to know in advance and provide the main options and their dependant options in order to get the expected configuration.
I don’t want to abuse your time and I prefer to open a new topic when I will encounter some more serious problem. I will mark your response as the solution just because you have been so nice to offer me your help even for such stupid and annoying questions.
Thanks

IMHO: Your questen should be answered:

This is a CMakeUserPresets.json that implicit includes CMakePresets.json, so you may extend or overwrite the settings of an exising ConfigurePreset i.e.:

{
    "version": 6,
    "cmakeMinimumRequired": {
        "major": 3,
        "minor": 25,
        "patch": 0
    },
    "configurePresets": [
        {
            "name": "user-config",
            "description": "Example for user default settings that apply to all configurations",
            "generator": "Ninja",
            "inherits": "common-config",
            "cacheVariables": {
                "CMAKE_C_COMPILER": "gcc",
                "CMAKE_CXX_COMPILER": "g++"
            },
            "environment": { "VARIANT": "Clang" }
        }
    ]
}

But this doesn’t change the prestes, refering to or inherits from the original common-config preset!