# RPM does not include \<exportname\>-\<config\>.cmake, results in IMPORTED\_LOCATION not set for imported target

**URL:** https://discourse.cmake.org/t/rpm-does-not-include-exportname-config-cmake-results-in-imported-location-not-set-for-imported-target/11223
**Category:** Code
**Tags:** os:linux, cpack:rpm
**Created:** [July 11, 2024, 11:57am UTC](https://discourse.cmake.org/t/rpm-does-not-include-exportname-config-cmake-results-in-imported-location-not-set-for-imported-target/11223 "2024-07-11T11:57:03Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![maxnoe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/maxnoe/32/4750_2.png) [@maxnoe](https://discourse.cmake.org/u/maxnoe)
#### Post date: [July 11, 2024, 11:57am UTC](https://discourse.cmake.org/t/rpm-does-not-include-exportname-config-cmake-results-in-imported-location-not-set-for-imported-target/11223/1 "2024-07-11T11:57:03Z")

</div>

I have a project where I export targets to make them findable via `find_package(ADH-APIS CONFIG)`.

This all works fine if done via:

```auto
$ cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/adh-apis
$ cmake --build build
$ cmake --install build

```

All expected files are there and a dependent project can use them without issue:

```auto
-- Installing: /tmp/adh-apis/share/cmake/ADH-APIS/ADH-APISTargets.cmake
-- Installing: /tmp/adh-apis/share/cmake/ADH-APIS/ADH-APISTargets-release.cmake
-- Installing: /tmp/adh-apis/share/cmake/ADH-APIS/ADH-APISConfig.cmake
-- Installing: /tmp/adh-apis/share/cmake/ADH-APIS/ADH-APISConfigVersion.cmake

```

However, when building an RPM, the `share/cmake/ADH-APIS/ADH-APISTargets-release.cmake` is not included in the rpm, which results in the mentioned error:

```auto
$ rpm -qlp ADH-APIS-2.1.0-Linux.rpm | grep ADH-APIS
/opt/ctao/share/cmake/ADH-APIS
/opt/ctao/share/cmake/ADH-APIS/ADH-APISConfig.cmake
/opt/ctao/share/cmake/ADH-APIS/ADH-APISConfigVersion.cmake
/opt/ctao/share/cmake/ADH-APIS/ADH-APISTargets.cmake

```

Any idea how to fix this issue?

---

<div class="post-metadata">

### Author: ![maxnoe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/maxnoe/32/4750_2.png) [@maxnoe](https://discourse.cmake.org/u/maxnoe)
#### Post date: [July 11, 2024, 3:06pm UTC](https://discourse.cmake.org/t/rpm-does-not-include-exportname-config-cmake-results-in-imported-location-not-set-for-imported-target/11223/2 "2024-07-11T15:06:14Z")

</div>

I found that when running

```auto
$ cmake --build build --target package

```

the file is included, but not when running `cpack manually` in the build directory like this:

```auto
$ cd build
$ cpack -G RPM -C CPackConfig.cmake

```

---

<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: [July 11, 2024, 10:03pm UTC](https://discourse.cmake.org/t/rpm-does-not-include-exportname-config-cmake-results-in-imported-location-not-set-for-imported-target/11223/3 "2024-07-11T22:03:22Z")

</div>

Can you provide a minimal project that reproduces your problem? It may be something about your system which causes RPM to behave differently, so having a minimal project that someone else can run on a different system may help to confirm that.

---

<div class="post-metadata">

### Author: ![maxnoe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/maxnoe/32/4750_2.png) [@maxnoe](https://discourse.cmake.org/u/maxnoe)
#### Post date: [July 12, 2024, 8:22am UTC](https://discourse.cmake.org/t/rpm-does-not-include-exportname-config-cmake-results-in-imported-location-not-set-for-imported-target/11223/4 "2024-07-12T08:22:33Z")

</div>

Thanks for your reply. I sat down and created the minimal example:

> **[GitHub - maxnoe/cmake\_rpm\_issue: Minimal example for an issue encountered...](https://github.com/maxnoe/cmake_rpm_issue/)**
>
> Minimal example for an issue encountered while packaging RPMs with cmake - maxnoe/cmake\_rpm\_issue

The issue is as described above: the package works when creating it via `cmake --build build --target package` but fails due to not including the `fibTargets-release.cmake` when build using `cd build; cpack -G RPM -C CPackConfig.cmake`

---

<div class="post-metadata">

### Author: ![maxnoe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/maxnoe/32/4750_2.png) [@maxnoe](https://discourse.cmake.org/u/maxnoe)
#### Post date: [July 12, 2024, 8:33am UTC](https://discourse.cmake.org/t/rpm-does-not-include-exportname-config-cmake-results-in-imported-location-not-set-for-imported-target/11223/5 "2024-07-12T08:33:17Z")

</div>

Ok, done, I forgot to add the part with manually invoking cpack…

Here is a log of the CI that shows it failing when using cpack:

> <https://github.com/maxnoe/cmake_rpm_issue/actions/runs/9904880120/job/27363205518>

and here succeeding with using `cmake --build build --target package`:

> <https://github.com/maxnoe/cmake_rpm_issue/actions/runs/9904880120/job/27363205174>

---

<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: [July 13, 2024, 5:30am UTC](https://discourse.cmake.org/t/rpm-does-not-include-exportname-config-cmake-results-in-imported-location-not-set-for-imported-target/11223/6 "2024-07-13T05:30:17Z")

</div>

Thanks, that allowed me to track down the problem. You are invoking `cpack` incorrectly. The `-C` option expects a configuration name like `Debug`, `Release`, etc., not the name of a cpack configuration file. You don’t actually need to specify the file anyway, it will use `CPackConfig.cmake` by default. If you did need to specify a different file for some reason, the `--config` option is what you would use for that. It is unfortunate that the term “configuration” has multiple meanings here, but it is hard to avoid.

---

<div class="post-metadata">

### Author: ![maxnoe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/maxnoe/32/4750_2.png) [@maxnoe](https://discourse.cmake.org/u/maxnoe)
#### Post date: [July 13, 2024, 6:20am UTC](https://discourse.cmake.org/t/rpm-does-not-include-exportname-config-cmake-results-in-imported-location-not-set-for-imported-target/11223/7 "2024-07-13T06:20:12Z")

</div>

Oh wow, `-C` is not an alias for `--config`.

Thanks a lot!
