diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index a00bf4ba7..a57a4f18f 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -1277,8 +1277,10 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file) bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file) { // The version file will be loaded in an isolated scope. - this->Makefile->PushScope(); - this->Makefile->PushPolicy(); + cmMakefile::ScopePushPop varScope(this->Makefile); + cmMakefile::PolicyPushPop polScope(this->Makefile); + static_cast(varScope); + static_cast(polScope); // Clear the output variables. this->Makefile->RemoveDefinition("PACKAGE_VERSION"); @@ -1344,10 +1346,6 @@ bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file) } } - // Restore the original scope. - this->Makefile->PopPolicy(); - this->Makefile->PopScope(); - // Succeed if the version is suitable. return suitable; }