View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015962CMakeCMakepublic2016-02-09 15:002016-06-10 14:21
Reporternitroamos 
Assigned To 
PrioritylowSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSWindowsOS Version8
Product VersionCMake 3.4.3 
Target VersionFixed in Version 
Summary0015962: can't unzip jar file on windows
DescriptionI'd like to use cmake to unpack a .jar file. To do this, I use the following command in my CMakeLists.txt:

execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf ${MY_JAR} --format=zip ${CMAKE_CURRENT_BINARY_DIR}/ )


Which I run through the CMake GUI. This command works as intended on OSX. On Windows, I get the following error when configuring:


COMMAND C:/Program Files (x86)/CMake/bin/cmake.exe -E tar xf my.jar --format=zip build
CMake Error: Problem with archive_write_header(): Can't create '\\?\C:\Program Files (x86)\CMake\META-INF\MANIFEST.MF'

CMake Error: Current file: META-INF/MANIFEST.MF

CMake Error: Problem extracting tar: my.jar

Steps To Reproducecmake_minimum_required(VERSION 2.8.9)
project(extractjar)

message("COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_SOURCE_DIR}/my.jar --format=zip ${CMAKE_CURRENT_BINARY_DIR}/")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_SOURCE_DIR}/my.jar --format=zip ${CMAKE_CURRENT_BINARY_DIR}/ )
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0040452)
Brad King (manager)
2016-02-09 16:05

Your command line appears to assume that the last argument is an output directory. It is not (and is not in POSIX tar command lines either). The current working directory of the process is always the output directory unless the tarball contains absolute paths. Paths listed at the end of the command line specify input files for tar creation and are currently ignored for extraction.

Use `cmake -E chdir ... cmake -E tar xf ...` to set the working directory.
(0040453)
Brad King (manager)
2016-02-09 16:07

Normally we've used `cmake -E tar` in an add_custom_command. In that case the working directory will be in the build tree when the command is executed by the generated build system.
(0040454)
Chuck Atkins (developer)
2016-02-09 16:25

You could also try passing the WORKING_DIRECTORY argument to execute_process:

execute_process(
  COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_SOURCE_DIR}/my.jar --format=zip
  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)

See https://cmake.org/cmake/help/v3.4/command/execute_process.html [^]
(0040455)
Brad King (manager)
2016-02-09 16:29

Re 0015962:0040454: [smacks forehead] Yes, that is much better than -E chdir.
(0040491)
nitroamos (reporter)
2016-02-15 12:57

I copied the line I used from elsewhere and only checked to see if it was correct by running it (and it worked as expected on OSX). Sorry for the bug report. Adding WORKING_DIRECTORY resolved it.

Thanks!

I don't see a way for me to mark the issue as resolved...
(0041253)
Kitware Robot (administrator)
2016-06-10 14:21

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2016-02-09 15:00 nitroamos New Issue
2016-02-09 16:05 Brad King Note Added: 0040452
2016-02-09 16:07 Brad King Note Added: 0040453
2016-02-09 16:25 Chuck Atkins Note Added: 0040454
2016-02-09 16:29 Brad King Note Added: 0040455
2016-02-15 12:57 nitroamos Note Added: 0040491
2016-02-16 09:21 Brad King Status new => resolved
2016-02-16 09:21 Brad King Resolution open => no change required
2016-06-10 14:21 Kitware Robot Note Added: 0041253
2016-06-10 14:21 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team