Skip to content

Commit 62a6e75

Browse files
committed
automatically copy windows dll dependencies into the exe output directory
1 parent 62a015d commit 62a6e75

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

cmake/fips.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ macro(fips_begin_app target type)
275275
fips_config_output_directory(${target})
276276
fips_config_postfixes_for_exe(${target})
277277
fips_msvc_add_target_properties(${target})
278+
fips_windows_copy_target_dlls(${target})
278279
fips_android_postbuildstep(${target})
279280
fips_add_to_targets_list(${target} "app")
280281
else()

cmake/fips_platform.cmake

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#-------------------------------------------------------------------------------
55

66
#-------------------------------------------------------------------------------
7-
# fips_vs_apply_options()
7+
# fips_msvc_apply_options()
88
# Applies the module-specific options set between begin/end, plus
99
# any other MSVC specific target options.
1010
#
@@ -16,6 +16,23 @@ macro(fips_msvc_add_target_properties target)
1616
endif()
1717
endmacro()
1818

19+
#-------------------------------------------------------------------------------
20+
# fips_windows_copy_target_dlls()
21+
# On Windows, copy any DLLs linked to the target into the target output
22+
# directory.
23+
#
24+
# See: https://discourse.cmake.org/t/how-to-copy-dlls-to-binary-directory/10154
25+
#-------------------------------------------------------------------------------
26+
macro(fips_windows_copy_target_dlls target)
27+
if (FIPS_WINDOWS)
28+
add_custom_command (
29+
TARGET "${target}" POST_BUILD
30+
COMMAND "${CMAKE_COMMAND}" -E copy -t "$<TARGET_FILE_DIR:${target}>"
31+
"$<TARGET_RUNTIME_DLLS:${target}>" USES_TERMINAL COMMAND_EXPAND_LISTS
32+
)
33+
endif()
34+
endmacro()
35+
1936
#-------------------------------------------------------------------------------
2037
# fips_frameworks_osx(frameworks ...)
2138
# OSX specific: Add one or more OSX frameworks for linking with the

0 commit comments

Comments
 (0)