What is the defacto way of handling implicit linking in CMake projects?
In windows, .dll
's are linked during runtime, thus CMake only needs to link the .lib
files during compilation. This is better done using find_package
. However, during compilation, CMake never copies over the .dll
corresponding to the linked .lib
file to the linked executable's output path.
Is this something that CMake leaves up to the user?
It seems kind of messy, not to mention non-cross platform, to have to manually find dll
's for each library you link and either manually copy them over to your output directory or write individual CMake commands, as shown below, to do this per package you find/library you link.
add_custom_command(
TARGET MyTarget POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_SOURCE_DIR}/libs/SDL2.dll"
$<TARGET_FILE_DIR:MyTarget>
)