I would like to zip folder in my project from CMake. For that I use following code snippet:
ADD_CUSTOM_COMMAND (
TARGET ${PROJECT_NAME}
PRE_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E tar cvf ${ZIP_OUT_DIR}/my_archive.zip --format=zip -- ${FOLDER_TO_ZIP}/another_folder/
)
The problem with this code is that the files after unzipping contain path component (../../my_file.txt
in my case). I tried to use tar cvf -C ${FOLDER_TO_ZIP}/another_folder
but unfortunatelly CMake doesn't accept this option.
How can I get rid of leading path from zip archive when using CMake ?