How to find out if Arduino framework is used using the preprocessor (PlatformIO)

You can use How to print all preprocessor flags in PlatformIO to print preprocessor flags. Note that these include the flags #defined in #includes such as Arduino.h. You can remove everything from main.cpp, however, so only the flags defined by the build environment are visible.

The Arduino-related flags are

#define ARDUINO_VARIANT "esp32"
#define ARDUINO_ARCH_ESP32 1
#define ARDUINO_PARTITION_default 1
#define ARDUINO 10812
#define ARDUINO_ESP32_DEV 1
#define ARDUINO_BOARD "Espressif ESP32 Dev Module"

So if you want a platform-independent check for Arduino, use

#ifdef ARDUINO
  // Arduino code goes here
#else
  // Non-Arduino code goes here
#else