Metallicity dependence of high-mass X-ray binary populations