Heavy flavor physics with CMS