PlatformIO Community

How to use custom xx_hal.conf.h

I noticed that during compilation a new xx_hal_conf file (in my case stm32h7xx_hal_conf.h) is generated from xx_hal_conf_template.h.
This generated file is then used by the compiler.
However, I would like to use my own version of this file they provide via STM32CubeMX. How to do it?
I tried to add include to main.h before #include “stm32h7xx_hal.h”, but it results in compilation errors:

In file included from /home/ppiorkow/.platformio/packages/framework-stm32cube@src-e6db69caf5e38938341a02a8ecc19401/h7/Drivers/CMSIS/Device/ST/STM32H7xx/Include/stm32h7xx.h:223:0,
                 from /home/ppiorkow/.platformio/packages/framework-stm32cube@src-e6db69caf5e38938341a02a8ecc19401/h7/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_def.h:30,
                 from /home/ppiorkow/.platformio/packages/framework-stm32cube@src-e6db69caf5e38938341a02a8ecc19401/h7/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_rcc.h:29,
                 from include/stm32h7xx_hal_conf.h:267,
                 from include/main.h:14,
                 from include/fmc.h:12,
                 from src/fmc.c:7:
/home/ppiorkow/.platformio/packages/framework-stm32cube@src-e6db69caf5e38938341a02a8ecc19401/h7/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal.h:1032:1: error: unknown type name 'HAL_StatusTypeDef'; did you mean 'HAL_TickFreqTypeDef'