I'm about to embark on a similar project...having bought a road bike I don't need and having a flat bar bike that is quite right for me!
You will need, the flat bar and grips, bar ends if you want them, brake levers, trigger shifters compatible with your front and rear mechanisms, new brake and gear cables
To give you an idea of cost of that lot (excluding any required labour), I've spent so far
Bars: £20
Compatible SRAM brakes and trigger shifters:£60
Cables: £20
Workstand:£45
I have some grips already, but they'd be another £20 odd for ergo ones
You might be able to claw some cash back by selling the bars and brifters from the cx
What specific bike do you have? Assume you've tried the usual tricks of checking stem length, flipping stem, confirming bar width. If it's got shimano sora front and back for example I'm sure you can get compatible shifters. Do some googling to find a flat bar with the same mechs and buy the shifters they have used
Here are my ramblings on the matter so far
https://www.cyclechat.net/threads/road-bike-to-flat-bar.181764/
I guess your issue might be that if the cube has the wrong geometry, you could spend all the money and time converting and it still may not be right for you