I’ve got a mono-repo building several audio plugins. I want to keep them all in the same build tree / CMake project, but use CPack to generate separate installers for each individual plugin.
I’ve got this function to create the install rules:
function (install_plugin plugin)
if(WIN32)
set (plugin_dest "Program Files/Common Files/VST")
else() # Linux not targeted, assume MacOS
set (plugin_dest "Library/Audio/Plug-Ins/VST")
endif()
install (TARGETS "${plugin}"
DESTINATION "${plugin_dest}"
COMPONENT "${plugin}")
cpack_add_component ("${plugin}"
DISPLAY_NAME "${plugin}"
DESCRIPTION "${plugin} VST plugin")
endfunction()
and then for each plugin I’m generating a CPackConfig.cmake file that sets CPACK_INSTALL_CMAKE_PROJECTS to install just that project name and component name.
It appears to work – when I call CPack with that config file, I get the following generated files:
Thank you for pointing me to that issue, it does sound like the same bug.
The solution from that discussion seems to be calling cpack_add_component after include(CPack), but I’m not actually calling include(CPack) anywhere – because I’m trying to generate separate installers for each subproject, I’m generating CPackConfig files for each subproject during CMake configure, and then calling cpack --config <conf> for each of these generated CPack config files.
I tried setting CPACK_COMPONENTS_ALL to just my desired install component in each of my generated CPack config files, but I still get the same error, an empty pkg.
This brings up a related question – can CPack be included multiple times in the same build tree? Perhaps I should be calling include (CPack) once for each subproject. I was under the impression that CPack could only be included once per build tree, so I needed to generate each individual CPack config myself.
I believe you can only really safely call include(CPack) once in a project. It may be possible to include more than once from separate directories which have no common parent directories, but I wouldn’t be surprised if some part of the process does things internally to break that.
You should also be aware that all install components defined throughout the whole build are added to a global CPACK_COMPONENTS_ALL property. You’d have to account for that too if you were trying to include CPack more than once.
I see. So my use case, of wanting to generate separate installers for multiple subprojects within a monorepo, is simply not well supported by CMake?
Even if I can’t include(CPack) multiple times, it seems like I should be able to manually generate a CPack config file for each sub-project’s installer. It works for the DMG generator, but not the PKG generator…