Fix cmake missing target issue of templates.