From 8c6676b2ea76842bd958998adfcfaedea09668b8 Mon Sep 17 00:00:00 2001 From: Taylor Sasser Date: Tue, 16 Dec 2025 14:53:16 -0500 Subject: [PATCH] cmFindPackage: Fix PACKAGE_VERSION not being set when rebuilding --- Source/cmFindPackageCommand.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 915388a784..1f6f35d543 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -1671,6 +1671,12 @@ bool cmFindPackageCommand::HandlePackageMode( "fileFound is true but FileFound is empty!"); fileFound = false; } + + if (fileFound) { + this->CurrentPackageInfo->Directory = + cmSystemTools::GetFilenamePath(this->FileFound); + this->CurrentPackageInfo->Version = this->VersionFound; + } } std::string const foundVar = cmStrCat(this->Name, "_FOUND"); @@ -1975,8 +1981,6 @@ bool cmFindPackageCommand::FindConfig() std::string init; if (found) { init = cmSystemTools::GetFilenamePath(this->FileFound); - this->CurrentPackageInfo->Directory = init; - this->CurrentPackageInfo->Version = this->VersionFound; } else { init = this->Variable + "-NOTFOUND"; }