Why the release if no debug is found? I think when the user explicitly writes "DEBUG" he also wants the debug libraries, giving him the release ones is likely to raise errors at link, load or run time. The same applies to the RELEASE equivalent
On Linux for example, you'll have only the release libraries installed, so you'll use them in debug mode (which is perfectly fine, unlike on Windows).
Hm... Is that often used? Doesn't the user want to know whether the library of the desired configuration is found (since sfml-window-d helps nothing for a release application)? See also the last one of the points below.
It's consistent with the rules that define the _DEBUG and _RELEASE variables, it's used when you don't care about which variant(s) of the SFML libraries are installed, as long as you've got at least one.
The others look okay. What about the following (with analogue DEBUG variables)?
- SFML_LIBRARIES_RELEASE as a list of SFML_XXX_LIBRARY_RELEASE (possibly empty), with the "optimized" keyword.
- SFML_RELEASE_FOUND maybe. But if there is an easy way to check whether SFML_LIBRARIES_RELEASE is empty, there is no need for that.
- SFML_XXX_RELEASE_FOUND maybe if the XXX component in release configuration is found.
Well, my point is: can you really check for the DEBUG libraries?
If you distribute your sources you can't require that developers compile in debug mode, or link to debug libraries in debug mode. Linking to release libraries in debug mode is an error on Windows with most compilers, but on other systems the default behaviour is often to have and use only the release libraries. It's even worse on Linux: there are no debug libraries, only debug symbols that live in a separate file.
If you explicitely handle the DEBUG libraries in your CMakeLists.txt file I think you'll make a lot of developers unhappy.
That's why I thought that Qt's strategy (using the library that is available if not both are there) is a good one.
And concerning the multi-configuration generators, I really can't believe this is the default approach to link a library in a portable way. What is a SFML user supposed to type in his CMake file to achieve this? In my opinion, it is important to keep the user code as simple as possible. Is there a fundamental CMake mechanism I've overlooked?
What are you talking about? Using the new rules I described, users would only have to link to ${SFML_LIBRARIES}.
For multi-configurations generators, the right libraries will be chosen for each config thanks to the "optimized" and "debug" flags, and for single-configuration generators... it's the same actually, CMake will pick the right one according to these flags.