That’s why a new tool was created: [ANNOUNCE] stm32bridge: migrate STM32CubeMX → PlatformIO in one command (no GPDSC)
Why? The PlatformIO documentation is very clear on its source code folder layout and configuration possibilities. (docs, docs). If you want source code to be built, it has to be in the src_dir (by default src/) or in a library in lib/, or referenced by lib_deps.
Carefully set up your project with either framework = stm32cube (meaning, PlatformIO will use its version of the STM32Cube CMSIS Startup File, Header, STM32HAL source and headers, linker script) or no framework (meaning you have to provide all those files yourself), along with the same compiler options that your stm32 project does, like clock configuration settings.