ESP-IDF: How to add custom compiler-flags

The recommended way of adding custom compiler flags to ESP-IDF projects is to add the following line to the end of main/CMakeLists.txt. Note: Don’t add it to CMakeLists.txt in the project root directory, but in the main/ subdirectory.

target_compile_options(${COMPONENT_LIB} PRIVATE -ffast-math)

Replace -ffast-math with your desired compiler flags.