Backport module/pg cmake changes from master to stable