I’m looking for a good way to select when platform specific source files should be included in the build. If I for example have “foo_linux.cpp” and “foo_windows.cpp”, I would like to select the appropriate version with as little extra work as possible. Currently I have if() statements in my CMakeLists.txt calling target_sources() differently depending on platform.
But I was hoping to be able to have files more or less automatically selected based for example on filename suffixes (as in my example names above).
Is there some “best practice” in this area with CMake?
Regards,
Johan Holmberg