From 14c1406bbd6170307f26ec81cffc39e1cdfeec2b Mon Sep 17 00:00:00 2001 From: drodin Date: Fri, 2 Jul 2021 12:37:49 +0300 Subject: [PATCH] patch mechanism --- cmake/schemes/url_sha1_cmake.cmake.in | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/cmake/schemes/url_sha1_cmake.cmake.in b/cmake/schemes/url_sha1_cmake.cmake.in index d638d25417..9d83c999a0 100644 --- a/cmake/schemes/url_sha1_cmake.cmake.in +++ b/cmake/schemes/url_sha1_cmake.cmake.in @@ -149,6 +149,31 @@ foreach(configuration ${configuration_types}) set(build_type_opts "-DCMAKE_CONFIGURATION_TYPES=${configuration}") endif() + set(patch_command PATCH_COMMAND) + set(package_patch_dir "@HUNTER_PACKAGE_SETUP_DIR@/patches/@HUNTER_PACKAGE_VERSION@") + if(EXISTS ${package_patch_dir} AND IS_DIRECTORY ${package_patch_dir}) + if(EXISTS ${package_patch_dir}/CMakeLists.txt) + list(APPEND patch_command + COMMAND ${CMAKE_COMMAND} -E copy ${package_patch_dir}/CMakeLists.txt @HUNTER_PACKAGE_SOURCE_DIR@ + ) + endif() + if(EXISTS ${package_patch_dir}/cmake AND IS_DIRECTORY ${package_patch_dir}/cmake) + list(APPEND patch_command + COMMAND ${CMAKE_COMMAND} -E copy_directory ${package_patch_dir}/cmake @HUNTER_PACKAGE_SOURCE_DIR@/cmake + ) + endif() + file(GLOB package_patches ${package_patch_dir}/*.patch) + if(package_patches) + list(SORT package_patches) + include(hunter_get_git_executable) + hunter_get_git_executable(git_executable) + list(APPEND patch_command + COMMAND ${git_executable} --work-tree=. --git-dir=.git apply ${package_patches} --ignore-whitespace --whitespace=nowarn --verbose + WORKING_DIRECTORY @HUNTER_PACKAGE_SOURCE_DIR@ + ) + endif() + endif() + ExternalProject_Add( "${current_project}" URL @@ -167,6 +192,7 @@ foreach(configuration ${configuration_types}) # not used, just avoid creating Install/ empty directory SOURCE_SUBDIR "@HUNTER_PACKAGE_SOURCE_SUBDIR@" + ${patch_command} BUILD_COMMAND # Separate build and install stage so we can suppress install log # which may consist of a long list of files