From: TimePath Date: Sat, 29 Jul 2017 10:28:12 +0000 (+1000) Subject: MSYS2: automatically copy dlls as part of build X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=commitdiff_plain;h=3c2e453ecacf62a8505c61541e735368ae462d08 MSYS2: automatically copy dlls as part of build --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 78efba94..626e15da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,6 +105,16 @@ endif () include_directories("${PROJECT_SOURCE_DIR}/include") include_directories("${PROJECT_SOURCE_DIR}/libs") +macro(copy_dlls target) + if (WIN32) + add_custom_command(TARGET ${target} POST_BUILD + COMMAND bash + ARGS -c "ldd '$' | grep -v /c/Windows | awk '{ print $1 }' | while read dll; do cp \"$(which $dll)\" '${PROJECT_BINARY_DIR}'; done" + VERBATIM + ) + endif () +endmacro() + #----------------------------------------------------------------------- # Libraries #----------------------------------------------------------------------- diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 7899526f..98020146 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -5,6 +5,7 @@ macro(radiant_plugin name) message(STATUS "Found Plugin ${name}") add_library(${name} MODULE ${ARGN}) add_dependencies(plugins ${name}) + copy_dlls(${name}) endmacro() add_subdirectory(bobtoolz) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 134902e4..bc9fcad3 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -5,6 +5,7 @@ macro(radiant_plugin name) message(STATUS "Found Module ${name}") add_library(${name} MODULE ${ARGN}) add_dependencies(modules ${name}) + copy_dlls(${name}) endmacro() add_subdirectory(archivepak) diff --git a/radiant/CMakeLists.txt b/radiant/CMakeLists.txt index 958384cc..287cc951 100644 --- a/radiant/CMakeLists.txt +++ b/radiant/CMakeLists.txt @@ -128,3 +128,5 @@ target_link_libraries(radiant if (X11_LIBRARIES) target_link_libraries(radiant ${X11_LIBRARIES}) endif () + +copy_dlls(radiant)