fix problem when cm / cmi is invoked in a symlinked folder

@tfoote @wjwwood Please review.