summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkleines Filmröllchen <filmroellchen@serenityos.org>2023-01-09 23:40:39 +0100
committerLinus Groh <mail@linusgroh.de>2023-03-19 14:15:35 +0000
commita6dd992ad3531ab427f3c39867d4f33b18ec561d (patch)
treef745c227f419ca121a27006b6b3c396980f06c8e
parent1ee2091b2d73808b245aeaf79e709ecc0017e65b (diff)
downloadserenity-a6dd992ad3531ab427f3c39867d4f33b18ec561d.zip
Meta: Add a tar extraction CMake wrapper
This is a copy of the zip wrapper adopted for tar archives.
-rw-r--r--Meta/CMake/utils.cmake15
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()