Forty eclipsing binaries in the Small Magellanic Cloud: fundamental parameters and Cloud distance