What it means? Imported target "my_sort_lib" includes non-existent path

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:

This is the project where I try to use find_package method:

But I get this error after find_package command:

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

    "/include/sort"

The include/sort folder is clearly here:

What do I do wrong?
I attached also the cmake files:
sortdemo-config.cmake (3.2 KB)
sortdemo-config-release.cmake (1.4 KB)

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

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

$<INSTALL_INTERFACE:/include/sort>

You want $<INSTALL_INTERFACE:include/sort>.

1 Like

Thank you very much, this solves my issue.

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:

I suppose to have these two libraries copied:

I don’t see any install rules for my_print_lib.

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?

Try these arguments:

install(TARGETS …
  EXPORT …
  RUNTIME DESTINATION "bin"
  LIBRARY DESTINATION "lib"
  ARCHIVE DESTINATION "lib")
1 Like

It does not work…

How does it not work?

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

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

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:

Anyone?

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.

Thank you for an answer.

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

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.

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.

Can you show full code of GET_RUNTIME_DEPENDENCIES, this is what I tried already:

This does not copy any dlls

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

This gives me error

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

Error:

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

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