From 8d6b76771dba19241056d5dba07dee11a52160fc Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 12 Dec 2024 11:36:40 -0500 Subject: [PATCH 1/2] find_package: Explicitly normalize CONFIG file path as it exists on disk This was missed in commit 9d44a77454 (find_*: Explicitly normalize found paths as they exist on disk, 2024-10-17). --- Source/cmFindPackageCommand.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index f3d95b5e3d..d74416c1dd 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -2410,8 +2410,6 @@ bool cmFindPackageCommand::CheckDirectory(std::string const& dir) // Look for the file in this directory. if (this->FindConfigFile(d, this->FileFound)) { - // Remove duplicate slashes. - cmSystemTools::ConvertToUnixSlashes(this->FileFound); return true; } return false; @@ -2429,6 +2427,8 @@ bool cmFindPackageCommand::FindConfigFile(std::string const& dir, // Allow resolving symlinks when the config file is found through a link if (this->UseRealPath) { file = cmSystemTools::GetRealPath(file); + } else { + file = cmSystemTools::ToNormalizedPathOnDisk(file); } return true; } From 592e95bbea3792bda3eefbcec49742d08a198854 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 12 Dec 2024 11:38:29 -0500 Subject: [PATCH 2/2] cmFindPackageCommand: Avoid temporarily saving non-existent result --- Source/cmFindPackageCommand.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index d74416c1dd..da29b9e97d 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -1437,7 +1437,7 @@ bool cmFindPackageCommand::HandlePackageMode( // The file location was cached. Look for the correct file. std::string file; if (this->FindConfigFile(dir, file)) { - this->FileFound = file; + this->FileFound = std::move(file); fileFound = true; } def = this->Makefile->GetDefinition(this->Variable); @@ -2409,7 +2409,9 @@ bool cmFindPackageCommand::CheckDirectory(std::string const& dir) } // Look for the file in this directory. - if (this->FindConfigFile(d, this->FileFound)) { + std::string file; + if (this->FindConfigFile(d, file)) { + this->FileFound = std::move(file); return true; } return false;