I ported my cross-platform, modern CMake-based application to use Conan library packages with transparent integration (conan_paths.cmake). Build and tests are good.
When I run the installer (cmake --install | build INSTALL project), everything is installed into the correct location. Now I need to include the new Conan libraries.
Since imported targets cannot be directly installed via cmake install(), I use workarounds such as:
install(
PROGRAMS $<TARGET_FILE:sometarget>
DESTINATION ${CMAKE_INSTALL_BINDIR}
)
However, since the Conan library targets are imported as INTERFACE, those generator expressions don't work with _libname::libname_ targets defined in the generated Find_libname_ scripts. Using "$ I read the following: Short of using a python script to convert the json deployment file into a cmake include with install(), I don't see any direct/easy way to deploy the Conan libraries. What is the most efficient way to install Conan libaries along side my application for deployment?
Hi @glennaycock
I think we need to understand the case a bit better, not fully sure I understood it. Let me summarize:
conanfile.txt to install dependencies.cmake_paths generator, but at some point you are talking about the generated Find_libname scripts. Conan has the generator cmake_find_package and cmake_find_package_multi that generate these scripts on the fly, for every package, even if the origin package does not use CMake at all. Are you talking about these files, the Conan cmake_find_package generated files, or the files generated by CMake inside the packages?cmake_paths, but the cmake_find_package generator?If that is the case, maybe you want to have a look to the imports functionality ([imports] in conanfile.txt,imports()in conanfile.py). With that you can define which files are imported from the cache to the local folder, with which patterns (*.dll), and how. This copy will be done automatically when you executeconan install``. Have a look to https://docs.conan.io/en/latest/using_packages/conanfile_txt.html#imports.
@memsharded,
Thanks for the quick response. I am responding to your summary points below:
Hi @glennaycock
Ok, then. I think now I understand it better:
imports() method: https://docs.conan.io/en/latest/reference/conanfile/methods.html#imports, to get a copy of the DLLs and other stuff you might need from the Conan cache.Let me know if that works ok. Thanks!
This led me down a path I didn't intend to take. I had to complete the conan build of my application, which I never intended to use, in order for imports() to work. In the course of doing so, I got side tracked trying to fix my other conan package.
I don't think static linking is going to work in the short term.
Hi @glennaycock
Sorry I didn't fully understand. I got that static linking is not going to work.
But I didn't get:
I had to complete the conan build of my application, which I never intended to use, in order for imports() to work.
Could you please clarify? Can you tell why imports() will not copy the DLLs or shared libraries from the packages to your local folder?
I'll hijack this thread as i've recently stumbled upon this issue myself
I think the question is about easy global installation of conanfile targets (libs/bins) that are required for runtime to a designated prefix
In cmake current best way to achieve that is to add custom install step that executes
conan imports ${CMAKE_SOURCE_DIR}/conanfile.txt -imf ${CMAKE_INSTALL_PREFIX}
@memsharded would this be the best recommended way ?
I have the same problem.
Project 1 Use Conan management to generate a .dll file and header file for use in other projects.
Project 2 only uses the product of Project 1, a .dll file and some header files.
If I define the imports function in the conanfile.py of project 2, I can copy the dynamic library of project 1 to the CMake cache directory.
But when I execute cmake install, it cannot install the files imported into the cache to the CMAKE_INSTALL_PREFIX folder that I specified when I initialized CMake.
@nmgwddj
I'm doing it via custom target
add_custom_target(
conan-install
COMMAND conan imports ${CMAKE_SOURCE_DIR}/conanfile.py -imf ${CMAKE_INSTALL_PREFIX}
)
Most helpful comment
I'll hijack this thread as i've recently stumbled upon this issue myself
I think the question is about easy global installation of conanfile targets (libs/bins) that are required for runtime to a designated prefix
In cmake current best way to achieve that is to add custom install step that executes
conan imports ${CMAKE_SOURCE_DIR}/conanfile.txt -imf ${CMAKE_INSTALL_PREFIX}@memsharded would this be the best recommended way ?