I have used the *_OUTPUT_PATH variables in my CMakeLists.txt file to specify specific locations for my binaries and library files, and that seems to be working "automatically"
I would like as part of a "build" for one final step to happen, which is to create a tarball of the binaries that output directory.
What do I need to add to create a tar?
You can use a CMake custom target to invoke CMake in command mode and have it produce a tarball from the binaries in the output directory. Here is a CMakeLists.txt that sketches the necessary steps:
project(TarExample)
set (EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/executables")
add_executable(foo foo.cpp)
add_custom_target(create_tar ALL COMMAND
${CMAKE_COMMAND} -E tar "cfvz" "executables.tgz" "${EXECUTABLE_OUTPUT_PATH}")
add_dependencies(create_tar foo)
The custom target generates a gzipped tarball from the files in the directory EXECUTABLE_OUTPUT_PATH
. The add_dependencies
call ensures that the tarball is created as a final step.
To produce an uncompressed tarball, use the option cfv
instead of cfvz
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With