President Theodore Roosevelt, behind table, at the U.S. Naval Academy graduation in 1902. He returned in 1905. (AP)

A foot of snow had piled up on the brick sidewalks of Annapolis when President Theodore Roosevelt arrived by train in 1905 to speak to 114 graduates of the U.S. Naval Academy.

The midshipmen were graduating in January instead of the spring, according to a Washington Post report, to man the warships their commander in chief was building. Roosevelt, a former Navy secretary and Spanish-American War hero, gave an aggressively militant speech, urging the young naval officers to advance American glory and “make our attitude in claiming to be a great nation respectable.”

Presidents have been coming to Annapolis — a city that once briefly served as the U.S. capital — to lay out their vision of American military power ever since Ulysses S. Grant handed out diplomas to the academy’s graduates in 1869.

On Friday, Donald Trump became the 19th president to take part in a ritual filled with symbolism and rhetorical significance. Blue Angels streaked over the Navy-Marine Corps Stadium, and hundreds of giddy graduates threw their caps in the air.

The Blue Angels fly over the graduating Class of 2018 at the U.S. Naval Academy in Annapolis Friday. (Photo by Michael Robinson Chavez/The Washington Post)

Trump, who just canceled a highly anticipated summit with North Korea, told the graduates that they were becoming officers at an ideal moment.

“In case you haven’t noticed, we have become a lot stronger lately,” he declared. “A lot.”

“We are witnessing the great reawakening of the American spirit and American might. . . . Yes, they’re respecting us again. Yes, America is back. . . . Victory, winning — beautiful words. But that’s what it’s all about.”

His appearance thrilled some midshipmen and dismayed others. Earlier this week, a Naval Academy political science professor published a piece in The Washington Post about the “startling emails” he received from several students.

One message said: “We are under no obligation to clap for Donald Trump. Trump wants the image of young service members cheering him on and we can deny him that image.” Another proposed an online petition on social media, pledging not to applaud Trump at commissioning. There were four more with similar themes: “We are taught selflessness; he practices narcissism.” “If he is a role model, it is only in the exact opposite.”

But Trump, who went to high school at the New York Military Academy and has proposed a Bastille-style military parade in Washington on Veterans Day, reveled in the pomp and ceremony of a Naval Academy graduation.

In the 20th century, only a handful of presidents, including William McKinley, Herbert Hoover, Harry Truman, Lyndon B. Johnson and Gerald Ford, have failed to seize the Naval Academy’s lectern, The Post has reported. Franklin D. Roosevelt spoke twice, in 1933 and 1938. So did Bill Clinton, in 1994 and 1998, and Barack Obama in 2009 and 2013.

With President Franklin D. Roosevelt smiling broadly from the podium, the 435 graduates of the Naval Academy toss their white caps into the air on June 2, 1938. (AP Photo/WRW)

George W. Bush delivered two very different speeches. The first was on May 25, 2001, just four months before the Sept. 11 terrorist attacks. Bush compared the Class of 2001 to the Class of 1951, who graduated at the height of the Cold War.

“Today, you inherit a world that is safer and more peaceful, a world the class of ’51 helped to make possible,” the president said. “You’re the custodians of their legacy, the next link in the long, unbroken chain that is Annapolis past and present. The world you’re entering today is different from the one they entered in five decades ago. But it’s still dangerous. It still requires America to have a forward strategy for freedom.”

When Bush returned to the Naval Academy in 2005, the nation was at war in both Afghanistan and Iraq.

President George W. Bush preparing to speak at the U.S. Naval Academy in 2005 in Annapolis. (Alex Wong/Getty Images)

“When I spoke to the class of 2001, none of us imagined that a few months later we would suffer a devastating surprise attack on our homeland or that our nation would be plunged into a global war unlike any we had known before,” Bush said.

“Today, we face brutal and determined enemies, men who celebrate murder, incite suicide, and thirst for absolute power. These enemies will not be stopped by negotiations or concessions or appeals to reason. In this war, there is only one option, and that is victory.”

Many presidents find speaking at the Naval Academy, the U.S. Military Academy, the U.S. Air Force Academy and the U.S. Coast Guard Academy irresistible.

Theodore Roosevelt, who liked to “speak softly and carry a big stick,” wanted the country to flex its muscles on the world stage. Nine years later, in 1914, Woodrow Wilson delivered an idealistic speech almost opposite in tenor, proclaiming the benefits of peace and warning against militarism. He was to be disappointed: World War I broke out only a few months after he gave his speech.

After World War II, the tone of the speeches changed again, with presidents urging a new kind of military leader.

Dwight D. Eisenhower, a West Point graduate who had presided over Allied military forces in Europe, saw in each new commissioned officer a “crusader for peace.”

Jerome F. Smith Jr. receives congratulations from President John F. Kennedy at the U.S. Naval Academy commencement ceremonies on June 7, 1961. (AP)

John F. Kennedy refined that vision, advocating that midshipmen not only be taught “strategy, tactics, logic and logistics, but also economics, politics and diplomacy and history.”

The nation’s battle against communism dominated much of the rhetoric in the 1970s and 1980s. In 1974, Richard Nixon outlined the diplomatic achievements of his administration, which had finally extracted the country from Vietnam.

In 1978, Jimmy Carter stressed the importance of friendship with the Soviet Union. Seven years later, Ronald Reagan did an about face, promising to strengthen the military and proclaiming the United States “a far more moral and decent land than any totalitarian state.”

Regardless of which president is speaking, the midshipmen are often too busy celebrating their survival of four grueling years at the Naval Academy to pay much attention.

Sen. John McCain (R-Ariz.), who graduated from the Naval Academy in 1958, once said he couldn’t remember Eisenhower’s commencement speech to his class. But in a Post interview 17 years ago, he did recall the president seeking out the “anchor man” — the midshipman who finished last in his class — and shaking his hand. For McCain, who finished fifth from the bottom, it was a lost opportunity.

“I would have tried a little harder to finish last if I had known that would happen,” McCain said.

Only one president understood how distracted his listeners would be: Jimmy Carter, who graduated from the Naval Academy in 1948 and returned to Annapolis as commander in chief in 1978.

“We had a good speaker, Chester Nimitz,” the legendary admiral who led the Pacific fleet to victory over Japan in World War II, Carter told the midshipmen. “As will be the case with you, I don’t remember a word he said.”

Read more Retropolis:

Thousands of Japanese fought in a bloody World War II battle for the Aleutians. Only 28 survived.

Gen. George Patton’s wife put a Hawaiian curse on his ex-mistress. She was dead within days.

Six Nazi spies were executed in D.C. White supremacists gave them a memorial — on federal land.

At Korean summit in DMZ, ‘deranged’ ax murders still cast a shadow

The savage fight for Guadalcanal: Jungle, crocodiles and snipers during World War II