|
|
|
|
|
|
| cmake_minimum_required(VERSION ${CMAKE_VERSION}) # this file comes with cmake
|
|
|
|
|
|
|
| get_filename_component(filename "@filename@" ABSOLUTE)
|
| get_filename_component(directory "@directory@" ABSOLUTE)
|
|
|
| message(VERBOSE "extracting...
|
| src='${filename}'
|
| dst='${directory}'"
|
| )
|
|
|
| if(NOT EXISTS "${filename}")
|
| message(FATAL_ERROR "File to extract does not exist: '${filename}'")
|
| endif()
|
|
|
|
|
|
|
| set(i 1234)
|
| while(EXISTS "${directory}/../ex-@name@${i}")
|
| math(EXPR i "${i} + 1")
|
| endwhile()
|
| set(ut_dir "${directory}/../ex-@name@${i}")
|
| file(MAKE_DIRECTORY "${ut_dir}")
|
|
|
|
|
|
|
| message(VERBOSE "extracting... [tar @args@]")
|
| execute_process(COMMAND ${CMAKE_COMMAND} -E tar @args@ ${filename} @options@
|
| WORKING_DIRECTORY ${ut_dir}
|
| RESULT_VARIABLE rv
|
| )
|
|
|
| if(NOT rv EQUAL 0)
|
| message(VERBOSE "extracting... [error clean up]")
|
| file(REMOVE_RECURSE "${ut_dir}")
|
| message(FATAL_ERROR "Extract of '${filename}' failed")
|
| endif()
|
|
|
|
|
|
|
| message(VERBOSE "extracting... [analysis]")
|
| file(GLOB contents "${ut_dir}/*")
|
| list(REMOVE_ITEM contents "${ut_dir}/.DS_Store")
|
| list(LENGTH contents n)
|
| if(NOT n EQUAL 1 OR NOT IS_DIRECTORY "${contents}")
|
| set(contents "${ut_dir}")
|
| endif()
|
|
|
|
|
|
|
| message(VERBOSE "extracting... [rename]")
|
| file(REMOVE_RECURSE ${directory})
|
| get_filename_component(contents ${contents} ABSOLUTE)
|
| file(RENAME ${contents} ${directory})
|
|
|
|
|
|
|
| message(VERBOSE "extracting... [clean up]")
|
| file(REMOVE_RECURSE "${ut_dir}")
|
|
|
| message(VERBOSE "extracting... done")
|
|
|