# Error when installing targets and exports in 3.19.1

**URL:** <https://discourse.cmake.org/t/error-when-installing-targets-and-exports-in-3-19-1/2245>\
**Category:** Usage\
**Created:** [November 26, 2020, 3:19pm UTC](https://discourse.cmake.org/t/error-when-installing-targets-and-exports-in-3-19-1/2245 "2020-11-26T15:19:34Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![vre](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@vre](https://discourse.cmake.org/u/vre)\
**Post date:** [November 26, 2020, 3:19pm UTC](https://discourse.cmake.org/t/error-when-installing-targets-and-exports-in-3-19-1/2245/1 "2020-11-26T15:19:34Z")

</div>

I’m using the following fragments to install targets and exports in a number of projects.

```
install(TARGETS myproj EXPORT myproj 
  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT development
  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime NAMELINK_SKIP
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
)

if(MYPROJ_BUILD_SHARED_LIBS)
  install(TARGETS myproj EXPORT myproj LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT development NAMELINK_ONLY)
  if(MSVC)
    install(FILES $<TARGET_PDB_FILE:myproj > DESTINATION ${CMAKE_INSTALL_BINDIR} CONFIGURATIONS Debug RelWithDebInfo COMPONENT debug)
  endif()
endif()

```

This has worked literally for the last years. Until recently I got an error message from a user that used CMake 3.19.1

````
```
-- Configuring done
CMake Error: install(EXPORT "myproj" ...) includes target "myproj" more than once in the export set.
-- Generating done
```

````

Is the error on my side and I should avoid repeating the `EXPORT myproj` part when building shared libraries or is that a regression in 3.19.1?

Thanks in advance, Cheers Volker

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [November 26, 2020, 7:46pm UTC](https://discourse.cmake.org/t/error-when-installing-targets-and-exports-in-3-19-1/2245/2 "2020-11-26T19:46:36Z")

</div>

It smells like a regression, but there should be no reason to have a separate `install()` command for the target as it should just be a no-op on static builds anyways. The PDB installation should be guarded by `MSVC` (or MinGW) though.

Cc: @kyle.edwards

---

<div class="post-metadata">

**Author:** ![JackBoosY](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jackboosy/32/2497_2.png) [@JackBoosY](https://discourse.cmake.org/u/JackBoosY)\
**Post date:** [November 27, 2020, 6:55am UTC](https://discourse.cmake.org/t/error-when-installing-targets-and-exports-in-3-19-1/2245/3 "2020-11-27T06:55:54Z")

</div>

BTW, I found many libraries have this same issue.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [November 27, 2020, 3:56pm UTC](https://discourse.cmake.org/t/error-when-installing-targets-and-exports-in-3-19-1/2245/4 "2020-11-27T15:56:57Z")

</div>

If it’s a prevalent pattern, we should definitely look at fixing it. Is there a full project that can be pointed at so we can test any fixes?

---

<div class="post-metadata">

**Author:** ![rickert](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/e68b1a/32.png) [@rickert](https://discourse.cmake.org/u/rickert)\
**Post date:** [November 29, 2020, 1:08pm UTC](https://discourse.cmake.org/t/error-when-installing-targets-and-exports-in-3-19-1/2245/5 "2020-11-29T13:08:58Z")

</div>

CMake \>3.12 includes a new option [`NAMELINK_COMPONENT`](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/1982) that can be used to do this in one command. As this was a common workaround to separate namelinks into runtime and development components on older CMake versions, it would be nice if this change in behavior since 3.19 could be protected by a policy.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [November 29, 2020, 5:36pm UTC](https://discourse.cmake.org/t/error-when-installing-targets-and-exports-in-3-19-1/2245/6 "2020-11-29T17:36:27Z")

</div>

Cc: @kyle.edwards @brad.king Potential 3.19 regression.

---

<div class="post-metadata">

**Author:** ![JackBoosY](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jackboosy/32/2497_2.png) [@JackBoosY](https://discourse.cmake.org/u/JackBoosY)\
**Post date:** [November 30, 2020, 2:51am UTC](https://discourse.cmake.org/t/error-when-installing-targets-and-exports-in-3-19-1/2245/7 "2020-11-30T02:51:27Z")

</div>

Related PR: [https://github.com/microsoft/vcpkg/pull/14716](https://github.com/microsoft/vcpkg/pull/14716)

---

<div class="post-metadata">

**Author:** ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)\
**Post date:** [November 30, 2020, 4:15pm UTC](https://discourse.cmake.org/t/error-when-installing-targets-and-exports-in-3-19-1/2245/8 "2020-11-30T16:15:04Z")

</div>

Cc: @craig.scott @dbahadir

This bisects to [CMake MR 5352](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5352). I’ve opened [CMake Issue 21529](https://gitlab.kitware.com/cmake/cmake/-/issues/21529) to record this regression.

---

<div class="post-metadata">

**Author:** ![vre](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@vre](https://discourse.cmake.org/u/vre)\
**Post date:** [December 5, 2020, 1:48pm UTC](https://discourse.cmake.org/t/error-when-installing-targets-and-exports-in-3-19-1/2245/9 "2020-12-05T13:48:44Z")

</div>

Thanks to all for handling and fixing this issue.
