My bad, I didn't check. I always create shared libs, whether it is at home or at work. Adding SHARED to add_library has probably become automatic for me, so that I don't notice it anymore.
You don't actually need to do this - if BUILD_SHARED_LIBS is set to ON, the libraries will compile as shared ones. But if you explicitly do add_library(some_lib SHARED) then it can only be compiled as a shared library and never as a static one.
I really wonder why STATIC is the default on CMake.
Maybe it comes from Windows projects where shared linking is kinda painful, because you need to do all this dllimport/dllexport stuff + copying of dll's to the executable's directory.
What's wrong about having to turn this flag off?
It's just a bit surprising, because I don't expect something to build as shared lib by default, because I don't set BUILD_SHARED_LIBS, but the library does it for me.
Also it forces programs which use SFML to explicitly set
BUILD_SHARED_LIBS to some value so that when you call
add_subdirectory(SFML), SFML will respect that. Otherwise your program will link everything statically, but SFML will set
BUILD_SHARED_LIBS flag and set it to "ON" for itself anyway and build itself as a shared lib, even though the parent application didn't tell it to build as a shared lib.
But yeah, I guess I'll just have to say people to explicitly set
BUILD_SHARED_LIBS before calling
add_subdirectory(SFML) if they want the flag to work right globally.