Search for MSSM and NMSSM Higgs bosons with the CMS detector