What was the non-GAAP operating margin for Sanmina in the first quarter of 2021 
gs are expanding. As you say, growing. Automotive, starting to see a nice improvement in demand. For communication networks, which includes networking, IP routing and advance optical systems, we see stable demand. We see some typical seasonality, but overall it's a fair demand. For mobile 5G network, short-term, we've seen improvements and long-term, we've seen a good growth. For cloud computing, for us that's a high-end computing and storage, we're starting to see some positive improvements and some seasonality impact. For second quarter, there are still some uncertainties around COVID and supply chain constraints, mainly with semiconductor components.
Please turn to slide 16. Let me make few more comments about business environment for the rest of the fiscal year 2021. We are focused on unlocking the total value by maximizing operating leverage in each of our business groups. Sanmina strategy is to build businesses around customer needs, delivering right value add and delivering competitive advantage to our customers, and expanding into more profitable projects in our focus key markets. As Kurt mentioned, we delivered for the second consecutive quarter, operating margin around 5%. We will continue to make progress and believe there is still room for improvement, and goal is to continue to drive efficiencies and a better mix. Today, I can say that management feels more comfortable that we can deliver to our long-term operating margin target of 5% to 6% in the future. And most important is that Sanmina has a strong customer base to build on for a better future. Based on present visibility, customers' forecasts and pipeline of growth opportunities, we feel positive about the rest of the calendar year 2021. The goal for us is to deliver solid results for fiscal year 2021.
Let me give you few more comments on management priorities. We'll continue to provide industry-leading end-to-end solution with the key technology components and products for key markets and our strategic customers. Managers will continue to build strong customer partnership, that's the key to our success. We're driving sustainable growth with financial discipline, what everything is measured and looked how do we improve it. The goal is to continue to deliver operating margin growth and strong cash flow. And to unlock the total value of Sanmina's capabilities and maximize the shareholders' value longer term. Still, a lot of leverage in Sanmina's business model, and we are excited about the future.
Please turn to slide 17. In summary, we delivered respectable results for our first quarter. Revenue of $1.76 billion, exceeding the midpoint of our outlook. Non-GAAP operating margin of 5%, and non-GAAP diluted EPS of $1.02, exceeding outlook. Free cash flow of $51 million. Non-GAAP pre-tax ROIC of 28.4%. For a second quarter, we see revenue outlook of $1.65 billion to $1.75 billion. Non-GAAP diluted EPS outlook of $0.76 to $0.86. We are seeing a relatively stable demand. We will continue to drive operational efficiencies and the mix. Also during this quarter, we will continue to monitor component supply environment. And as Kurt mentioned, we already factor this in into our quarterly outlook.
So, ladies and gentlemen, I would like to again, at this time, thank you all. And operator, we're ready for Q&A. Thank you again.
Questions and Answers:
Operator
[Operator Instructions] Our first question comes from the line of Ruplu Bhattacharya from Bank of America.
Ruplu Bhattacharya -- Bank of America -- Analyst
Thanks for taking my questions. I have a couple for Jure, and then a couple for Kurt, if I may. Jure, you had expected stable demand for the first quarter. More or less, when I look at the communications networks and the cloud infrastructure segment, it was down a little bit. So can you help us parse through what happened, like, maybe just talk a little bit about what you saw in optical versus networking? And last quarter, you had said there were some push outs in cloud. So, did those come in? So just trying to understand what was a strong, what was a little bi
gs are expanding. As you say, growing. Automotive, starting to see a nice improvement in demand. For communication networks, which includes networking, IP routing and advance optical systems, we see stable demand. We see some typical seasonality, but overall it's a fair demand. For mobile 5G network, short-term, we've seen improvements and long-term, we've seen a good growth. For cloud computing, for us that's a high-end computing and storage, we're starting to see some positive improvements and some seasonality impact. For second quarter, there are still some uncertainties around COVID and supply chain constraints, mainly with semiconductor components.
Please turn to slide 16. Let me make few more comments about business environment for the rest of the fiscal year 2021. We are focused on unlocking the total value by maximizing operating leverage in each of our business groups. Sanmina strategy is to build businesses around customer needs, delivering right value add and delivering competitive advantage to our customers, and expanding into more profitable projects in our focus key markets. As Kurt mentioned, we delivered for the second consecutive quarter, operating margin around 5%. We will continue to make progress and believe there is still room for improvement, and goal is to continue to drive efficiencies and a better mix. Today, I can say that management feels more comfortable that we can deliver to our long-term operating margin target of 5% to 6% in the future. And most important is that Sanmina has a strong customer base to build on for a better future. Based on present visibility, customers' forecasts and pipeline of growth opportunities, we feel positive about the rest of the calendar year 2021. The goal for us is to deliver solid results for fiscal year 2021.
Let me give you few more comments on management priorities. We'll continue to provide industry-leading end-to-end solution with the key technology components and products for key markets and our strategic customers. Managers will continue to build strong customer partnership, that's the key to our success. We're driving sustainable growth with financial discipline, what everything is measured and looked how do we improve it. The goal is to continue to deliver operating margin growth and strong cash flow. And to unlock the total value of Sanmina's capabilities and maximize the shareholders' value longer term. Still, a lot of leverage in Sanmina's business model, and we are excited about the future.
 Please turn to slide 17. In summary, we delivered respectable results for our first quarter. Revenue of $1.76 billion, exceeding the midpoint of our outlook. Non-GAAP operating margin of 5%, and non-GAAP diluted EPS of $1.02, exceeding outlook. Free cash flow of $51 million. Non-GAAP pre-tax ROIC of 28.4%. For a second quarter, we see revenue outlook of $1.65 billion to $1.75 billion. Non-GAAP diluted EPS outlook of $0.76 to $0.86. We are seeing a relatively stable demand. We will continue to drive operational efficiencies and the mix. Also during this quarter, we will continue to monitor component supply environment. And as Kurt mentioned, we already factor this in into our quarterly outlook.
So, ladies and gentlemen, I would like to again, at this time, thank you all. And operator, we're ready for Q&A. Thank you again.
Questions and Answers:
Operator
[Operator Instructions] Our first question comes from the line of Ruplu Bhattacharya from Bank of America.
Ruplu Bhattacharya -- Bank of America -- Analyst
Thanks for taking my questions. I have a couple for Jure, and then a couple for Kurt, if I may. Jure, you had expected stable demand for the first quarter. More or less, when I look at the communications networks and the cloud infrastructure segment, it was down a little bit. So can you help us parse through what happened, like, maybe just talk a little bit about what you saw in optical versus networking? And last quarter, you had said there were some push outs in cloud. So, did those come in? So just trying to understand what was a strong, what was a little bi