If present and true, this will cause all libraries to be built shared unless the library was explicitly added as a static library.
I propose to not set BUILD_SHARED_LIBS to "OFF"You mean to not set to "ON" or to set to "OFF", right?
I expect that static libs are built by defaultCMake builds shared libs by default (if nothing is explicitly specified), so why would you expect static libs?
CMake builds shared libs by default (if nothing is explicitly specified), so why would you expect static libs?
Plus as mentioned, it's also the CMake default and what is normally expected.This is not a CMake's default. BUILD_SHARED_LIBS should be manually defined and set to ON so that CMake builds a shared library instead of static one. E.g. this will produce static library:
This is not a CMake's default. BUILD_SHARED_LIBS should be manually defined and set to ON so that CMake builds a shared library instead of static one.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.
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.
When you say, SFML's CMake sets it to ON, do you mean implicitly by using the SHARED keyword? Because there's no explicit setting of the mentioned variable.No, I mean this line (https://github.com/SFML/SFML/blob/252d26afb0aa6375e08ef95b754cccf60f31b6df/CMakeLists.txt#L57).