1message(STATUS "Installing bundled mingw libraries")
2
3if ("${CMAKE_BINARY_DIR}" STREQUAL "")
4  set(CMAKE_BINARY_DIR ".")
5endif ()
6
7set (mingw_bundle_dlls "${CMAKE_BINARY_DIR}/../mingw/tools/mingw-bundle-dlls")
8file(GLOB opencpn_exe "${CMAKE_BINARY_DIR}/*opencpn.exe")
9execute_process(
10    COMMAND python3 ${mingw_bundle_dlls} ${opencpn_exe}
11    OUTPUT_VARIABLE MINGW_LIBS
12)
13string(REPLACE "\n" ";" MINGW_LIBS ${MINGW_LIBS})
14
15if ("$ENV{DESTDIR}" STREQUAL "")
16    set (install_dir ${CMAKE_INSTALL_PREFIX})
17else ()
18    set (install_dir $ENV{DESTDIR}/${CMAKE_INSTALL_PREFIX})
19endif ()
20
21message(STATUS "Installing mingw runtime libs in ${install_dir}")
22file (COPY ${MINGW_LIBS} DESTINATION "${install_dir}")
23