Mayor de Blasio just got a blaring wake-up call from the West Coast about his lawsuit against Big Oil: Get set to be laughed straight out of court, Mr. Mayor.

That was the message behind US District Court Judge William Alsup’s decision last week to toss out lawsuits by San Francisco and Oakland against five of the world’s largest oil companies. The suits sought reimbursement for the cost of repairs to city infrastructure necessitated by global warming.

Alsup’s reasoning was spot-on: Courts are no place to decide how to deal with climate change.

“The dangers raised in the complaints are very real,” he wrote. “But those dangers are worldwide. Their causes are worldwide. The benefits of fossil fuels are worldwide.”

The problem, he added, “deserves a solution on a more vast scale than can be supplied by a district judge or jury in a public nuisance case.”

Alsup also rightly cited his obligation to “defer to the other co-equal branches of government when the problem at hand clearly deserves a solution best addressed by those branches.”

And he warned, too, against scapegoating the oil companies: “Would it really be fair to now ignore our own responsibility in the use of fossil fuels and place the blame for global warming on those who supplied what we demanded?”

That logic may soon demolish de Blasio’s similarly wacky suit against Big Oil for “causing” Superstorm Sandy. After all, City Hall itself still uses oil to run its police cars, firetrucks and other vehicles and for other things — even though it presumably knows the damage that causes.

At a hearing this month on the mayor’s case, US District Court Judge John Keenan made that precise point, as he gestured to cop cars and firetrucks outside the courthouse.

“Does the city have clean hands?” Keenan asked rhetorically.

De Blasio must know his suit is a long shot at best. No matter: His main goal has been to score political points with progressives and burnish his national bona fides as an anti-fossil-fuel crusader. And, hey — if he does win some cash for the city in the process, all the better.

Consider, too, how the lame-duck mayor’s campaign against Big Oil fits nicely with his other profile-boosting bids: his similar lawsuit against Big Pharma for “creating” the opioid epidemic, for example, or his recent trip to the Mexican border to protest family separation.

New Yorkers can scratch their heads over these moves and bemoan the waste of (their) money being spent on them. When his efforts fail, though, de Blasio’s self-promotion may backfire. And taxpayers can have the last laugh.