Gerrit Cole missed a chance to be a Yankee out of high school when he decided to attend UCLA rather than sign with the club that selected him in the first round of the 2008 draft.

Now, the right-hander whom the Pirates took with the first pick in the 2011 draft and gave an $8 million signing bonus can’t halt a trade from Pittsburgh to the Bronx that is inching closer to happening.

According to a person with knowledge of the talks, the Yankees and Pirates will get “a deal done’’ that will drop Cole into the Bronx without sacrificing stud prospects Gleyber Torres and Estevan Florial.

“When you bring up those two names to the Yankees, the talks stop,’’ said an official with a team other than the Pirates that has been engaged with the Yankees.

The Pirates have an interest in outfielder Clint Frazier, third baseman Miguel Andujar and right-hander Chance Adams. It’s doubtful the Yankees would give up all three for Cole, but it’s also possible the deal could be expanded to include Pittsburgh’s versatile Josh Harrison, who can play second, third, left field and shortstop in a pinch. The Yankees have openings at second and third after dealing Starlin Castro to the Marlins, and Chase Headley to the Padres, and they haven’t brought back free agent Todd Frazier.

Clint Frazier, 23, appeared in 39 big league games last year (.231; four homers; 17 RBIs) but turned into a sixth outfielder/Triple-A player when Giancarlo Stanton was acquired from the Marlins.

Andujar, who turns 23 in March, has been mentioned as a possible replacement for Headley and Todd Frazier at third. He batted a combined .315 with a .850 OPS, 16 homers and 82 RBIs in 125 games for Double-A Trenton and Triple-A Scranton/Wilkes-Barre. He impressed by going 3-for-4 with four RBIs in a one-game call-up on June 28 in Chicago. He played in five big-league games last season.

Adams, whom some regard as a reliever, is a 23-year-old right-hander who was 15-5 with a 2.45 ERA in 27 starts for Trenton and SWB.

Earlier this week, The Post reported the Yankees and Astros were the teams most likely to land Cole, who is scheduled for his second trip through the arbitration process after making $3.75 million last year.

The 27-year-old Cole, 12-12 with a 4.26 ERA in 33 starts last season, isn’t an ace, but his 203 innings a year ago would have led the Yankees staff that was topped by Severino’s 193¹/₃ innings.

Cole isn’t eligible for free agency until after the 2019 season. He gave up 31 homers in 33 starts last year, which could be a drawback if he has to work half the games in hitter-friendly Yankee Stadium. Nevertheless, in the previous four years, Cole allowed 36 homers in 94 games.