Skip to content

Commit c358729

Browse files
committed
skip already-applied patches gracefully in 3rdparty FetchContent
Signed-off-by: Aurelien Chartier <2567591+achartier@users.noreply.github.com>
1 parent 93d99f1 commit c358729

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

3rdparty/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,15 @@ foreach(DEP_IDX RANGE ${DEP_COUNT_MINUS_ONE})
5555
endif()
5656

5757
if(DEP_PATCH_FILE AND NOT DEP_PATCH_FILE STREQUAL "")
58+
set(_patch_file "${CMAKE_CURRENT_SOURCE_DIR}/${DEP_PATCH_FILE}")
5859
list(
5960
APPEND
6061
FETCH_ARGS
6162
PATCH_COMMAND
62-
patch
63-
-p1
64-
--forward
65-
--batch
66-
-i
67-
"${CMAKE_CURRENT_SOURCE_DIR}/${DEP_PATCH_FILE}")
63+
bash
64+
-c
65+
"patch -p1 --batch --dry-run -R -i '${_patch_file}' && echo 'Patch already applied, skipping.' || patch -p1 --forward --batch -i '${_patch_file}'"
66+
)
6867
endif()
6968

7069
FetchContent_Declare(${FETCH_ARGS})

0 commit comments

Comments
 (0)