Washington (CNN) President Donald Trump's decision to visit France on its national day next month at the invitation of new President Emmanuel Macron represents a shrewd political calculation by both leaders.

Trump announced Wednesday that he would be in Paris on Bastille Day, July 14, for a day of pageantry at an event that will mark 100 years since the US entry into World War I.

The US President, on his second trip to Europe in two weeks -- he heads to Germany for the G20 summit and Poland next week -- will bask in the pomp of his official role as commander-in-chief at a time when he is under political siege at home.

"The two leaders will further build on the strong counter-terrorism cooperation and economic partnership between the two countries, and they will discuss many other issues of mutual concern," the White House said in a statement on Wednesday.

The trip -- to visit a leader who actually wants him to come -- will be a chance for the President to counter a growing narrative about his unpopularity abroad. A Pew Research poll released Tuesday found deep disdain for Trump's manner and "America First" foreign policy. In France for instance, only 14% of those surveyed had confidence that Trump would do the right thing in global affairs, compared to 84% of people who said the same thing for former President Barack Obama.

Macron, who was elected in May and won a broad mandate for his brand of outsider politics in parliamentary elections earlier this month, will use the visit to signal that despite his deep differences with Trump on issues like global warming, he is determined to maintain the alliance between the US and France, which has endured for more than two centuries.

"Macron is not inviting Donald Trump, he is inviting the President of the United States," said Nicholas Dungan, a former president of the French American Foundation, who teaches at Sciences Po, a prestigious French research university.

JUST WATCHED France reacts to US climate deal withdrawal Replay More Videos ... MUST WATCH France reacts to US climate deal withdrawal 02:02

Macron 's decision to treat Trump to full bore French pageantry on a day that includes a military parade along the Champs-Elysee that will feature US soldiers and a spectacular fireworks display at the Eiffel Tower, will likely please the US President, and may be an attempt to play into an increasing trend of global leaders seeking to flatter a leader who has a highly developed sense of his own image.

Macron's surprise invitation , delivered in a phone call with Trump on Tuesday, may also represent an attempt to get off on a better foot with the US leader, after Macron's comment that their long white knuckle handshake when they first met on the sidelines of the NATO summit in Brussels last month was a deliberate attempt to show that he was not intimidated by the US leader.

The visit will also further Macron's clear attempt to establish himself in the top rank of world leaders, despite his inexperience and relative youth. The French President is 30 years younger than his American counterpart.

Macron recently flattered Russian President Vladimir Putin at the French royal palace at Versailles but also put on a bravura performance, speaking directly about alleged Russian meddling in the French election and the "lying propaganda" of Russian state media networks.

The French President has positioned himself as a bastion of liberal global values, and rebuked Trump in a remarkable video address to the American people after the US leader withdrew from the Paris climate accord.

"Tonight I wish to tell the United States, France believes in you. The world believes in you. I know that you are a great nation," Macron said in the video against a backdrop of the French tricolor and the flag of the European Union.

"I know your history, our common history," he said, calling on scientists, engineers and "responsible citizens" disappointed by Trump's decision to find a "second homeland" in France to work together on concrete solutions to climate change, and co-opted Trump's campaign theme in a swipe at the President by saying he wanted to "make the planet great again."

The trip to Paris also represents an about turn for Trump, who has sometimes denigrated the French capital and French government's policies on Muslim immigration following a series of terror attacks.

"A friend of mine, he said he was going to France like three or four months ago. I saw him yesterday. I said, how did you like France? He said, 'I wouldn't go to France. I wouldn't go to France because France is no longer France,'" Trump said in Florida at a campaign event last July.

"France is no longer France. They won't like me for saying that but ... France is no longer France and this world better be very careful and they better get very tough and very smart," Trump said.

Macron was endorsed by Obama ahead of his election win and may be making an attempt to fill the global leadership vacuum that many allies perceive was left by the US decision to walk away from global efforts to combat climate change and Trump's oft voiced skepticism towards NATO.

His victory over far right leader Marine Le Pen in May represented a triumph over the wave of populism that has been sweeping democracies and helped elect Trump and has already elevated him to the top tier of Western leadership, alongside German Chancellor Angela Merkel.

A source who spoke with Trump after the G7 summit told CNN's Kevin Liptak that the President was annoyed after sitting through lectures from leaders including Macron and Merkel about the Paris accord during his previous visit to Europe.

This visit is also a demonstration of how a foreign leader in a strong political position has an advantage in dealing with Trump and can play less heed to his unpopularity. Reports out of the United Kingdom this month said that Trump had delayed a state visit at the invitation of Queen Elizabeth II because of fears of mass protests if he arrived in London. The White House denied the report.