diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 481801b7e3..64c5ad998d 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -446,7 +446,6 @@ if (MSVC) add_custom_command(TARGET ResInsight POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ ) - list(APPEND RI_DLL_FILENAMES $) endforeach(qtlib) else() set (QTLIBLIST QtCore4 QtCored4 QtGui4 QtGuid4 QtOpenGl4 QtOpenGld4 QtNetwork4 QtNetworkd4 QtScript4 QtScriptd4 QtScriptTools4 QtScriptToolsd4) @@ -535,6 +534,51 @@ if (RESINSIGHT_PRIVATE_INSTALL) set (RESINSIGHT_FILES ${RI_DLL_FILENAMES}) + if(Qt5_FOUND AND WIN32 AND TARGET Qt5::qmake AND NOT TARGET Qt5::windeployqt) + get_target_property(_qt5_qmake_location Qt5::qmake IMPORTED_LOCATION) + + execute_process( + COMMAND "${_qt5_qmake_location}" -query QT_INSTALL_PREFIX + RESULT_VARIABLE return_code + OUTPUT_VARIABLE qt5_install_prefix + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + set(imported_location "${qt5_install_prefix}/bin/windeployqt.exe") + + if(EXISTS ${imported_location}) + add_executable(Qt5::windeployqt IMPORTED) + + set_target_properties(Qt5::windeployqt PROPERTIES + IMPORTED_LOCATION ${imported_location} + ) + endif() + endif() + + # TODO(wjwwood): find a way to make this optional or to run without "deploying" the + # necessary dlls and stuff to the bin folder. + # see: + # https://stackoverflow.com/questions/41193584/deploy-all-qt-dependencies-when-building#41199492 + if(TARGET Qt5::windeployqt) + # execute windeployqt in a tmp directory after build + add_custom_command(TARGET ResInsight + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/windeployqt" + COMMAND set PATH=%PATH%$${qt5_install_prefix}/bin + COMMAND + Qt5::windeployqt + --dir "${CMAKE_CURRENT_BINARY_DIR}/windeployqt" + "$/$" + ) + + # copy deployment directory during installation + install( + DIRECTORY + "${CMAKE_CURRENT_BINARY_DIR}/windeployqt/" + DESTINATION ${RESINSIGHT_INSTALL_FOLDER} + ) + endif() + # CRT set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP ON) set(CMAKE_INSTALL_OPENMP_LIBRARIES ON)