Skip to content

Commit f0620ba

Browse files
committed
compile app with compiler runtime.
This fixes and issue where users are required to download mingw dll's because they weren't shipped with app
1 parent b63804f commit f0620ba

File tree

2 files changed

+20
-39
lines changed

2 files changed

+20
-39
lines changed

CMakeLists.txt

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,35 @@ if (WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Release")
8383
get_target_property(_qt_qmake_executable Qt6::qmake IMPORTED_LOCATION)
8484
get_filename_component(_qt_bin_dir "${_qt_qmake_executable}" DIRECTORY)
8585
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}")
86+
8687
if (WINDEPLOYQT_EXECUTABLE)
8788
set(_deploy_dir "${CMAKE_SOURCE_DIR}/release")
89+
8890
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
91+
COMMAND "${CMAKE_COMMAND}" -E remove_directory "${_deploy_dir}"
8992
COMMAND "${CMAKE_COMMAND}" -E make_directory "${_deploy_dir}"
90-
COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:${TARGET_NAME}>" "${_deploy_dir}/$<TARGET_FILE_NAME:${TARGET_NAME}>"
91-
COMMAND "${WINDEPLOYQT_EXECUTABLE}"
93+
COMMAND "${CMAKE_COMMAND}" -E copy
94+
"$<TARGET_FILE:${TARGET_NAME}>"
9295
"${_deploy_dir}/$<TARGET_FILE_NAME:${TARGET_NAME}>"
96+
97+
COMMAND "${WINDEPLOYQT_EXECUTABLE}"
98+
--release
9399
--qmldir "${CMAKE_SOURCE_DIR}/qml"
94-
--no-compiler-runtime
95100
--no-translations
96101
--no-system-d3d-compiler
97102
--no-opengl-sw
98-
COMMAND cmd /c if exist "${CMAKE_SOURCE_DIR}/installer/clean_release.bat" call "${CMAKE_SOURCE_DIR}/installer/clean_release.bat" "${_deploy_dir}"
99-
COMMAND cmd /c if exist "${CMAKE_SOURCE_DIR}/installer/user_post_deploy.bat" call "${CMAKE_SOURCE_DIR}/installer/user_post_deploy.bat" "${_deploy_dir}" "${PROJECT_VERSION}"
103+
--skip-plugin-types qmltooling,generic
104+
"${_deploy_dir}/$<TARGET_FILE_NAME:${TARGET_NAME}>"
105+
106+
COMMAND cmd /c if exist
107+
"${CMAKE_SOURCE_DIR}/installer/clean_release.bat"
108+
call "${CMAKE_SOURCE_DIR}/installer/clean_release.bat" "${_deploy_dir}"
109+
110+
COMMAND cmd /c if exist
111+
"${CMAKE_SOURCE_DIR}/installer/user_post_deploy.bat"
112+
call "${CMAKE_SOURCE_DIR}/installer/user_post_deploy.bat"
113+
"${_deploy_dir}" "${PROJECT_VERSION}"
114+
100115
COMMENT "Running windeployqt for ${TARGET_NAME} (release folder)"
101116
)
102117
else()

installer/installer/installer.nsi

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -127,40 +127,6 @@ Section "Main Application" SecMain
127127
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "InstallDate" $0
128128
SectionEnd
129129

130-
; Optional VC++ Redistributable Section (unchecked by default)
131-
Section /o "Microsoft Visual C++ Redistributable" SecVCRedist
132-
DetailPrint "Downloading Microsoft Visual C++ Redistributable..."
133-
134-
; Download the VC++ redistributable to temp directory
135-
NSISdl::download "https://aka.ms/vs/17/release/vc_redist.x64.exe" "$TEMP\vc_redist.x64.exe"
136-
Pop $0 ; get the return value
137-
138-
; Check if download was successful
139-
StrCmp $0 success download_success
140-
MessageBox MB_ICONSTOP "Download failed: $0"
141-
Goto download_end
142-
143-
download_success:
144-
DetailPrint "Installing Microsoft Visual C++ Redistributable..."
145-
146-
; Run the redistributable installer silently
147-
ExecWait '"$TEMP\vc_redist.x64.exe" /install /passive /norestart' $0
148-
149-
; Check installation result
150-
${If} $0 == 0
151-
DetailPrint "Microsoft Visual C++ Redistributable installed successfully"
152-
${ElseIf} $0 == 1638
153-
DetailPrint "Microsoft Visual C++ Redistributable is already installed (newer or same version)"
154-
${Else}
155-
DetailPrint "Microsoft Visual C++ Redistributable installation failed (Exit code: $0)"
156-
${EndIf}
157-
158-
; Clean up downloaded file
159-
Delete "$TEMP\vc_redist.x64.exe"
160-
161-
download_end:
162-
SectionEnd
163-
164130
;--------------------------------
165131
; Section descriptions
166132
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN

0 commit comments

Comments
 (0)