The quantum correlations of $N$ noninteracting spinless fermions in their ground state can be expressed in terms of a two-point function called the kernel. Here we develop a general and compact method for computing the kernel in a general trapping potential in terms of the Green's function for the corresponding single particle Schr\"odinger equation. For smooth potentials the method allows a simple alternative derivation of the local density approximation for the density and of the sine kernel in the bulk part of the trap in the large $N$ limit. It also recovers the density and the kernel of the so-called {\em Airy gas} at the edge. This method allows to analyse the quantum correlations in the ground state when the potential has a singular ...