diff options
author | Pär Björklund <per.bjorklund@gmail.com> | 2020-01-11 11:46:35 +0100 |
---|---|---|
committer | Pär Björklund <per.bjorklund@gmail.com> | 2020-01-16 19:58:35 +0100 |
commit | 24138bf3e609596074155c316c076024677f3df2 (patch) | |
tree | d6e45a16361d2773c41414ce9da1e008bba4cfa9 /cmake | |
parent | 4db5f328d1c1ede85169eadf4fec4c1459a6efa5 (diff) |
Improve patch finding
On Windows we only want to find patch.exe included with git.
All other patch.exe is broken in some way and will cause build
failures
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/scripts/common/HandleDepends.cmake | 12 | ||||
-rw-r--r-- | cmake/scripts/windows/tools/patch.cmake | 39 | ||||
-rw-r--r-- | cmake/scripts/windowsstore/tools/patch.cmake | 39 |
3 files changed, 74 insertions, 16 deletions
diff --git a/cmake/scripts/common/HandleDepends.cmake b/cmake/scripts/common/HandleDepends.cmake index 40e382b94c..78a3742145 100644 --- a/cmake/scripts/common/HandleDepends.cmake +++ b/cmake/scripts/common/HandleDepends.cmake @@ -111,18 +111,6 @@ function(add_addon_depends addon searchpath) endif() set(PATCH_PROGRAM ${PATCH_EXECUTABLE}) - - # On Windows "patch.exe" can only handle CR-LF line-endings. - # Our patches have LF-only line endings - except when they - # have been checked out as part of a dependency hosted on Git - # and core.autocrlf=true. - if(WIN32) - file(READ ${patch} patch_content_hex HEX) - # Force handle LF-only line endings - if(NOT patch_content_hex MATCHES "0d0a") - list(APPEND PATCH_PROGRAM --binary) - endif() - endif() endif() set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${patch}) diff --git a/cmake/scripts/windows/tools/patch.cmake b/cmake/scripts/windows/tools/patch.cmake index b955b4cdcf..d75cb6ec5d 100644 --- a/cmake/scripts/windows/tools/patch.cmake +++ b/cmake/scripts/windows/tools/patch.cmake @@ -1,6 +1,41 @@ -find_program(PATCH_FOUND NAMES patch patch.exe) +set(_doc "Patch command line executable") +set(_patch_path ) + +#cmake can't handle ENV{PROGRAMFILES(X86)} so +#use a hack where we append it ourselves +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" + "$ENV{PROGRAMFILES}/Git/bin" + "$ENV{PROGRAMFILES}/Git/usr/bin" + "$ENV{PROGRAMFILES} (x86)/Git/bin" + "$ENV{PROGRAMFILES} (x86)/Git/usr/bin" + ) + +# First search the PATH +find_program(PATCH_EXECUTABLE + NAME patch + PATHS ${_patch_path} + DOC ${_doc} + NO_DEFAULT_PATH + ) + +if(PATCH_EXECUTABLE AND NOT TARGET Patch::patch AND NOT PATCH_EXECUTABLE MATCHES Strawberry) + add_executable(Patch::patch IMPORTED) + set_property(TARGET Patch::patch PROPERTY IMPORTED_LOCATION ${PATCH_EXECUTABLE}) +endif() + +unset(_patch_path) +unset(_doc) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Patch + REQUIRED_VARS PATCH_EXECUTABLE) + if(PATCH_FOUND) - message(STATUS "patch utility found at ${PATCH_FOUND}") + message(STATUS "patch utility found at ${PATCH_EXECUTABLE}") else() set(PATCH_ARCHIVE_NAME "patch-2.7.6-bin") set(PATCH_ARCHIVE "${PATCH_ARCHIVE_NAME}.zip") diff --git a/cmake/scripts/windowsstore/tools/patch.cmake b/cmake/scripts/windowsstore/tools/patch.cmake index b955b4cdcf..d75cb6ec5d 100644 --- a/cmake/scripts/windowsstore/tools/patch.cmake +++ b/cmake/scripts/windowsstore/tools/patch.cmake @@ -1,6 +1,41 @@ -find_program(PATCH_FOUND NAMES patch patch.exe) +set(_doc "Patch command line executable") +set(_patch_path ) + +#cmake can't handle ENV{PROGRAMFILES(X86)} so +#use a hack where we append it ourselves +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" + "$ENV{PROGRAMFILES}/Git/bin" + "$ENV{PROGRAMFILES}/Git/usr/bin" + "$ENV{PROGRAMFILES} (x86)/Git/bin" + "$ENV{PROGRAMFILES} (x86)/Git/usr/bin" + ) + +# First search the PATH +find_program(PATCH_EXECUTABLE + NAME patch + PATHS ${_patch_path} + DOC ${_doc} + NO_DEFAULT_PATH + ) + +if(PATCH_EXECUTABLE AND NOT TARGET Patch::patch AND NOT PATCH_EXECUTABLE MATCHES Strawberry) + add_executable(Patch::patch IMPORTED) + set_property(TARGET Patch::patch PROPERTY IMPORTED_LOCATION ${PATCH_EXECUTABLE}) +endif() + +unset(_patch_path) +unset(_doc) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Patch + REQUIRED_VARS PATCH_EXECUTABLE) + if(PATCH_FOUND) - message(STATUS "patch utility found at ${PATCH_FOUND}") + message(STATUS "patch utility found at ${PATCH_EXECUTABLE}") else() set(PATCH_ARCHIVE_NAME "patch-2.7.6-bin") set(PATCH_ARCHIVE "${PATCH_ARCHIVE_NAME}.zip") |