Meta: Add a tar extraction CMake wrapper
This is a copy of the zip wrapper adopted for tar archives.
This commit is contained in:
parent
1ee2091b2d
commit
a6dd992ad3
Notes:
sideshowbarker
2024-07-17 18:49:10 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/a6dd992ad3 Pull-request: https://github.com/SerenityOS/serenity/pull/16937 Issue: https://github.com/SerenityOS/serenity/issues/14683 Reviewed-by: https://github.com/linusg ✅
1 changed files with 15 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue