cmake: increase template depth if necessary