Preheat your oven to 350°F (175°C).
Grease and flour two 9-inch round cake pans.
In a large bowl, whisk together flour, sugar, baking powder, baking soda, cinnamon, nutmeg, and salt.
In another bowl, mix the oil and eggs until well combined.
Gradually add the wet mixture to the dry ingredients, stirring until just combined.
Fold in the grated carrots, crushed pineapple, and walnuts if using.
Divide the batter evenly between the prepared pans.
Bake for 40-45 minutes, or until a toothpick inserted into the center comes out clean.
Allow the cakes to cool in the pans for 10 minutes, then turn them out onto a wire rack to cool completely.
Once cooled, frost with cream cheese frosting and decorate as desired.