cmake buildPresets runs without environment

I have an issue where I see my cmake buildPresets runs without the environment defined in the configurePresets. I tried defining the environment in the buildPresets as well but seems cmake still does not run with correct environment. Small example to see issue

{
  "configurePresets": [
    {
      "name": "default",
      "hidden": true,
      "environment": {
        "CCACHE_DIR": "${sourceDir}/build/.ccache",
      }
    },
 ],
  "buildPresets": [
    {
      "name": "test",
      "configurePreset": "default"
    }
]
 }   

If I then invoke ccache -p during the configure step (cmake --preset) then it is correctly set. But if I invoke ccache -p during the build (cmake --build) then the environment is not correct passed when ccache is invoked.

Dit you use: cmake —build —preset test?