[CMake] CMake extracting tar via execute_process does not allow extraction in subdirectories

Eric Noulard eric.noulard at gmail.com
Tue Apr 2 01:50:47 EDT 2013


2013/4/2 Saad Khattak <saadrustam at gmail.com>

> Hi,
>
> If I have the following command:
>
>   execute_process(
>     COMMAND ${CMAKE_COMMAND} -E tar xzf mySDK.tar.gz
>     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
>     )
>
> the extraction works and extracts the tar in the current directory. But
> this:
>
>   execute_process(
>     COMMAND ${CMAKE_COMMAND} -E tar xzf mySDK.tar.gz
>     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/someSubdirectory
>     )
>
> fails to extract into 'someDirectory' (even if it already exists -
> although it 'should' create the directory for me).
>

No it shouldn't.


> Am I misunderstanding some commands?
>

Yes I think you misunderstand "WORKING_DIRECTORY" argument of
"execute_process" command.
The WORKING_DIRECTORY MUST exists beforehand and it is NOT the job of
"execute_process"
to create it.

A "WORKING_DIRECTORY" is **always** supposed to exists when used
by the cmake command providing this option like:
add_custom_command, add_test or execute_process.

If you need to create a directory you can "cmake -E make_directory"
or "file(MAKE_DIRECTORY ...)"

That said "cmake -E tar xzf mySDK.tar.gz" will create any directory found
in the archive as expected.
"working directory" for untar and "[possibly] top-level directory" created
nby untar are not the same.


-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130402/af112a52/attachment.htm>


More information about the CMake mailing list