The 22-year-old striker will officially join the Bluebirds on July 1st after his contract at Manchester United expires.
The striker rose to prominence at Old Trafford as a teenager, coming off the bench to score the winner against Aston Villa in 2009.
However, Macheda struggled to establish himself as a regular at Old Trafford and has subsequently enjoyed loan spells at Sampdoria, QPR, Stuttgart and Doncaster.
Macheda spent the majority of last season on loan at Birmingham City, scoring 13 goals in 33 Championship appearances.
The striker will now stay in the second tier with Ole Gunnar Solskjaer’s side but says he is confident Cardiff can return to the Prmeier League quickly.
“It’s a massive opportunity for me and it is with thanks to Ole Gunnar Solskjær that I am here,” he told the club’s official website.
“I’m really looking forward to starting this season. This is a new chapter of my career and I can’t wait to get going.
“Knowing Ole, he wants to get back into the Premier League as soon as possible and the recent signings show that.
“I’m here for the same reason, I feel this is a great team. If we can have a good year and work hard, we can go straight back up.”