updated for arbitrary dimension
updated cmakes to do static compile