Build trying to use headers flagged out

I am struggling to prevent Platformio trying to pull header files (Ethernet.h and SPI.h) that are not part of the project. These are mentioned in the eModbus library that is for both ESP32 and ESP8266. The library code but has these #include lines surrounded by #ifdef, that will not evaluate to true in the ESP8266 environment.

platformio.ini:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:esp8285]
platform = espressif8266
board = esp8285
framework = arduino
lib_deps = 
	FauxmoESP=https://github.com/vintlabs/fauxmoESP
	eModbus=https://github.com/eModbus/eModbus
board_build.flash_mode = dout
board_build.ldscript = eagle.flash.1m64.ld
monitor_speed = 115200
monitor_filters = esp8266_exception_decoder
build_flags = 
    -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH 
    -DLOG_LEVEL=LOG_LEVEL_VERBOSE
upload_protocol = espota
upload_port = Gosund01
upload_flags = 
	--port=8266
	--auth="XxXX"

The code containing the references to Ethernet.h and SPI.h is not even used in those files the project is using. If I will open the library code using those, the #ifdef seems to be functional, the code is dimmed:
grafik

Nevertheless a buil is failing due to these files missing in ESP8266 environment:

> Executing task in folder SmartDose: C:\Users\Micha\.platformio\penv\Scripts\pio.exe run <

Processing esp8285 (platform: espressif8266; board: esp8285; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/esp8285.html
PLATFORM: Espressif 8266 (2.6.2) > Generic ESP8285 Module
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
 - framework-arduinoespressif8266 3.20704.0 (2.7.4)
 - tool-esptool 1.413.0 (4.13)
 - tool-esptoolpy 1.20800.0 (2.8.0)
 - toolchain-xtensa 2.40802.200502 (4.8.2)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 47 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <FauxmoESP> 3.2.0+sha.810d5d7
|   |-- <ESPAsyncTCP> 1.2.2      
|   |   |-- <ESP8266WiFi> 1.0    
|   |-- <ESP8266WiFi> 1.0        
|-- <eModbus> 0.0.1+sha.27f3ec7  
|   |-- <ESPAsyncTCP> 1.2.2      
|   |   |-- <ESP8266WiFi> 1.0    
|   |-- <Ethernet> 2.0.0
|-- <ESP8266WiFi> 1.0
|-- <LittleFS(esp8266)> 0.1.0    
|-- <ArduinoOTA> 1.0
|   |-- <ESP8266WiFi> 1.0        
|   |-- <ESP8266mDNS> 1.2        
|   |   |-- <ESP8266WiFi> 1.0    
|-- <ESP8266WebServer> 1.0       
|   |-- <ESP8266WiFi> 1.0        
Building in release mode
Archiving .pio\build\esp8285\libe3a\libESPAsyncTCP.a
Archiving .pio\build\esp8285\lib96b\libFauxmoESP.a
Compiling .pio\build\esp8285\lib0af\Ethernet\Dhcp.cpp.o
Compiling .pio\build\esp8285\lib0af\Ethernet\Dns.cpp.o
Compiling .pio\build\esp8285\lib0af\Ethernet\Ethernet.cpp.o
Compiling .pio\build\esp8285\lib0af\Ethernet\EthernetClient.cpp.o
In file included from .pio\libdeps\esp8285\Ethernet\src\Dhcp.cpp:7:0:
.pio\libdeps\esp8285\Ethernet\src\utility/w5100.h:18:17: fatal error: SPI.h: No such file or directory

*************************************************************
* Looking for SPI.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SPI.h"
* Web  > https://platformio.org/lib/search?query=header:SPI.h
*
*************************************************************

 #include <SPI.h>
                 ^
compilation terminated.
In file included from .pio\libdeps\esp8285\Ethernet\src\Dns.cpp:8:0:
.pio\libdeps\esp8285\Ethernet\src\utility/w5100.h:18:17: fatal error: SPI.h: No such file or directory

*************************************************************
* Looking for SPI.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SPI.h"
* Web  > https://platformio.org/lib/search?query=header:SPI.h
*
*************************************************************

 #include <SPI.h>
                 ^
compilation terminated.
In file included from .pio\libdeps\esp8285\Ethernet\src\Ethernet.cpp:23:0:
.pio\libdeps\esp8285\Ethernet\src\utility/w5100.h:18:17: fatal error: SPI.h: No such file or directory

*************************************************************
* Looking for SPI.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SPI.h"
* Web  > https://platformio.org/lib/search?query=header:SPI.h
*
*************************************************************

 #include <SPI.h>
                 ^
compilation terminated.
*** [.pio\build\esp8285\lib0af\Ethernet\Dhcp.cpp.o] Error 1
*** [.pio\build\esp8285\lib0af\Ethernet\Dns.cpp.o] Error 1
*** [.pio\build\esp8285\lib0af\Ethernet\Ethernet.cpp.o] Error 1
In file included from .pio\libdeps\esp8285\Ethernet\src\EthernetClient.cpp:24:0:
.pio\libdeps\esp8285\Ethernet\src\utility/w5100.h:18:17: fatal error: SPI.h: No such file or directory

*************************************************************
* Looking for SPI.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SPI.h"
* Web  > https://platformio.org/lib/search?query=header:SPI.h
*
*************************************************************

 #include <SPI.h>
                 ^
compilation terminated.
*** [.pio\build\esp8285\lib0af\Ethernet\EthernetClient.cpp.o] Error 1
========================================================================= [FAILED] Took 8.29 seconds =========================================================================The terminal process "C:\Users\Micha\.platformio\penv\Scripts\pio.exe 'run'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

The Ethernet library is mentioned in the dependency graph, but why?

There is a dependency in library.json, but only for platform espressif32:

"dependencies": [
    {
      "owner": "me-no-dev",
      "name": "AsyncTCP",
      "version": "*",
      "platforms": ["espressif32"]
    },
    {
      "owner": "me-no-dev",
      "name": "ESPAsyncTCP",
      "version": "*",
      "platforms": ["espressif8266"]
    },
    {
      "name": "Ethernet",
      "url": "https://github.com/maxgerhardt/Ethernet.git",
      "platforms": ["espressif32"]
    }
  ],

Have you tried different lib_ldf_mode values?

In a workaround one can also specify lib_ignore = Ethernet.

None of the lib_ldf_mode alternatives did help, so I resorted to the lib_ignore workaround. Thank you for hinting me to it.

Nevertheless I would like to know where the dependency is coming from…

@bertmelis found another solution by changing the following in library.json:
grafik
Why that works yet slips my understanding.