FindPatch.cmake should not restrict PATH to a subset of 4 pre-defined folders (and please document current behavior)
I was really confused that this kept failing:
find_package(Patch REQUIRED)
if (NOT DEFINED Patch_FOUND)
message(FATAL_ERROR "Could not find an executable for applying .patch files (IE: 'git') on this machine")
else()
message("Patch executable found: ${Patch_EXECUTABLE}")
endif()
rayga@DESKTOP-88A51E5 MINGW64 ~/Projects/tmp/JUCE-reaper-embedded-fx-gui/JUCE (develop)
$ where git
C:\Program Files\Git\mingw64\bin\git.exe
C:\Program Files\Git\cmd\git.exe
rayga@DESKTOP-88A51E5 MINGW64 ~/Projects/tmp/JUCE-reaper-embedded-fx-gui/JUCE (develop)
$ where patch
C:\Program Files\Git\usr\bin\patch.exe
But checking the source, I can see this:
if(CMAKE_HOST_WIN32)
set(_patch_path
"$ENV{LOCALAPPDATA}/Programs/Git/bin"
"$ENV{LOCALAPPDATA}/Programs/Git/usr/bin"
"$ENV{APPDATA}/Programs/Git/bin"
"$ENV{APPDATA}/Programs/Git/usr/bin"
)
endif()
# First search the PATH
find_program(Patch_EXECUTABLE
NAME patch
PATHS ${_patch_path}
DOC ${_doc}
)
if(CMAKE_HOST_WIN32)
# Now look for installations in Git/ directories under typical installation
# prefixes on Windows.
find_program(Patch_EXECUTABLE
NAMES patch
PATH_SUFFIXES Git/usr/bin Git/bin GnuWin32/bin
DOC ${_doc}
)
endif()
It looks like I cannot override the _patch_path
variable either to provide my own.
I think ideally it should:
- Just search the entire path
- (There's no documentation/warning anywhere that "tries to find patch executable in your PATH" = "opens your PATH but then looks in these 4 folders")
- Document the current behavior so that users are not surprised
- Allow passing/setting manual PATCH path
Thank you =)