add_library: Reject shared libraries on platforms that do not support them

Add policy CMP0164 to provide compatibility.

Fixes: #25759
13 files changed