Refactor disabling of third-party warnings

This follows up OPM/opm-core#655.