The president also thanked Italian and North Atlantic Treaty Organisation allies for joining the fight against the Islamic State of Iraq and Syria (ISIS) and eradicating terrorism.
Trudeau and Trump also met for an informal chat on the sidelines of the summit. Macron won the French presidency on May 7.
Trump also said he leaves amid new hope among nations on "eradicating the terrorism that plagues humanity".
Trump, who has previously called global warming a hoax, tweeted that he would make a decision next week on whether to back the 2015 Paris Agreement on curbing carbon emissions following lengthy discussions with G7 partners.
However, there was relief that Trump agreed to language in the final G7 communique that pledged to fight protectionism and commits to a rules-based global trade system.
Cohn told reporters: "They understand where we are, we understand where they are and it's most important that we continue to work together".
This is Mr Trump's first G7 summit - during his first foreign trip.
Gentiloni says: "Discussing is always useful".
He notes that the American people chose Trump and adds, "so we are coming to terms with this choice".
Trump's predecessor, Barack Obama, negotiated the deal and agreed reduce the country's emissions by between 26 and 28 percent by 2025 compared to 2005 levels. "Meeting the Paris Agreement's temperature limitation goals is in the environmental, economic and national security interests of the United States, whereas President Trump's "climate inaction plan" is a threat to every American's health and future prosperity". This will put him in an opposing role against the climate change pledge.
"There have been differences, to be sure, in some past summits, but not a sharp open split like this", he said.More news: Arsene Wenger says his future at Arsenal will be decided by Thursday
More news: Microsoft says after WannaCry attack governments should end 'hoarding' security vulnerabilities
More news: Trump hands Putin a win at first North Atlantic Treaty Organisation meeting
Yet the six other leaders in the communique reaffirmed their "strong commitment to swiftly implement the Paris Agreement". "Look, as you know from the USA, there's very strong views on both sides". Differences over trade and Russian Federation have also arisen in talks. She said the G7 member states clearly articulated that they would reject protectionism in trade policies.
However, a diplomat told Reuters that other Italian proposals - which looked to highlight the benefits of migration and promote a major initiative on food security - were dismissed ahead of the summit.
The rift is one of several emerging disagreements between Trump and other world leaders.
"The whole discussion on the topic of climate was very hard, not to say very unsatisfactory", she told reporters, labelling the G7 deadlock as "six against one".
But after the pomp of presidential travel overseas, Trump will return to Washington to find the same problems that have dogged him.
The president tweeted on Saturday: "I will make my final decision on the Paris Accord next week!"
Leaders from the G-7 countries were expected to gather at the San Domenico Palace Hotel on Saturday morning.
"The world will not stand idly by whilst Donald Trump takes a wrecking ball to global efforts to prevent catastrophic climate change - one of the biggest challenges the world faces".
"I am so proud of the future you are going to have", he said.
On the campaign trail, Trump said he would "cancel" the Paris deal.
They restored a vow to fight protectionism - the use of import taxes and skewed regulations that favor domestic producers over their foreign competitors.