Butter a 2-quart (2l) gratin or baking dish. Bring a large pot of lightly salted water to a boil. Add the potatoes and cook the potatoes at a low boil until a paring knife inserted into the center meets no resistance, about 12 to 15 minutes. You want them fully cooked through but avoid overcooking them. Drain the potatoes and set aside.
Preheat the oven to 425ºF (220ºC). Put the bacon pieces in a cold skillet. Bring the heat up to medium-high and cook, stirring frequently, until the bacon pieces are almost crisp. (If necessary, add a bit of olive oil if your bacon doesn't have quite enough fat to keep it from sticking.) Drain the bacon onto a paper towel-covered plate.
Remove most of the bacon fat from the pan, leaving a few teaspoons remaining for frying the onion. Add the onion and garlic to the pan and cook, stirring frequently, until the onions are completely cooked and translucent, about 5 to 7 minutes. Turn off the heat and add the wine or vermouth to deglaze the pan, scraping the bottom of the pan to release any browned bits.
Slice the potatoes and 1/2 - 3/4-inch (1,5-2cm) slices and lay half of them in a single layer in the baking dish. Season very lightly with salt (the cheese and bacon will add a fair amount of salt) and freshly ground black pepper. Strew half of the onion mixture over the potatoes and half of the bacon.
Arrange the remaining half of the potatoes in a single layer in the baking dish, season with salt and pepper, then finish with the remaining onions and bacon. Dribble the cream over the top, then cover with the slices of cheese in a single layer. Bake on the middle rack of the oven until the cheese is melted and starting to brown, about 30 minutes. Serve hot.