Skip to content

Commit 9788041

Browse files
Fix "cpm_add_patches" handling of multiple patch commands
Update "cpm_add_patches" to correctly handle multiple patch files. The "PATCH_COMMAND" executor may not be a shell, so it is not portable to use shell operators like "&&" and "<" in the command. Commands after the initial PATCH_COMMAND should nstead be prefixed by COMMAND, and we can use "-i" to specify that a file is used by the "patch" command.
1 parent 0f23108 commit 9788041

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cmake/CPM.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,16 +529,16 @@ function(cpm_add_patches)
529529
# Convert to absolute path for use with patch file command.
530530
get_filename_component(PATCH_FILE "${PATCH_FILE}" ABSOLUTE)
531531

532-
# The first patch entry must be preceded by "PATCH_COMMAND" while the following items are
533-
# preceded by "&&".
532+
# The first patch entry must be preceded by "PATCH_COMMAND". Subsequent
533+
# commands are preceeded by "COMMAND".
534534
if(first_item)
535535
set(first_item False)
536536
list(APPEND temp_list "PATCH_COMMAND")
537537
else()
538-
list(APPEND temp_list "&&")
538+
list(APPEND temp_list "COMMAND")
539539
endif()
540540
# Add the patch command to the list
541-
list(APPEND temp_list "${PATCH_EXECUTABLE}" "-p1" "<" "${PATCH_FILE}")
541+
list(APPEND temp_list "${PATCH_EXECUTABLE}" "-p1" "-i" "${PATCH_FILE}")
542542
endforeach()
543543

544544
# Move temp out into parent scope.

0 commit comments

Comments
 (0)