# CPack not installing package contents?

**URL:** https://discourse.cmake.org/t/cpack-not-installing-package-contents/7411
**Category:** Usage
**Created:** [February 6, 2023, 6:50pm UTC](https://discourse.cmake.org/t/cpack-not-installing-package-contents/7411 "2023-02-06T18:50:28Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![benthevining](https://discourse.cmake.org/user_avatar/discourse.cmake.org/benthevining/32/1924_2.png) [@benthevining](https://discourse.cmake.org/u/benthevining)
#### Post date: [February 6, 2023, 6:50pm UTC](https://discourse.cmake.org/t/cpack-not-installing-package-contents/7411/1 "2023-02-06T18:50:28Z")

</div>

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:

```cmake
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:

```auto
_CPack_Packages
 - productbuild
  - opzilla-0.0.1-Darwin
    - Contents
      - Readme, license, etc
    - Library/Audio/Plug-Ins/VST
      - opzilla.vst

```

but when I run the generated `.pkg`, it appears it has nothing to install:

 ![Screen Shot 2023-02-06 at 12.49.42 PM](https://discourse.cmake.org/uploads/default/original/2X/b/bed32e6ac5927edf8b0bffaf2e0c72e93d447488.jpeg)

is this a problem with my installation paths?

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [February 7, 2023, 3:47am UTC](https://discourse.cmake.org/t/cpack-not-installing-package-contents/7411/2 "2023-02-07T03:47:11Z")

</div>

The following issue probably describes your scenario and includes a workaround:

[https://gitlab.kitware.com/cmake/cmake/-/issues/18201](https://gitlab.kitware.com/cmake/cmake/-/issues/18201)

---

<div class="post-metadata">

### Author: ![benthevining](https://discourse.cmake.org/user_avatar/discourse.cmake.org/benthevining/32/1924_2.png) [@benthevining](https://discourse.cmake.org/u/benthevining)
#### Post date: [February 7, 2023, 11:11pm UTC](https://discourse.cmake.org/t/cpack-not-installing-package-contents/7411/3 "2023-02-07T23:11:13Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [February 25, 2023, 7:54am UTC](https://discourse.cmake.org/t/cpack-not-installing-package-contents/7411/4 "2023-02-25T07:54:49Z")

</div>

> [@benthevining](#):
>
> 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.

---

<div class="post-metadata">

### Author: ![benthevining](https://discourse.cmake.org/user_avatar/discourse.cmake.org/benthevining/32/1924_2.png) [@benthevining](https://discourse.cmake.org/u/benthevining)
#### Post date: [February 28, 2023, 3:57am UTC](https://discourse.cmake.org/t/cpack-not-installing-package-contents/7411/5 "2023-02-28T03:57:16Z")

</div>

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…
