Siemens agreed to buy U.S.-based Mentor Graphics in a $4.5 billion all-cash deal that will further build the German engineering group’s software capabilities.

Siemens said on Monday it would pay $37.25 per share for Mentor ment —which makes software for designing semiconductors—a 21% premium to Friday’s closing share price.

The acquisition will help Siemens smawf expand its software capabilities, which it has been shoring up in recent years. It bought CD-adapco, a privately held U.S. engineering software firm, earlier this year.

Since taking over Siemens as chief executive, former finance chief Joe Kaeser has set out to reshape the German company and make it more profitable and less cumbersome by selling off non-core units.

It said last week that it planned a public listing of its $15 billion healthcare business, lifting its shares to a 16-year high as investors hoped for an injection of capital that would boost its valuation while funding future investments.

But Siemens has increasingly had to compete with software companies who can develop technology faster because they have a sole focus. Only 5% of Siemens’ 350,000 employees are software engineers. As part of its “Vision 2020” strategy, it has identified software as a growth area for the company.

 

The sale of Mentor Graphics, based in Wilsonville, Ore., and run by Chief Executive Wally Rhines, will cap off a long road for a company that has been no stranger to activist investors or takeover offers over the years.

Billionaire activist Carl Icahn won a proxy fight in 2011 that secured him three board seats, although he exited his investment in the company in April after six years.

Mentor also fended off a hostile takeover by rival Cadence Design Systems cdns in 2008.

Mentor Graphics has been under pressure since activist hedge fund Elliott Management reported an 8.1% stake in the company in September and said its shares were deeply undervalued. Elliott could not be reached for comment Sunday.

Reuters reported last month that Mentor Graphics was working with Bank of America bac to explore strategic alternatives, including a sale.

Siemens expects the acquisition of Mentor to add to its earnings within three years and result in savings that will lift earnings before interest and tax (EBIT) by more than 100 million euros ($108 million) within four years.

People familiar with the matter had flagged the planned deal to Reuters, saying Siemens would pay $4.5 billion to $4.6 billion for Mentor.

Deutsche Bank db and J.P. Morgan jpm advised Siemens on the transaction.