From db0e2574cb2d3e4471f3cbf210870158dfd74f9e Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 7 Apr 2025 19:27:55 -0400 Subject: cmSystemTools: Restore FindProgram look-up of on-disk case on Windows KWSys's `FindProgram` no longer looks up the actual case on disk. This behavior change was inherited from the change to `CollapseFullPath`. Extend commit 773b75e4ed (cmake: Explicitly look up on-disk case of input paths on Windows, 2024-10-23, v4.0.0-rc1~589^2) to cover this by wrapping `FindProgram` in a CMake-specific layer. Issue: #20214 --- Source/cmSystemTools.cxx | 10 ++++++++++ Source/cmSystemTools.h | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 1968f3b..248a8a0 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2992,6 +2992,16 @@ unsigned int cmSystemTools::RandomNumber() return static_cast(gen()); } +std::string cmSystemTools::FindProgram(std::string const& name, + std::vector const& path) +{ + std::string exe = cmsys::SystemTools::FindProgram(name, path); + if (!exe.empty()) { + exe = cmSystemTools::ToNormalizedPathOnDisk(std::move(exe)); + } + return exe; +} + namespace { std::string InitLogicalWorkingDirectory() { diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 16c5caa..892da76 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -560,6 +560,14 @@ public: static unsigned int RandomSeed(); static unsigned int RandomNumber(); + /** + * Find an executable in the system PATH, with optional extra paths. + * This wraps KWSys's FindProgram to add ToNormalizedPathOnDisk. + */ + static std::string FindProgram( + std::string const& name, + std::vector const& path = std::vector()); + /** Find the directory containing CMake executables. */ static void FindCMakeResources(char const* argv0); -- cgit v0.12