A static library gets generated implicitly when TARGET_SUPPORTS_SHARED_LIBS is false
On platforms that do not support dynamic linking, if a shared library is created CMake will currently fall back implicitly to creating a STATIC library instead. This happens here: https://gitlab.kitware.com/cmake/cmake/-/blob/master/Source/cmAddLibraryCommand.cxx?ref_type=heads#L236
This is confusing: instead, I believe CMake should print the warning but leave the target type alone. Changing the target type can lead to other failures down the line that are simply more confusing and at the end of the day, changing the library type to STATIC is unlikely to be what the user wants. The user most likely wants a failure so they can fix their code.
This was encountered in the process of refactoring libc++'s CMake configuration. We basically define targets for both the shared and the static libraries, but users may decide to build and install only one of those if they desire. On embedded platforms that don't support dynamic linking, this fails because while the users wouldn't be building and installing the unsupported shared library, they still get a definition since we define the static library twice (once via the normal definition of the static variant of the library, and once via the shared library being implicitly changed to a static library).