1 # Copyright (C) 2018-2019 Intel Corporation
3 # SPDX-License-Identifier: Apache-2.0
6 function (extract archive_path unpacked_path folder result)
7 # Slurped from a generated extract-TARGET.cmake file.
8 if (NOT EXISTS ${unpacked_path})
9 get_filename_component(unpacked_dir ${unpacked_path} DIRECTORY)
11 file(MAKE_DIRECTORY ${unpacked_path})
13 message(STATUS "extracting...
15 dst='${unpacked_path}'")
17 if(NOT EXISTS "${archive_path}")
18 message(FATAL_ERROR "error: file to extract does not exist: '${archive_path}'")
23 # in case of archive dont have top level folder lets create it
25 set (unpacked_dir ${unpacked_path})
26 message("unpacked_dir= ${unpacked_dir}")
29 message(STATUS "extracting... [tar xfz]")
30 execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz ${archive_path}
31 WORKING_DIRECTORY ${unpacked_dir}
35 if (NOT (err STREQUAL ""))
36 message(STATUS "error: extract of '${archive_path}' failed: ${err}")
38 file(REMOVE_RECURSE "${unpacked_path}")
39 file(REMOVE_RECURSE "${archive_path}")
40 set(${result} 0 PARENT_SCOPE)
42 set(${result} 1 PARENT_SCOPE)