aboutsummaryrefslogtreecommitdiff
path: root/thirdparty/ryml/ext/c4core/cmake/PatchUtils.cmake
blob: 164940e009dd8f56604b6f79d823642c82fd1418 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# create a script that applies a patch (it's different in windows)

# to generate a patch:
# subversion: svn diff --patch-compatible > path/to/the/patch.diff


function(apply_patch patch where mark)
    if(NOT EXISTS "${mark}")
        if(NOT Patch_EXECUTABLE)
          find_package(Patch REQUIRED)
        endif()
        file(TO_NATIVE_PATH ${patch} patch_native)
        get_filename_component(patch_name "${patch}" NAME)
        message(STATUS "Applying patch: ${patch_name}")
        execute_process(
          COMMAND "${Patch_EXECUTABLE}" "-p0" "--input=${patch_native}"
          WORKING_DIRECTORY "${where}"
          RESULT_VARIABLE status)
        if(NOT status STREQUAL "0")
            message(FATAL_ERROR "could not apply patch: ${patch} ---> ${where}")
        else()
          file(TOUCH "${mark}")
        endif()
    endif()
endfunction()