Reapply r185601 with a fix for the cmake build.