This is on a build box, where the generator is "Ninja Multi-Config"
, and -DCMAKE_CONFIGURATION_TYPES="Release;Debug" -DCMAKE_DEFAULT_CONFIGS=all
. After the project is built (it has multiple libraries), I want to run a custom command to tar up a couple directories (that contain Debug and Release artifacts).
In the CMakeLists.txt of the last library built (renamed to LastTargetBuilt for this example), I currently have:
add_custom_command(TARGET LastTargetBuilt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E tar “cf” “${CMAKE_BINARY_DIR}/${ZIP_FILENAME}” --format=zip – “*”
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/dist
COMMENT “Creating archive ${CMAKE_BINARY_DIR}/${ZIP_FILENAME}.”
)
However, in the generated .zip, I am only seeing a single library built by the Debug (the second in the list of configuration types), where I see all the Release libraries.
I also tried:
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${ZIP_FILENAME}
COMMAND ${CMAKE_COMMAND} -E tar “cf” “${CMAKE_BINARY_DIR}/${ZIP_FILENAME}” --format=zip – “*”
DEPENDS LastTargetBuilt
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/dist
COMMENT “Creating archive ${CMAKE_BINARY_DIR}/${ZIP_FILENAME}.”
)add_custom_target(ArchiveProject ALL
${CMAKE_BINARY_DIR}/${ZIP_FILENAME}
)
And this does not generate an archive at all.