I have never been to Salema, but there have been many posts on this forum from people who said it was a disappointment, spoiled by over-tourism. You might use the Search function here to look at some of those earlier posts.
It appears that your transportation choices are ALSA, Eva or Damas bus to Lagos then Eva bus to Salema OR bus to Faro/train to Lagos/bus to Salema. You can drill down on Rome2Rio.com to find links to the companies running those buses and check their schedules. Do not trust the fares, travel times, or frequencies displayed on the Rome2Rio website itself. I think you'll find the buses you need are rather infrequent, and it's going to be a long trip.
Spain and Portugal are not well-connected by ground transportation.
There's no rail service between Salema and Lisbon, so that will be another bus ride.
Are you sure you want to do this? I'd spend all the time in Lisbon, going to Sintra and perhaps Cascais. Or there are other spots on the Algarve that would somewhat shorten your transportation time. You'll find suggestions for alternatives to Salema in some of the earlier posts. (I admit to never having been to Salema.)