2017-05-25 14:33:16 +08:00
|
|
|
## # vcpkg_apply_patches
|
|
|
|
##
|
|
|
|
## Apply a set of patches to a source tree.
|
|
|
|
##
|
|
|
|
## ## Usage
|
|
|
|
## ```cmake
|
|
|
|
## vcpkg_apply_patches(
|
|
|
|
## SOURCE_PATH <${SOURCE_PATH}>
|
|
|
|
## [QUIET]
|
|
|
|
## PATCHES <patch1.patch>...
|
|
|
|
## )
|
|
|
|
## ```
|
|
|
|
##
|
|
|
|
## ## Parameters
|
|
|
|
## ### SOURCE_PATH
|
|
|
|
## The source path in which apply the patches. By convention, this is usually set in the portfile as the variable `SOURCE_PATH`.
|
|
|
|
##
|
|
|
|
## ### PATCHES
|
|
|
|
## A list of patches that are applied to the source tree.
|
|
|
|
##
|
|
|
|
## Generally, these take the form of `${CMAKE_CURRENT_LIST_DIR}/some.patch` to select patches in the `port\<port>\` directory.
|
|
|
|
##
|
|
|
|
## ### QUIET
|
|
|
|
## Disables the warning message upon failure.
|
|
|
|
##
|
|
|
|
## This should only be used for edge cases, such as patches that are known to fail even on a clean source tree.
|
|
|
|
##
|
|
|
|
## ## Examples
|
|
|
|
##
|
|
|
|
## * [boost](https://github.com/Microsoft/vcpkg/blob/master/ports/boost/portfile.cmake)
|
|
|
|
## * [freetype](https://github.com/Microsoft/vcpkg/blob/master/ports/freetype/portfile.cmake)
|
|
|
|
## * [libpng](https://github.com/Microsoft/vcpkg/blob/master/ports/libpng/portfile.cmake)
|
2017-01-06 06:37:37 +08:00
|
|
|
|
2016-09-19 11:50:08 +08:00
|
|
|
function(vcpkg_apply_patches)
|
2017-01-06 06:37:37 +08:00
|
|
|
cmake_parse_arguments(_ap "QUIET" "SOURCE_PATH" "PATCHES" ${ARGN})
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-02-21 13:24:14 +08:00
|
|
|
find_program(GIT NAMES git git.cmd)
|
2016-09-19 11:50:08 +08:00
|
|
|
set(PATCHNUM 0)
|
|
|
|
foreach(PATCH ${_ap_PATCHES})
|
2018-08-08 19:15:13 +08:00
|
|
|
get_filename_component(ABSOLUTE_PATCH "${PATCH}" ABSOLUTE BASE_DIR "${CURRENT_PORT_DIR}")
|
2016-09-19 11:50:08 +08:00
|
|
|
message(STATUS "Applying patch ${PATCH}")
|
|
|
|
set(LOGNAME patch-${TARGET_TRIPLET}-${PATCHNUM})
|
2019-08-29 04:49:29 +08:00
|
|
|
_execute_process(
|
2018-08-08 19:15:13 +08:00
|
|
|
COMMAND ${GIT} --work-tree=. --git-dir=.git apply "${ABSOLUTE_PATCH}" --ignore-whitespace --whitespace=nowarn --verbose
|
2016-09-19 11:50:08 +08:00
|
|
|
OUTPUT_FILE ${CURRENT_BUILDTREES_DIR}/${LOGNAME}-out.log
|
|
|
|
ERROR_FILE ${CURRENT_BUILDTREES_DIR}/${LOGNAME}-err.log
|
|
|
|
WORKING_DIRECTORY ${_ap_SOURCE_PATH}
|
|
|
|
RESULT_VARIABLE error_code
|
|
|
|
)
|
2016-11-03 07:49:15 +08:00
|
|
|
|
2018-01-25 07:22:41 +08:00
|
|
|
if(error_code AND NOT _ap_QUIET)
|
2019-10-08 01:35:13 +08:00
|
|
|
message(FATAL_ERROR "Applying patch failed. Patch needs to be updated to work with source being used by vcpkg!")
|
2016-10-19 07:17:47 +08:00
|
|
|
endif()
|
|
|
|
|
2016-09-19 11:50:08 +08:00
|
|
|
math(EXPR PATCHNUM "${PATCHNUM}+1")
|
|
|
|
endforeach()
|
|
|
|
endfunction()
|