cmake-conan icon indicating copy to clipboard operation
cmake-conan copied to clipboard

support installing conan libraries along with the project

Open maddanio opened this issue 5 years ago • 4 comments
trafficstars

i.e. we would like to build conan libraries shared and install them along with the project. including proper rpath patching. that way the libraries when using cpack would end up in the package. now when we build shared the resulting executables depend on files in ~/.conan, which will not be present on the deployed-to machines. is this possible?

maddanio avatar Mar 04 '20 17:03 maddanio

Hi @maddanio, Have you tried to use imports ? Maybe doing something like:

set ( CONANIMPORTS
   "bin, *.dll -> ./bin"
   "lib, *.lib -> ./lib"
)

include(conan.cmake)
message("${CMAKE_BUILD_TYPE}")
conan_cmake_run(REQUIRES zlib/1.2.8
                IMPORTS ${CONANIMPORTS}
                BASIC_SETUP CMAKE_TARGETS
                BUILD missing)

add_executable(main main.cpp)
target_link_libraries(main CONAN_PKG::zlib)

Please tell me if this helps.

czoido avatar Mar 11 '20 16:03 czoido

conanfile.txt have an own [imports] section. Can't we make use of this, instead of having to list imports in the CMake file? 🤔

Croydon avatar Mar 15 '20 18:03 Croydon

Having a quick look into the source, yes, it should be possible.

I can't get even one of both variants to work for some reason

Croydon avatar Mar 15 '20 19:03 Croydon

My imports work when executing conan install . in the terminal, but I can't get it working through CMake

Croydon avatar Mar 15 '20 19:03 Croydon