Preheat the oven to 180°C (350°F), or 170°C (340°F) for a fan oven. Line a 20 cm square tin with baking paper.
For the base, beat the butter, sugar, vanilla and almond extract until pale and fluffy, about 3 minutes.
Add the flour and mix briefly until the dough forms soft crumbs that clump together when pressed.
Press the crumbs evenly into the tin and smooth the surface with the back of a spatula.
For the frangipane, use the same bowl. Cream the butter, sugar, vanilla and almond extract until pale. Beat in the eggs one at a time until smooth.
Mix in the ground almonds and flour until just combined.
Pat the cherry halves dry on kitchen paper, then fold them gently through the frangipane.
Spread the cherry frangipane over the base and scatter the flaked almonds on top.
Bake for 43 to 45 minutes, until golden and the centre feels set. Cover loosely with foil if the top browns too quickly.
Cool completely in the tin, dust with icing sugar and cut into 9 squares.