Permalink
Browse files

Merge branch 'update-find-patch'

* update-find-patch:
  ApplyPatches: Use copy of upstream FindPatch.cmake
  • Loading branch information...
2 parents b9ae615 + 7eda951 commit cc93717837469bcd36746b91739949f100e64123 @jcfr jcfr committed Sep 4, 2017
Showing with 73 additions and 17 deletions.
  1. +68 −0 cmake/FindPatch.cmake
  2. +5 −17 cmake/PythonApplyPatches.cmake
View
@@ -0,0 +1,68 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#.rst:
+# FindPatch
+# ---------
+#
+# The module defines the following variables:
+#
+# ``Patch_EXECUTABLE``
+# Path to patch command-line executable.
+# ``Patch_FOUND``
+# True if the patch command-line executable was found.
+#
+# The following :prop_tgt:`IMPORTED` targets are also defined:
+#
+# ``Patch::patch``
+# The command-line executable.
+#
+# Example usage:
+#
+# .. code-block:: cmake
+#
+# find_package(Patch)
+# if(Patch_FOUND)
+# message("Patch found: ${Patch_EXECUTABLE}")
+# endif()
+
+set(_doc "Patch command line executable")
+set(_patch_path )
+
+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()
+
+if(Patch_EXECUTABLE AND NOT TARGET Patch::patch)
+ 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)
@@ -1,21 +1,9 @@
-set(_x86 "(x86)") # Indirection required to avoid error related to CMP0053
-find_program(PATCH_EXECUTABLE
- NAME patch
- PATHS "$ENV{ProgramFiles}/Git/usr/bin"
- "$ENV{ProgramFiles${_x86}}/Git/usr/bin"
- "$ENV{ProgramFiles}/GnuWin32/bin"
- "$ENV{ProgramFiles${_x86}}/GnuWin32/bin"
- "$ENV{ProgramFiles}/Git/bin"
- "$ENV{ProgramFiles${_x86}}/Git/bin"
- "$ENV{LOCALAPPDATA}/Programs/Git/bin"
- "$ENV{LOCALAPPDATA}/Programs/Git/usr/bin"
- "$ENV{APPDATA}/Programs/Git/bin"
- "$ENV{APPDATA}/Programs/Git/usr/bin"
+set(CMAKE_MODULE_PATH
+ ${CMAKE_CURRENT_LIST_DIR}
+ ${CMAKE_MODULE_PATH}
)
-if(NOT PATCH_EXECUTABLE)
- message(FATAL_ERROR "Could NOT find patch (missing: PATCH_EXECUTABLE)")
-endif()
+find_package(Patch REQUIRED)
set(patches_dir "${Python_SOURCE_DIR}/patches")
@@ -39,7 +27,7 @@ function(_apply_patches _subdir)
continue()
endif()
execute_process(
- COMMAND ${PATCH_EXECUTABLE} --quiet -p1 -i ${patches_dir}/${patch}
+ COMMAND ${Patch_EXECUTABLE} --quiet -p1 -i ${patches_dir}/${patch}
WORKING_DIRECTORY ${SRC_DIR}
RESULT_VARIABLE result
ERROR_VARIABLE error

0 comments on commit cc93717

Please sign in to comment.