A rigorous thermodynamic framework is developed for performing free energy calculations of polymer glasses described by classical molecular forcefields. The proper free energy connected to all combinations of imposed external conditions (strain, stress) is derived from a well defined Helmholtz energy calculated from the detailed atomistic configurations. The quasi-harmonic approximation (QHA) is employed around local minima of the system on its potential energy landscape. The ingredients of the methodology, i.e. the derivatives of the free energy with respect to atomic positions (forces, elements of the Hessian) and the relevant derivatives with respect to strain (stresses and elastic constants), are calculated through tractable analytic ex...