A Generalization of Calabi-Yau Fourfolds Arising from M-Theory Compactifications