Perfect Magic Cubes

A magic cube is a three-dimensional array of whole numbers, in which each row, column, and body diagonal (corner to corner, through the center) adds up to the same total. A perfect magic cube is one in which the diagonals of each vertical or horizontal slice through the cube also sum to the same value.

Courtesy of Christian Boyer

Suppose each row, column, and diagonal contains N numbers.