# Install DLL from imported package

**URL:** <https://discourse.cmake.org/t/install-dll-from-imported-package/11628>\
**Category:** Code\
**Created:** [September 9, 2024, 4:02pm UTC](https://discourse.cmake.org/t/install-dll-from-imported-package/11628 "2024-09-09T16:02:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oodini](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Post date:** [September 9, 2024, 4:02pm UTC](https://discourse.cmake.org/t/install-dll-from-imported-package/11628/1 "2024-09-09T16:02:58Z")

</div>

Hello,

In my project, I use thye package Xerces-C++. So I do :

```auto
find_package(XercesC 3.2.5 CONFIG REQUIRED)

if(XercesC_FOUND)
    message(STATUS "@@@@@@@@@@@@@@@@ Xerces found")
    message(STATUS "@@@@@@@@@@@@@@@@ Xerces version: ${XercesC_VERSION}")
    message(STATUS "@@@@@@@@@@@@@@@@ Xerces include dirs: ${XercesC_INCLUDE_DIRS}")
    message(STATUS "@@@@@@@@@@@@@@@@ Xerces libraries: ${XercesC_LIBRARIES}")
else()
    message(FATAL_ERROR "Xerces not found")
endif()

```

I can link it with my project without any problem :

```auto
target_link_libraries(MyProject PRIVATE XercesC::XercesC)

```

Note I found the value `XercesC::XercesC` only thanks to the `message()` command. I didn’t find documentation about this point.

Next, I want to install the Xerces DLLs. I tried several flavors of the `install()` command, but I fail.

Ie (at the end of the CMakeLists.txt):

```auto
install(IMPORTED_RUNTIME_ARTIFACTS XercesC::XercesC
        RUNTIME_DEPENDENCY_SET foo
        RUNTIME)

```

Here is the log :

```auto
  -- @@@@@@@@@@@@@@@@ Xerces found
  -- @@@@@@@@@@@@@@@@ Xerces version: 3.2.5
  -- @@@@@@@@@@@@@@@@ Xerces include dirs: E:/CMake/bin/ExternalDependencies/XercesC-install/x64/Debug/include
  -- @@@@@@@@@@@@@@@@ Xerces libraries: XercesC::XercesC
...
  CMake Error at src/CMakeLists.txt:488 (install):
    install IMPORTED_RUNTIME_ARTIFACTS given target "XercesC::XercesC" which is
    not an executable, library, or module.

```

Note the code of my project isn’t compiled/linked at all, whereas it is when I remove the `install()` command (located at the end of the CMakeLists.txt).

What am I supposed to do to install the DLL coming with Xerces ?

---

<div class="post-metadata">

**Author:** ![Osyotr](https://discourse.cmake.org/user_avatar/discourse.cmake.org/osyotr/32/4883_2.png) [@Osyotr](https://discourse.cmake.org/u/Osyotr)\
**Post date:** [September 13, 2024, 8:42pm UTC](https://discourse.cmake.org/t/install-dll-from-imported-package/11628/2 "2024-09-13T20:42:26Z")

</div>

`XercesC::XercesC` is probably `UNKNOWN IMPORTED` target. I don’t think CMake is able to install such targets (though I also think it be able to guess that it’s a shared library by inspecting `IMPORTED_LOCATION` property).

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [September 14, 2024, 12:32pm UTC](https://discourse.cmake.org/t/install-dll-from-imported-package/11628/3 "2024-09-14T12:32:35Z")

</div>

I have a working example (tested on OSX only):

> <https://github.com/ClausKlein/docker_build/blob/develop/CMakeLists.txt>
