CMAKE: moved GNA var setting to proper place; removed find_package when build python...
[platform/upstream/dldt.git] / inference-engine / cmake / extract.cmake
1 # Copyright (C) 2018-2019 Intel Corporation
2 # SPDX-License-Identifier: Apache-2.0
3 #
4
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)
9
10     file(MAKE_DIRECTORY ${unpacked_path})
11
12     message(STATUS "extracting...
13          src='${archive_path}'
14          dst='${unpacked_path}'")
15
16     if(NOT EXISTS "${archive_path}")
17       message(FATAL_ERROR "error: file to extract does not exist: '${archive_path}'")
18     endif()
19
20     # Extract it:
21     #
22     # in case of archive dont have top level folder lets create it
23     if (${folder})
24       set (unpacked_dir ${unpacked_path})
25       message("unpacked_dir= ${unpacked_dir}")      
26     endif()
27
28     message(STATUS "extracting... [tar xfz]")
29     execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz ${archive_path} 
30       WORKING_DIRECTORY ${unpacked_dir}
31       RESULT_VARIABLE rv
32       ERROR_VARIABLE err)
33
34     if (NOT (err STREQUAL ""))
35       message(STATUS "error: extract of '${archive_path}' failed: ${err}")
36       #invalid archive
37       file(REMOVE_RECURSE "${unpacked_path}")
38       file(REMOVE_RECURSE "${archive_path}")
39       set(${result} 0 PARENT_SCOPE)
40     else()
41       set(${result} 1 PARENT_SCOPE)
42     endif()
43     
44   endif()
45 endfunction (extract)