Unclarity around the usage of install and CPack in specific scenario

I’m in the process of splitting up a large and quite dated, monorepo into smaller more isolated chunks. But I’m left uncertain on how the install and CPack functionality is ment to be used here, specificly when it comes to linking the different components together.

Purely for the build phase, I’ve started with a FetchContent based system, which is working quite well. Now I am now adding the support to be able to install and package the software. However it is unclear to me how the various install and package components are intended to work together.

Ultimatly, I need to be able to bundle all the, dll/dylibs (both internal and a few external), resources together into an installer or zip depending on the specific export (application vs SDK). For applications, from what I have been able to read, CPack seems like the best option. Whilst for SDK it is likely better to export these as import targets, which can be consumed using find_package.

For me it remains unclear how and where I should place: install(TARGETS), install(EXPORT), include(CPack), configure_package_config_file. Or how COMPONENT should best be used.

  • If I have a dependency chain of Lib1 > Lib2 > Exe, how can I ensure that the resources and dlls/dylibs of Lib1 and Lib2 are packaged with Exe, It seems like inside the CPack of Exe it would need to mention every component mentioned somewhere inside its dependency chain or avoid using component based installs altogether
  • Similarly, if a library offers optional components, there seems to be no way to define connenctions between those components. Thus Exe could be packaged missing a required component of an optional one.

So i’m left head-scratching on how to use these various tools in order to be able to split a bloated repository into smaller chunks. Any advise or tips would be welcome.