Intro
When I go exploring, I often find abandoned buildings, farms, factories. Near where I live, it's easy to find abandoned buildings in the mountains or the National Park.
I have an interest in Urbex. I admit some times when I go to the wild I'm actively looking for urban places and ruins to explore. I've been in some amazing places in my country, and I'm always looking for more. However, this is just an interest, not something I spend a lot of time thinking about.
Examples
Here's a few examples of places I've been (I don't own these photos):
Abandoned arabic building
Abandoned hotel (since the 80s I think), in the islands
Abandoned panoramic restaurant (since the 80s), right next to the country's capital
Abandoned thermal spa, popular during the beginning of XX century
Problem
How legal is it to enter these buildings? Can I explore with peace of mind knowing I'm doing nothing wrong or can this be considered trespassing, breaking & entering, burglary or even mischief, even if I'm doing nothing wrong?
I only enter a building if there is an open door (or window, gate, even holes in the walls or fences) and I never break anything. I like to have the same approach as I have in the wild: leave no trace. In my opinion, this is still the wilderness and you can actually find good examples of local flora and fauna inside these buildings.
Also, if there is a sign stating "Private property" or "No enter", I respect the signs and move on. There's plenty more to explore out there.
The arabic building from the picture above, for example, is abandoned but belongs to a complex of buildings on the same area, which I suppose belong to the same owner. As far as I know, there are people who own this building and who are easily identifiable, so I did not go inside.
I understand the laws will be different from country to country, but probably the principles will be the same? And how can I find the relevant laws and analyze them?
Thank you in advance, respect the world.
EDIT
To clarify, the photos were taken in Portugal; but since I also travel around the world (mainly Europe), I would like to know the general principles behind these laws. The answers given so far are interesting on this matter.
Also, one final note just to point the obvious: trespassing, burglary and other offenses can be considered serious crimes in your area. If you believe you might be committing a felony, you should stop and inform yourself first. I believe no one in here endorses illegal activities. :-)
SECOND EDIT
I understand that laws will be different from country to country, no need to keep telling me that. However, the answers given so far are all quite interesting and what I was looking for, so I will keep the question as is. Thanks guys.