diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f0927286803bab1cd4165c9a0399b002c8f8351..338f66c136e42b867289f654a824b752cb9e4452 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) -find_package(Qt5 REQUIRED COMPONENTS +find_package(Qt5 REQUIRED COMPONENTS Widgets SerialPort PrintSupport @@ -105,9 +105,9 @@ target_link_libraries(groundstation PUBLIC Qt5::3DInput Mavlink::Mavlink ) -if(APPLE) - set_target_properties(groundstation PROPERTIES MACOSX_BUNDLE TRUE) -endif() +if (APPLE) + set_target_properties(groundstation PROPERTIES MACOSX_BUNDLE TRUE) +endif () add_backward(groundstation) @@ -116,5 +116,19 @@ if (UNIX) set(BACKWARD_HAS_LIBUNWIND 1) endif (UNIX) + +if (DEFINED ENV{WIN_DEPLOY_QT}) + message("-- Using windeployqt.exe from $ENV{WIN_DEPLOY_QT}") + # Execute windeployqt.exe in the binary directory after every build. + # It adds all the necessary data in the directory to run the executable without external dependencies. + # Reference: https://doc.qt.io/qt-5/windows-deployment.html#the-windows-deployment-tool + add_custom_command( + TARGET groundstation POST_BUILD + COMMAND $ENV{WIN_DEPLOY_QT} groundstation.exe + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Running windeployqt.exe..." + ) +endif () + # For now we keep debug information on set(CMAKE_BUILD_TYPE RelWithDebInfo)