Hi community,
This topic is about the usage of $<TARGET_RUNTIME_DLLS:tgt> but there is a slight possibility that I’ve misunderstood something in the documentation, that states the following:
List of DLLs that the target depends on at runtime. This is determined by the locations of all the SHARED and MODULE targets in the target’s transitive dependencies.
So, let’s suppose that I have a CMake project that consist of three targets:
- a shared library created with
add_library(mylib SHARED ...). (Static library usage is omitted now for brevity) - a module created with
add_library(mymodule MODULE ...) - an executable created with
add_executable(myapp ...)
Furthermore
-
myapplinks to the shared librarymylib:target_link_libraries(myapp PRIVATE mylib) -
myapploadsmymoduleat runtime
The task is to copy all of the runtime parts (myapp.exe, mylib.dll, mymodule.dll) into one directory. Applying the example code (see below) from the documentation of $<TARGET_RUNTIME_DLLS:tgt> to my situation works well, if there is no MODULE, just the application and the shared library.
add_custom_command(TARGET exe POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:exe> $<TARGET_FILE_DIR:exe>
COMMAND_EXPAND_LISTS
)
According to the documentation, MODULE dependencies could be somehow gathered with $<TARGET_RUNTIME_DLLS>, the question is, how can I set the dependency?
I’ve checked the following with cmake-3.22.3:
-
target_link_librarieswill not work if the dependency is aMODULE. -
add_dependencieswill not insert a new dependency tomymodule.dllso it is not copied
Any help is highly appreciated!
Thank you!