diff options
author | thexai <58434170+thexai@users.noreply.github.com> | 2022-05-08 15:34:44 +0200 |
---|---|---|
committer | thexai <58434170+thexai@users.noreply.github.com> | 2022-05-14 12:18:38 +0200 |
commit | c18c1fcd330da4eaa070304e62f8d8964335a32b (patch) | |
tree | efdcc7c8701cd11c908be103caba6c6dd02c3fce /cmake/scripts | |
parent | c4357207d65bf1af8e852769495aed8922a41b70 (diff) |
[Windows] fix cmake find patch executable (prioritize use Git patch.exe)
Diffstat (limited to 'cmake/scripts')
-rw-r--r-- | cmake/scripts/common/HandleDepends.cmake | 12 | ||||
-rw-r--r-- | cmake/scripts/windows/tools/patch.cmake | 10 | ||||
-rw-r--r-- | cmake/scripts/windowsstore/tools/patch.cmake | 10 |
3 files changed, 29 insertions, 3 deletions
diff --git a/cmake/scripts/common/HandleDepends.cmake b/cmake/scripts/common/HandleDepends.cmake index c737c6aef7..f3a821de28 100644 --- a/cmake/scripts/common/HandleDepends.cmake +++ b/cmake/scripts/common/HandleDepends.cmake @@ -116,8 +116,18 @@ function(add_addon_depends addon searchpath) if(NOT PATCH_PROGRAM OR "${PATCH_PROGRAM}" STREQUAL "") if(NOT PATCH_EXECUTABLE) # find the path to the patch executable - find_program(PATCH_EXECUTABLE NAMES patch) + if(WIN32) + # On Windows prioritize Git patch.exe + find_package(Git) + if(Git_FOUND) + get_filename_component(GIT_DIR ${GIT_EXECUTABLE} DIRECTORY) + get_filename_component(GIT_DIR ${GIT_DIR} DIRECTORY) + endif() + find_program(PATCH_EXECUTABLE NAMES patch.exe HINTS ${GIT_DIR} PATH_SUFFIXES usr/bin) + else() + find_program(PATCH_EXECUTABLE NAMES patch) + endif() if(NOT PATCH_EXECUTABLE) message(FATAL_ERROR "Missing patch command (we looked in ${CMAKE_PREFIX_PATH})") endif() diff --git a/cmake/scripts/windows/tools/patch.cmake b/cmake/scripts/windows/tools/patch.cmake index b955b4cdcf..451fc6664c 100644 --- a/cmake/scripts/windows/tools/patch.cmake +++ b/cmake/scripts/windows/tools/patch.cmake @@ -1,4 +1,12 @@ -find_program(PATCH_FOUND NAMES patch patch.exe) +# prioritize Git patch.exe +find_package(Git) +if(Git_FOUND) + get_filename_component(GIT_DIR ${GIT_EXECUTABLE} DIRECTORY) + get_filename_component(GIT_DIR ${GIT_DIR} DIRECTORY) +endif() + +find_program(PATCH_FOUND NAMES patch.exe HINTS ${GIT_DIR} PATH_SUFFIXES usr/bin) + if(PATCH_FOUND) message(STATUS "patch utility found at ${PATCH_FOUND}") else() diff --git a/cmake/scripts/windowsstore/tools/patch.cmake b/cmake/scripts/windowsstore/tools/patch.cmake index b955b4cdcf..451fc6664c 100644 --- a/cmake/scripts/windowsstore/tools/patch.cmake +++ b/cmake/scripts/windowsstore/tools/patch.cmake @@ -1,4 +1,12 @@ -find_program(PATCH_FOUND NAMES patch patch.exe) +# prioritize Git patch.exe +find_package(Git) +if(Git_FOUND) + get_filename_component(GIT_DIR ${GIT_EXECUTABLE} DIRECTORY) + get_filename_component(GIT_DIR ${GIT_DIR} DIRECTORY) +endif() + +find_program(PATCH_FOUND NAMES patch.exe HINTS ${GIT_DIR} PATH_SUFFIXES usr/bin) + if(PATCH_FOUND) message(STATUS "patch utility found at ${PATCH_FOUND}") else() |