-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathApplyPatch.cmake
More file actions
33 lines (30 loc) · 1.05 KB
/
ApplyPatch.cmake
File metadata and controls
33 lines (30 loc) · 1.05 KB
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
26
27
28
29
30
31
32
33
# Copyright (c) 2020-2021 Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
macro(execute_reset_head_cmd target)
# git reset --hard
execute_process(COMMAND ${GIT_EXECUTABLE} reset --hard --quiet
WORKING_DIRECTORY ${target}
RESULT_VARIABLE GIT_RESET_RESULT)
if(NOT GIT_RESET_RESULT EQUAL "0")
message(FATAL_ERROR "reset failed for ${target}")
endif()
endmacro()
macro(execute_apply_patch_cmd target)
# git apply <patch_file>
execute_process(COMMAND ${GIT_EXECUTABLE} apply "${target}.patch"
WORKING_DIRECTORY ${target}
RESULT_VARIABLE GIT_PATCH_RESULT)
if(NOT GIT_PATCH_RESULT EQUAL "0")
message(FATAL_ERROR "Apply patch failed for ${target}")
else()
message(STATUS "Patch applied successfully on ${target}")
endif()
endmacro()
function(apply_patch target)
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
execute_reset_head_cmd(${target})
execute_apply_patch_cmd(${target})
endif()
endfunction()