fix array num for FFI
[liba.git] / cmake / FindPatch.cmake
blob9b42df0df467aed899f8b4fd78beb71a8b84acc7
1 # .rst:
2 # FindPatch
3 # ----------
5 # Find patch executable.
7 # Result Variables
8 # ^^^^^^^^^^^^^^^^
10 # This module defines the following variables:
12 # ``Patch_FOUND``
14 # ``Patch_EXECUTABLE``
16 # ``Patch_VERSION``
18 include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
20 if(CMAKE_HOST_WIN32)
21   find_program(Patch_EXECUTABLE NAMES patch
22     PATHS
23       "$ENV{LOCALAPPDATA}/Programs/Git/bin"
24       "$ENV{LOCALAPPDATA}/Programs/Git/usr/bin"
25       "$ENV{APPDATA}/Programs/Git/bin"
26       "$ENV{APPDATA}/Programs/Git/usr/bin"
27   )
28   mark_as_advanced(Patch_EXECUTABLE)
29 else()
30   find_program(Patch_EXECUTABLE NAMES patch)
31   mark_as_advanced(Patch_EXECUTABLE)
32 endif()
34 if(EXISTS "${Patch_EXECUTABLE}")
35   execute_process(COMMAND ${Patch_EXECUTABLE} --version ERROR_QUIET OUTPUT_VARIABLE Patch_VERSION)
36   string(REGEX REPLACE ".*patch ([^\n ]+).*" "\\1" Patch_VERSION "${Patch_VERSION}")
37 endif()
39 find_package_handle_standard_args(Patch
40   FOUND_VAR
41     Patch_FOUND
42   REQUIRED_VARS
43     Patch_EXECUTABLE
44   VERSION_VAR
45     Patch_VERSION