# What it means? Imported target "my\_sort\_lib" includes non-existent path

**URL:** https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850
**Category:** Code
**Created:** [June 12, 2022, 4:43pm UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850 "2022-06-12T16:43:26Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![petrasvestartas](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@petrasvestartas](https://discourse.cmake.org/u/petrasvestartas)
#### Post date: [June 12, 2022, 4:43pm UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850/1 "2022-06-12T16:43:27Z")

</div>

Hi,

I am trying to use function `find_package` for my created package which is very simple for learning purposes.  
This is how I create and install my own package:

> **[CMAKE/install\_export at main · petrasvestartas/CMAKE](https://github.com/petrasvestartas/CMAKE/tree/main/install_export)**
>
> main/install\_export

This is the project where I try to use find\_package method:

> **[CMAKE/find\_package at main · petrasvestartas/CMAKE](https://github.com/petrasvestartas/CMAKE/tree/main/find_package)**
>
> main/find\_package

But I get this error after find\_package command:

```auto
CMake Error in CMakeLists.txt:
  Imported target "my_sort_lib" includes non-existent path

    "/include/sort"

```

The include/sort folder is clearly here:

 ![image](https://discourse.cmake.org/uploads/default/original/2X/5/55f1cd1f4f0b86c4e077654ec0d31fdea35847ee.jpeg)

What do I do wrong?  
I attached also the cmake files:  
[sortdemo-config.cmake](https://discourse.cmake.org/uploads/short-url/cLplL2ekbsPMnLB7f0r3pGKEEuk.cmake) (3.2 KB)  
[sortdemo-config-release.cmake](https://discourse.cmake.org/uploads/short-url/iVoFRMJ5oJVeo7YKuxyXpBShgNL.cmake) (1.4 KB)

```auto
C:\ProgramFiles\
│ sortdemo-config-release.cmake
│ sortdemo-config.cmake
│
├───include
│ ├───print
│ │ print.hpp
│ │
│ └───sort
│ sort.hpp
│
└───lib
        my_print_lib.dll
        my_print_lib.lib
        my_sort_lib.dll
        my_sort_lib.lib

```

---

<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: [June 13, 2022, 4:56pm UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850/2 "2022-06-13T16:56:50Z")

</div>

It means that `sortdemo`'s install interface is not creating the right path. You have this:

```cmake
$<INSTALL_INTERFACE:/include/sort>

```

You want `$<INSTALL_INTERFACE:include/sort>`.

---

<div class="post-metadata">

### Author: ![petrasvestartas](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@petrasvestartas](https://discourse.cmake.org/u/petrasvestartas)
#### Post date: [June 14, 2022, 7:27am UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850/3 "2022-06-14T07:27:16Z")

</div>

Thank you very much, this solves my issue.

---

<div class="post-metadata">

### Author: ![petrasvestartas](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@petrasvestartas](https://discourse.cmake.org/u/petrasvestartas)
#### Post date: [June 15, 2022, 12:50pm UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850/4 "2022-06-15T12:50:48Z")

</div>

Dear @ben.boeckel ,

Do you know why in this project no .dlls are copied after I used the created package using find\_package?

I see only exe:

 ![image](https://discourse.cmake.org/uploads/default/original/2X/0/07664792ce42398cb2cdc237d68ab600c8400338.png)

I suppose to have these two libraries copied:

 ![image](https://discourse.cmake.org/uploads/default/original/2X/5/5cbf85e21bad2f27497b06788e6697d4c59965f9.png)

> **[CMAKE/find\_package at main · petrasvestartas/CMAKE](https://github.com/petrasvestartas/CMAKE/tree/main/find_package)**
>
> main/find\_package

---

<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: [June 15, 2022, 12:59pm UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850/5 "2022-06-15T12:59:54Z")

</div>

I don’t see any install rules for `my_print_lib`.

---

<div class="post-metadata">

### Author: ![petrasvestartas](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@petrasvestartas](https://discourse.cmake.org/u/petrasvestartas)
#### Post date: [June 15, 2022, 1:03pm UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850/6 "2022-06-15T13:03:04Z")

</div>

I thought, I wrote rules in this cmake lists during installation.  
But I believe, installation and using the installed project are two different things.

How you would write a rule that to make it work?

---

<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: [June 15, 2022, 1:23pm UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850/7 "2022-06-15T13:23:10Z")

</div>

Try these arguments:

```cmake
install(TARGETS …
  EXPORT …
  RUNTIME DESTINATION "bin"
  LIBRARY DESTINATION "lib"
  ARCHIVE DESTINATION "lib")

```

---

<div class="post-metadata">

### Author: ![petrasvestartas](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@petrasvestartas](https://discourse.cmake.org/u/petrasvestartas)
#### Post date: [June 15, 2022, 1:58pm UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850/8 "2022-06-15T13:58:35Z")

</div>

> [@ben.boeckel](#):
>
> ```auto
> RUNTIME DESTINATION "bin"
> LIBRARY DESTINATION "lib"
> ARCHIVE DESTINATION "lib"
> 
> ```

It does not work…

---

<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: [June 15, 2022, 3:18pm UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850/9 "2022-06-15T15:18:18Z")

</div>

How does it not work?

---

<div class="post-metadata">

### Author: ![petrasvestartas](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@petrasvestartas](https://discourse.cmake.org/u/petrasvestartas)
#### Post date: [June 15, 2022, 3:40pm UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850/10 "2022-06-15T15:40:07Z")

</div>

It copies files to bin folder during installation in the _install\_export_ project, this part all good:

> **[CMAKE/install\_export at main · petrasvestartas/CMAKE](https://github.com/petrasvestartas/CMAKE/tree/main/install_export)**
>
> main/install\_export

But when I configure and build second project “find\_package” using **find\_package(…)** dlls are not copied to release folder:

> **[CMAKE/find\_package at main · petrasvestartas/CMAKE](https://github.com/petrasvestartas/CMAKE/tree/main/find_package)**
>
> main/find\_package

---

<div class="post-metadata">

### Author: ![petrasvestartas](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@petrasvestartas](https://discourse.cmake.org/u/petrasvestartas)
#### Post date: [June 15, 2022, 5:01pm UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850/11 "2022-06-15T17:01:20Z")

</div>

Dear @ben.boeckel ,

I recorded what happens in my pc.  
The .dll do not get copied. Please take a look of this short video, where I need manually copy the files:

[![](https://discourse.cmake.org/uploads/default/original/2X/9/985440299f5666d02b79490fd6f5509ffde51da3.jpeg "2022 06 15 18 53 07") ](https://www.youtube.com/watch?v=0W5ghrSMgWM)

---

<div class="post-metadata">

### Author: ![petrasvestartas](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@petrasvestartas](https://discourse.cmake.org/u/petrasvestartas)
#### Post date: [June 16, 2022, 10:50am UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850/12 "2022-06-16T10:50:38Z")

</div>

Anyone?

---

<div class="post-metadata">

### Author: ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)
#### Post date: [June 16, 2022, 11:08am UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850/13 "2022-06-16T11:08:52Z")

</div>

If I understand you correctly, you’d like the build to somehow copy all the found DLLs into your build directory.  
This is not how things work. You need to set the right execution environment in your IDE, so that all the needed DLLs are in your PATH.

---

<div class="post-metadata">

### Author: ![petrasvestartas](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@petrasvestartas](https://discourse.cmake.org/u/petrasvestartas)
#### Post date: [June 16, 2022, 11:48am UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850/14 "2022-06-16T11:48:04Z")

</div>

Thank you for an answer.

Could you show an example?  
I think I am lost.

---

<div class="post-metadata">

### Author: ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)
#### Post date: [June 16, 2022, 1:38pm UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850/15 "2022-06-16T13:38:31Z")

</div>

I have no idea where one configures this in VSCode (which seems to be what you’re using).  
IDEs normally have “Enviroment (variables)” section somewhere in the same window where you configure your target.

If you’re only using terminal, simple `set PATH=%PATH%;C:\Program Files\whatever` would suffice and you’ll be able to run your project.

---

<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: [June 16, 2022, 7:47pm UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850/16 "2022-06-16T19:47:05Z")

</div>

You can either set up `PATH` for any tests or you can use something like `file(GET_RUNTIME_DEPENDENCIES)` to discover DLLs to then copy them as needed.

---

<div class="post-metadata">

### Author: ![petrasvestartas](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@petrasvestartas](https://discourse.cmake.org/u/petrasvestartas)
#### Post date: [June 16, 2022, 9:18pm UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850/17 "2022-06-16T21:18:57Z")

</div>

Can you show full code of GET\_RUNTIME\_DEPENDENCIES, this is what I tried already:

This does not copy any dlls

```auto
include(GNUInstallDirs )
install(
    TARGETS "example" 
    RUNTIME_DEPENDENCIES 
    )

```

This gives me error

```auto
include(GNUInstallDirs )
install(
    TARGETS "example" 
    RUNTIME_DEPENDENCIES "sortdemo::my_sort_lib"
    )

```

Error:

```auto
CMake Error at CMakeLists.txt:28 (install):
  install TARGETS given unknown argument "sortdemo::my_sort_lib".

```

---

<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: [July 9, 2022, 1:03pm UTC](https://discourse.cmake.org/t/what-it-means-imported-target-my-sort-lib-includes-non-existent-path/5850/18 "2022-07-09T13:03:34Z")

</div>

@kyle.edwards might have examples handy. Searching on Discourse here should also bring up prior discussion.
