I have been trying to use CPack on my project (which builds vst plugins) and having a hard time making it work. So I created a smaller project to ask for help.
The idea is that there are 2 components: a vst2 and a vst3 which are both the exact same file but need to go in different folder with different names (note that it is actually the same way for my audio plugins).
Here is the small project CMakeLists.txt
cmake_minimum_required(VERSION 3.17)
project(cpack_test)
set(CMAKE_CXX_STANDARD 17)
add_executable(cpack_test main.cpp)
set(DEST_DIR "/Volumes/Vault/tmp/cpack-test")
install(FILES "$<TARGET_FILE:cpack_test>"
COMPONENT "vst2"
DESTINATION "${DEST_DIR}/vst2"
CONFIGURATIONS Debug
RENAME "cpack_test_Debug_vst2"
)
install(FILES "$<TARGET_FILE:cpack_test>"
COMPONENT "vst3"
DESTINATION "${DEST_DIR}/vst3"
CONFIGURATIONS Debug
RENAME "cpack_test_Debug_vst3"
)
set(CPACK_PACKAGE_NAME "CPackTestArchive")
set(CPACK_PACKAGE_VENDOR "TBD: CPACK_PACKAGE_VENDOR")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "TBD: CPACK_PACKAGE_DESCRIPTION_SUMMARY")
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "0")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_GENERATOR ZIP)
set(CPACK_VERBATIM_VARIABLES TRUE)
set(CPACK_ARCHIVE_COMPONENT_INSTALL TRUE)
set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)
include(CPack)
cpack_add_component(vst3
DISPLAY_NAME "TBD: cpack_add_component/vst3/DISPLAY_NAME"
DESCRIPTION "TBD: cpack_add_component/vst3/DESCRIPTION"
)
cpack_add_component(vst2
DISPLAY_NAME "TBD: cpack_add_component/vst2/DISPLAY_NAME"
DESCRIPTION "TBD: cpack_add_component/vst2/DESCRIPTION"
)
add_custom_target("archive"
COMMAND ${CMAKE_COMMAND} -E echo "Creating archive ${CMAKE_CPACK_COMMAND}"
COMMAND "${CMAKE_CPACK_COMMAND}" --verbose -G ZIP -C $<CONFIG>
DEPENDS cpack_test
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" # CPackConfig.cmake is created there
)
When I run the archive
target I get the following output:
[100%] Built target cpack_test
Creating archive /Applications/CLion.app/Contents/bin/cmake/mac/bin/cpack
CPack: Enable Verbose
CPack Verbose: Read CPack config file:
CPack Verbose: Read CPack configuration file: /Volumes/Vault/tmp/misc-projects/cpack-test/cmake-build-debug/CPackConfig.cmake
CPack Verbose: Specified generator: ZIP
CPack Verbose: Use generator: cmCPackArchiveGenerator
CPack Verbose: For project: CPackTestArchive
CPack: Create package using ZIP
CPack Verbose: Read description file: /Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.17/Templates/CPack.GenericDescription.txt
CPack Verbose: [ZIP] requested component grouping = ALL_COMPONENTS_IN_ONE
CPack Verbose: [ZIP] requested component grouping = ALL_COMPONENTS_IN_ONE
CPack Verbose: Remove toplevel directory: /Volumes/Vault/tmp/misc-projects/cpack-test/cmake-build-debug/_CPack_Packages/Darwin/ZIP
CPack: Install projects
CPack: - Run preinstall target for: cpack_test
CPack: - Install project: cpack_test [Debug]
CPack: - Install component: vst2
CPack Verbose: Install configuration: "Debug"
CPack Verbose: Up-to-date: /Volumes/Vault/tmp/cpack-test/vst2/cpack_test_Debug_vst2
CPack: - Install component: vst3
CPack Verbose: Install configuration: "Debug"
CPack Verbose: Up-to-date: /Volumes/Vault/tmp/cpack-test/vst3/cpack_test_Debug_vst3
CPack: Create package
CPack Verbose: Package files to: /Volumes/Vault/tmp/misc-projects/cpack-test/cmake-build-debug/_CPack_Packages/Darwin/ZIP/CPackTestArchive-1.0.0-Darwin.zip
CPack Verbose: Packaging all groups in one package...(CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE is set)
CPack Verbose: - packaging component: vst2
CPack Verbose: - packaging component: vst3
CPack Verbose: Copying final package(s) [1]:
CPack: - package: /Volumes/Vault/tmp/misc-projects/cpack-test/cmake-build-debug/CPackTestArchive-1.0.0-Darwin.zip generated.
Built target archive
But the archive generated (CPackTestArchive-1.0.0-Darwin.zip
) is completely empty. I have been following the details in Chapter 27 of Professional CMake (7th edition) but cannot figure out what I am doing wrong. It also seems to suggest that cpack
is installing in a staging directory but from the output it looks like it is installing in the actual destination folder, not a staging one and I am wondering if that is the issue.
Thanks for the help
Yan