Can't find header file in lib/Components/src folder

I have been building a private library for my Arduino projects.

It is a project in its own right with each of the main components in a sub-directory under the project’s main directory.

DplhArduinoLibrary/
  lib/
    Components/
      src/
        Gme12864Xx_Oled.h
        Hc595ShiftRegister.h
        Oleds.h                <-- The file that can not be found.
    Network/
    Syslog/
    Utilities/
      src/
        I2CMux.h
        Logger.h
  platformio.ini
  ...

My platformio.ini file defines a number of build environments. The one I am working with at the moment is “env:oleds_test” which extends from others. It looks like this:

[env:feather_m0]
platform = atmelsam
board = adafruit_feather_m0
framework = arduino

env:test_base]
extends = env:feather_m0
build_flags =
	${env:feather_m0.build_flags}
	-D ERROR_PRINTABLE

[env:oleds_test]
  extends = env:test_base
build_flags =
	${env:test_base.build_flags}
	-D TEST_MAIN_CPP="\"../unitTests/OledsTest.cpp\""
lib_deps =
	adafruit/Adafruit GFX Library@^1.12.5
	adafruit/Adafruit SSD1306@^2.5.16

Building the project results in a “src/../unitTests/OledsTest.cpp:29:10: fatal error: Oleds.h: No such file or directory” error.

Turns out that the compiler can’t find any of the files in lib/Components/src. The application also includes files from lib/Utilities/src and it finds those just fine.

The full path to lib/component/src is included in the .pio/build/oleds_test/idedata.json file.

I have done a clean.

I have removed the .pio directory.

So, what am I missing?

TIA

What are you doing with this macro? You just #include TEST_MAIN_CPP in some other source file? That would be a really weird way to build the unit tests and would likely also prevent the library dependency finder to properly resolve the dependencies. I don’t think it can follow #include MACRO directives even if you set lib_ldf_mode = deep+, but you can give it a try.

main.cpp does indeed just include whatever is specified in the TEST_MAIN_CPP macro.

These aren’t standard unit tests. Most of them require special hardware setups.

This process has been working fine for other components. Like I said, it finds the files in lib/Utilities/src/ just fine.

lib_ldf_mode = deep+ does not help.

Okay. Problem solved.

It looks like you are right about the -D and #include.

A little more searching revealed a much better solution for what I want to do.

I am now using the build_src_filter option in my platformio.ini.

This seems to work as desired.

Thanks!