function(patch_sources PATCH_DIR SOURCE_DIR) file(GLOB_RECURSE PATCHED_SOURCES RELATIVE ${PATCH_DIR} ${PATCH_DIR}/*) list(REMOVE_ITEM PATCHED_SOURCES ".gitkeep") foreach (file ${PATCHED_SOURCES}) message(STATUS "Patching ${file}...") set(destination "${SOURCE_DIR}/${file}") cmake_path(GET destination PARENT_PATH dest_dir) file(COPY ${PATCH_DIR}/${file} DESTINATION ${dest_dir}) endforeach () endfunction()