3

I have a CMake project where I link with fmt::fmt which is specified in the conanfile.py and installed and all cmake config files have been generated by Conan and been used by CMake, so far all good. (I use from conan.tools.cmake import CMakeDeps, CMakeToolchain, CMake

I try to copy all transitive dependencies of my target tgt with https://cmake.org/cmake/help/git-stage/manual/cmake-generator-expressions.7.html#genex:TARGET_RUNTIME_DLLS (I know about conan‘s import feature but I wanted to give it a try with CMake!)

add_executable(exe main.c)
target_link_libraries(exe PRIVATE otherTarget fmt::fmt)
add_custom_command(TARGET exe POST_BUILD
  COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:exe> $<TARGET_FILE_DIR:exe>
  COMMAND_EXPAND_LISTS
  )

Strangely, the otherTarget.dll will be copyied to the Exe. But fmt::fmt dll is not copied, because something is either wrongly setup in the generated files? Conan however sets IMPORTED_LOCATION to the .../lib/fmtd.lib on the referencing targets of fmt::fmt, and I suspect CMake does not include it in TARGET_RUNTIME_DLLS because only .dll files are treated?

Does anybody know whats going on here?

Gabriel
  • 8,990
  • 6
  • 57
  • 101
  • "generated by Coban" - typo? – Кое Кто Jul 05 '22 at 14:38
  • I'm curious about what the purpose of the copy is. CMake links the source fmt to the exe and not the copy fmt to the exe (right?)... If the purpose is related to installation and bundling dependendcies with an installation, you may be interested in https://stackoverflow.com/a/68487506/11107541 – starball Jul 20 '22 at 10:14
  • Its all about bundling an installation – Gabriel Jul 22 '22 at 14:52

0 Answers0