This work reports on incorporating complex terrain into wind farm simulations for the purpose of layout optimization. Adding complex terrain boundary conditions to NREL's medium fidelity Reynolds averaged Navier-Stokes flow model, WindSE, produces significant separation, flow curvature, and speedup effects that would otherwise be difficult to capture with lower-fidelity models or a flat-terrain assumption. These flow features, in turn, can significantly impact the optimal turbine array layout. We demonstrate the addition of complex terrain improves agreement with SCADA data by 34.8% in mean average error. Additionally, we discuss modifications to the code that enable gradient-based layout optimization using terrainaware adjoints with arbitrary topography. Through several optimization case studies, we show that the layout optimization process takes advantage of speedup effects on terrain high points, and leverages flow curvature effects that modify wake trajectories. This yields substantial power improvements over gridded layouts, and hints at future research directions in simulation and optimization for wake trajectories in complex terrain.