This was previously discussed at Discord/IRC, but I want to discuss it here too.
Right now, SFML only offers targets like sfml-graphics, sfml-system and so on. What I want is to have something like SFML::Graphics, SFML::System and so on.
The advantage of these aliases is that if the target sfml-graphics is not found at configuration time, CMake simply will add -lsml-graphics and be done with it, If I misspell sfml-graphics, for example, by writing sfml-garphics, CMake will add -lsfml-garphics and I'll have an error at link time.
On the other hand, if I link to SFML::Graphics, I'll get error at configuration time if this target is not found.
The thing I want to discuss here is how these aliases should be named.
1) SFML::sfml-graphics
2) sfml::graphics
3) SFML::Graphics
4) sfml::sfml-graphics
In my opinion the second one looks the best, because it looks like "sfml-graphics". Plus, making "Graphics" from "graphics" string in CMake is not a trivial task... So, what do you think?
The common convention seems to be PascalCase, without repetition.
Examples:
JPEG::JPEG (libjpeg)PNG::PNG (libpng)OpenSSL::Crypto (OpenSSL)Qt5::Core (Qt)JsonCpp::JsonCppStatic (jsoncpp)Some deviate also in the component part:
Boost::filesystem (Boost)I would thus suggest SFML::Graphics.
See also: https://stackoverflow.com/q/48524359
If we want to be consistent with the call to find_package, it would be
find_package(SFML COMPONENTS graphics)
target_link_libraries(target PRIVATE SFML::graphics)
I assume find_package() uses lower-case because of historic reasons (the linked library is sfml-graphics)? On the other hand, the include directory is <SFML/Graphics.hpp> and not <SFML/graphics.hpp>.
If we already change this, it might be most user-friendly if modules were named consistently, not different in each context.
I think SFML::graphics will be consistent with sfml-graphics and sfml-graphics.so/dll. And I don't think that it's fair to compare it to header naming, it should be compared to library naming. And either we rename the produced library (highly doubt it), or we go with SFML::graphics, which seems ok to me.
Remembered about this issue, and here's more thoughts. I think I'll go with "SFML::graphics", because now we have target's named like "sfml-graphics" and it'll be just pretty hard to make sfml_add_library convert first letter of module to uppercase.
With "sfml-graphics", we'll be able to just remove "sfml-" part and prepent "SFML::". The thing that bothers me, though, is that all names passed to sfml_add_library macro will need to start with sfml-.
Note that the :: part is one you're supposed to add in the NAMESPACE argument of install(EXPORT NAMESPACE SFML::) (see install for more information) parameter, not directly in the target name or alias. That's how CMake automatically detect imported targets when creating configuration packages along with the appropriate modules.
Any movement on this? Anyone have a fork to be tested maybe?
Most helpful comment
If we want to be consistent with the call to find_package, it would be