I use folders to put the dependent header/source files as this example shows
fs/filesystem.hpp <-- main generic header that is what you include in any project and you can create a #define in there to ensure that a person only includes this one and if they include a sub one below, it will give a compile error pointing to this file as the one to include.
fs/linux/filesystem.hpp <-- header for linux #included with #ifdef LINUX in main file above
fs/windows/filesystem.hpp <-- header for windows #included with #ifdef WINDOWS in main file above
fs/linux/filesystem.cpp <-- implementation for linux
fs/windows/filesystem.cpp <-- implementation for windows
Then in my build system it's easy to use the "$target" to include the relevant source files per os for the build.
The trick is to create a interface that you can typedef and hide from the user so that they only see this and not the implementation details
I personally hate source files littered with multiple OS #ifdefs throughout class definitions, types, headers, etc. and I prefer to fragment everything for the sake of clarity and ease of reading.