Tar creation path issues
I have a directory that is generated at build time: $CMAKE_BINARY_DIRECTORY/Pack
. It has a load of stuff in it that I'd like to zip: Pack/a.txt
, Pack/b.txt
and so on.
The problem is, there is no way to build a zip from those that doesn't have a 'Pack' directory in it. I tried the following.
add_custom_target(zip
COMMAND ${CMAKE_COMMAND} -E tar "cfv" "${CMAKE_BINARY_DIR}/out.zip" --format=zip -- "${CMAKE_BINARY_DIR}/Pack/"
VERBATIM
)
That unfortunately puts everything in Pack. Then I looked in the code, and saw that the final zip path depends on the working directory. So I tried this.
add_custom_target(zip
COMMAND ${CMAKE_COMMAND} -E tar "cfv" "${CMAKE_BINARY_DIR}/out.zip" --format=zip -- "${CMAKE_BINARY_DIR}/Pack/"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Pack/"
VERBATIM
)
But that doesn't seem to add anything at all! I tried this:
add_custom_target(zip
COMMAND ${CMAKE_COMMAND} -E tar "cfv" "${CMAKE_BINARY_DIR}/out.zip" --format=zip -- "."
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Pack/"
VERBATIM
)
That adds all the files, but it puts them as ./a.txt
and so on in the zip. 7-zip sort of understands this, but Windows just shows it as an empty zip. It's wrong in any case.