diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 1968f3b75b..248a8a0c92 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 16c5caa321..892da76c1b 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);