diff options
-rw-r--r-- | Meta/CMake/utils.cmake | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Meta/CMake/utils.cmake b/Meta/CMake/utils.cmake index 336f7bc96d..9970e87f72 100644 --- a/Meta/CMake/utils.cmake +++ b/Meta/CMake/utils.cmake @@ -267,3 +267,18 @@ function(extract_path dest_dir zip_path source_path dest_path) endif() endif() endfunction() + +function(extract_tar_path dest_dir tar_path source_path dest_path) + if (EXISTS "${tar_path}" AND NOT EXISTS "${dest_path}") + if (CMAKE_VERSION VERSION_LESS 3.18.0) + message(STATUS "Extracting using ${TAR_TOOL} ${source_path} from ${tar_path}") + execute_process(COMMAND "${TAR_TOOL}" -xf "${tar_path}" -C "${dest_dir}" "${source_path}" RESULT_VARIABLE untar_result) + if (NOT untar_result EQUAL 0) + message(FATAL_ERROR "Failed to untar ${source_path} from ${tar_path} with status ${untar_result}") + endif() + else() + message(STATUS "Extracting using cmake ${source_path}") + file(ARCHIVE_EXTRACT INPUT "${tar_path}" DESTINATION "${dest_dir}" PATTERNS "${source_path}") + endif() + endif() +endfunction() |