1 # Copyright (C) 2018-2019 Intel Corporation
2 # SPDX-License-Identifier: Apache-2.0
5 function (extract archive_path unpacked_path folder result)
6 # Slurped from a generated extract-TARGET.cmake file.
7 if (NOT EXISTS ${unpacked_path})
8 get_filename_component(unpacked_dir ${unpacked_path} DIRECTORY)
10 file(MAKE_DIRECTORY ${unpacked_path})
12 message(STATUS "extracting...
14 dst='${unpacked_path}'")
16 if(NOT EXISTS "${archive_path}")
17 message(FATAL_ERROR "error: file to extract does not exist: '${archive_path}'")
22 # in case of archive dont have top level folder lets create it
24 set (unpacked_dir ${unpacked_path})
25 message("unpacked_dir= ${unpacked_dir}")
28 message(STATUS "extracting... [tar xfz]")
29 execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz ${archive_path}
30 WORKING_DIRECTORY ${unpacked_dir}
34 if (NOT (err STREQUAL ""))
35 message(STATUS "error: extract of '${archive_path}' failed: ${err}")
37 file(REMOVE_RECURSE "${unpacked_path}")
38 file(REMOVE_RECURSE "${archive_path}")
39 set(${result} 0 PARENT_SCOPE)
41 set(${result} 1 PARENT_SCOPE)