© 2016 American Physical Society. Using the adiabatic connection, we formulate the free energy in terms of the correlation function of a fictitious system, hλ(r,r′), in which interactions λu(r,r') are gradually switched on as λ changes from 0 to 1. The function hλ(r,r') is then obtained from the inhomogeneous Ornstein-Zernike equation and the two equations constitute a general liquid-state framework for treating inhomogeneous fluids. The two equations do not yet constitute a closed set. In the present work we use the closure cλ(r,r')≈-λβu(r,r'), known as the random-phase approximation (RPA). We demonstrate that the RPA is identical with the variational Gaussian approximation derived within the field-theoretical framework, originally derived and used for charged particles. We apply our generalized RPA approximation to the Gaussian core model and Coulomb charges.