Evolutionary population synthesis in stellar systems. I. A global approach