[CMake] Cherry-pick upstream BUILD_SHARED_LIBS fix
[CMake] Cherry-pick upstream BUILD_SHARED_LIBS fix

apple/swift-lldb,apple/swift-lldb,apple/swift-lldb,apple/swift-lldb,apple/swift-lldb,apple/swift-lldb