CPack: Setting `CPACK_OUTPUT_FILE_PREFIX` breaks the `cpack -B` argument
If CPACK_OUTPUT_FILE_PREFIX
is set and -B
is provided, the intermediate _CPack_Packages
directory is created in the directory specified by -B
, but the final package files (and also checksum files) are still created in the directory specified by CPACK_OUTPUT_FILE_PREFIX
.
set(CPACK_PACKAGE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set(CPACK_OUTPUT_FILE_PREFIX "${CPACK_PACKAGE_DIRECTORY}/Packaging")
cpack -G ZIP -C RelWithDebInfo -B "C:/_tmp"
The solution is to set CPACK_PACKAGE_DIRECTORY
as follows and never use CPACK_OUTPUT_FILE_PREFIX
.
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Packaging")
I suggest deprecating CPACK_OUTPUT_FILE_PREFIX
, documenting the variable on https://cmake.org/cmake/help/latest/module/CPack.html (I know that the variable is not listed there, but one can find references on the WWW) as "do not use!" and remove it completely after some time.
Edited by Florian Wolters