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
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)
│ │ print.hpp
It means that
sortdemo's install interface is not creating the right path. You have this:
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
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:
RUNTIME DESTINATION "bin"
LIBRARY DESTINATION "lib"
ARCHIVE DESTINATION "lib")
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:
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
This gives me error
CMake Error at CMakeLists.txt:28 (install):
install TARGETS given unknown argument "sortdemo::my_sort_lib".