MSYS2: automatically copy dlls as part of build
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 29 Jul 2017 10:28:12 +0000 (20:28 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 29 Jul 2017 10:28:12 +0000 (20:28 +1000)
CMakeLists.txt
contrib/CMakeLists.txt
plugins/CMakeLists.txt
radiant/CMakeLists.txt

index 78efba9..626e15d 100644 (file)
@@ -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 '$<TARGET_FILE:${target}>' | grep -v /c/Windows | awk '{ print $1 }' | while read dll; do cp \"$(which $dll)\" '${PROJECT_BINARY_DIR}'; done"
+            VERBATIM
+        )
+    endif ()
+endmacro()
+
 #-----------------------------------------------------------------------
 # Libraries
 #-----------------------------------------------------------------------
index 7899526..9802014 100644 (file)
@@ -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)
index 134902e..bc9fcad 100644 (file)
@@ -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)
index 958384c..287cc95 100644 (file)
@@ -128,3 +128,5 @@ target_link_libraries(radiant
 if (X11_LIBRARIES)
     target_link_libraries(radiant ${X11_LIBRARIES})
 endif ()
+
+copy_dlls(radiant)