I've started doing the changes to support config file generation. At the moment this is working at least for me on macOS with frameworks. I expect it to work on other platforms too because it reuses the definitions of current SFML targets. This implies a LOT of changes though so I would like your feedback before going on.
The current diff:
https://github.com/SFML/SFML/compare/master...Ceylo:feature/CMakeTargetExportEspecially I have replaced all the listing of dependencies with calls to target_link_libraries() and target_include_directories() for 3 reasons:
- this avoids redoing what CMake already does (target_link_libraries() and target_include_directories() already handle lists)
- this makes it easier to group the full setup (include+link) of each dependency
- this will allow specifying which dependencies must be public in case of static linking (what SFML_DEPENDENCIES currently does in FindSFML.cmake), same eventually if compile definitions or include dirs must be exported (currently only the root include dir of SFML is exported)
In terms of usage right now (example from sfeMovie):
find_package (SFML 2.3 COMPONENTS graphics window system audio REQUIRED)
target_link_libraries(sfeMovie PRIVATE sfml-graphics sfml-window sfml-system sfml-audio)
I didn't expose yet the fact that sfml-graphics depends on sfml-window and sfml-system. Could be done and would allow writing only
target_link_libraries(sfeMovie PRIVATE sfml-graphics sfml-audio)
Dunno yet if we want that though.
PS: does your CI allow testing branches before the PR is open? This way I can quickly see whether I broke something on other platforms.