allow building empty workspace with cmi

and generating the environment files.
This is a modified version of pull request #423.