Using the adiabatic connection, we formulate the free energy in terms of the correlation function of a fictitious system, $h_{lambda}({bf r},{bf r})$, where $lambda$ determines the interaction strength. To obtain $h_{lambda}({bf r},{bf r})$ we use the Ornstein-Zernike equation, and the two equations constitute a general liquid-state framework for treating inhomogeneous fluids. As the two equations do not form a closed set, an approximate closure relation is required and it determines a type of an approximation. In the present work we investigate the random phase approximation (RPA) closure. We determine that this approximation is identical to the variational Gaussian approximation derived within the framework of the field-theory. We then apply our generalized RPA approximation to the Gaussian core model and Coulomb charges.