How can I change a file in lib depending on env

I have a c++ file and two header files. I want to include a different .h file into the c++ depending on the environment. I have tried stuff with src_filter but it does not seem to work.

Looks like you need build_flags. For example,

platformio.ini

[env:myenv1]
platform = atmelavr
framework = arduino
board = uno
build_flags = -DHEADER_1

[env:myenv2]
platform = atmelavr
framework = arduino
board = uno
build_flags = -DHEADER_2

main.cpp


#ifdef HEADER_1
#include "myheader1.h"
#else
#include "myheader2.h
#endif