Apply build flag for a specific file only

Hi everybody,

I was wondering if there is a way to set a build flag that is applied to a specific source file. I am trying to replicate CMakeLists configuration to build a dependency correctly. For instance, I would like to do the following:

set_source_files_properties(
  ${CORE_HTTP_PATH}/core_http_client.c
    PROPERTIES COMPILE_FLAGS
      -Wno-stringop-truncation
)

Setting build_flags to -Wno-stringop-truncation" in platformio.ini or library.json works, but it applies this flag to all source files.

Thanks in advance!

Maksim

This is exactly an application of advanced scripting as documented in

https://docs.platformio.org/en/latest/scripting/middlewares.html

1 Like