How to add a custom component to the build system?

I have a custom STM32L496VG board with a micro SD card slot connected to the MCU via the 4-bit SDIO interface.

I have ported JojoS62’s COMPONENT_SDIO driver to use the micro SD card.

Everything works fine if I place the COMPONENT_SDIO files(SDIOBlockDevice.cpp, SDIOBlockDevice.h, ported sdio_device.c and sdio_device.h) directly into the custom target folder.

I prefer to retain the COMPONENT_SDIO directory structure and let Mbed Studio’s build system to pick the correct driver files for me. But then the build system failed to locate the SDIOBlockDevice.h in the COMPONENT_SDIO/drivers folder. I wrote a CMakeLists.txt in the COMPONENT_SDIO folder and it has no effect.

How can I integrate the custom component into the build system like the built-in components such as COMPONENT_SPIF and COMPONENT_SD?