Skip to content

Commit 356545f

Browse files
refactor(installer/windows): move nsis code (#3915)
1 parent 883eff5 commit 356545f

File tree

3 files changed

+80
-71
lines changed

3 files changed

+80
-71
lines changed

cmake/packaging/windows.cmake

Lines changed: 5 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# windows specific packaging
2-
3-
# see options at: https://cmake.org/cmake/help/latest/cpack_gen/nsis.html
42
install(TARGETS sunshine RUNTIME DESTINATION "." COMPONENT application)
53

64
# Hardening: include zlib1.dll (loaded via LoadLibrary() in openssl's libcrypto.a)
@@ -52,79 +50,11 @@ cmake_path(CONVERT "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/assets/shaders"
5250
cmake_path(CONVERT "${CMAKE_BINARY_DIR}/assets/shaders" TO_NATIVE_PATH_LIST shaders_in_build_dest_native)
5351
execute_process(COMMAND cmd.exe /c mklink /J "${shaders_in_build_dest_native}" "${shaders_in_build_src_native}")
5452

55-
# set(CPACK_NSIS_MUI_HEADERIMAGE "") # TODO: image should be 150x57 bmp
5653
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}\\\\sunshine.ico")
57-
set(CPACK_NSIS_INSTALLED_ICON_NAME "${PROJECT__DIR}\\\\${PROJECT_EXE}")
54+
5855
# The name of the directory that will be created in C:/Program files/
5956
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
6057

61-
# Extra install commands
62-
# Restores permissions on the install directory
63-
# Migrates config files from the root into the new config folder
64-
# Install service
65-
SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
66-
"${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}
67-
IfSilent +2 0
68-
ExecShell 'open' 'https://docs.lizardbyte.dev/projects/sunshine'
69-
nsExec::ExecToLog 'icacls \\\"$INSTDIR\\\" /reset'
70-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\update-path.bat\\\" add'
71-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\migrate-config.bat\\\"'
72-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\add-firewall-rule.bat\\\"'
73-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\install-gamepad.bat\\\"'
74-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\install-service.bat\\\"'
75-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\autostart-service.bat\\\"'
76-
NoController:
77-
")
78-
79-
# Extra uninstall commands
80-
# Uninstall service
81-
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
82-
"${CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS}
83-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\delete-firewall-rule.bat\\\"'
84-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\uninstall-service.bat\\\"'
85-
nsExec::ExecToLog '\\\"$INSTDIR\\\\${CMAKE_PROJECT_NAME}.exe\\\" --restore-nvprefs-undo'
86-
MessageBox MB_YESNO|MB_ICONQUESTION \
87-
'Do you want to remove Virtual Gamepad?' \
88-
/SD IDNO IDNO NoGamepad
89-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\uninstall-gamepad.bat\\\"'; skipped if no
90-
NoGamepad:
91-
MessageBox MB_YESNO|MB_ICONQUESTION \
92-
'Do you want to remove $INSTDIR (this includes the configuration, cover images, and settings)?' \
93-
/SD IDNO IDNO NoDelete
94-
RMDir /r \\\"$INSTDIR\\\"; skipped if no
95-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\update-path.bat\\\" remove'
96-
NoDelete:
97-
")
98-
99-
# Adding an option for the start menu
100-
set(CPACK_NSIS_MODIFY_PATH OFF)
101-
set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
102-
# This will be shown on the installed apps Windows settings
103-
set(CPACK_NSIS_INSTALLED_ICON_NAME "${CMAKE_PROJECT_NAME}.exe")
104-
set(CPACK_NSIS_CREATE_ICONS_EXTRA
105-
"${CPACK_NSIS_CREATE_ICONS_EXTRA}
106-
SetOutPath '\$INSTDIR'
107-
CreateShortCut '\$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\${CMAKE_PROJECT_NAME}.lnk' \
108-
'\$INSTDIR\\\\${CMAKE_PROJECT_NAME}.exe' '--shortcut'
109-
")
110-
set(CPACK_NSIS_DELETE_ICONS_EXTRA
111-
"${CPACK_NSIS_DELETE_ICONS_EXTRA}
112-
Delete '\$SMPROGRAMS\\\\$MUI_TEMP\\\\${CMAKE_PROJECT_NAME}.lnk'
113-
")
114-
115-
# Checking for previous installed versions
116-
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON")
117-
118-
set(CPACK_NSIS_HELP_LINK "https://docs.lizardbyte.dev/projects/sunshine/latest/md_docs_2getting__started.html")
119-
set(CPACK_NSIS_URL_INFO_ABOUT "${CMAKE_PROJECT_HOMEPAGE_URL}")
120-
set(CPACK_NSIS_CONTACT "${CMAKE_PROJECT_HOMEPAGE_URL}/support")
121-
122-
set(CPACK_NSIS_MENU_LINKS
123-
"https://docs.lizardbyte.dev/projects/sunshine" "Sunshine documentation"
124-
"https://app.lizardbyte.dev" "LizardByte Web Site"
125-
"https://app.lizardbyte.dev/support" "LizardByte Support")
126-
set(CPACK_NSIS_MANIFEST_DPI_AWARE true)
127-
12858
# Setting components groups and dependencies
12959
set(CPACK_COMPONENT_GROUP_CORE_EXPANDED true)
13060

@@ -165,3 +95,7 @@ set(CPACK_COMPONENT_FIREWALL_GROUP "Scripts")
16595
set(CPACK_COMPONENT_GAMEPAD_DISPLAY_NAME "Virtual Gamepad")
16696
set(CPACK_COMPONENT_GAMEPAD_DESCRIPTION "Scripts to install and uninstall Virtual Gamepad.")
16797
set(CPACK_COMPONENT_GAMEPAD_GROUP "Scripts")
98+
99+
# include specific packaging
100+
include(${CMAKE_MODULE_PATH}/packaging/windows_nsis.cmake)
101+
include(${CMAKE_MODULE_PATH}/packaging/windows_wix.cmake)

cmake/packaging/windows_nsis.cmake

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# NSIS Packaging
2+
# see options at: https://cmake.org/cmake/help/latest/cpack_gen/nsis.html
3+
4+
set(CPACK_NSIS_INSTALLED_ICON_NAME "${PROJECT__DIR}\\\\${PROJECT_EXE}")
5+
6+
# Extra install commands
7+
# Restores permissions on the install directory
8+
# Migrates config files from the root into the new config folder
9+
# Install service
10+
SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
11+
"${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}
12+
IfSilent +2 0
13+
ExecShell 'open' 'https://docs.lizardbyte.dev/projects/sunshine'
14+
nsExec::ExecToLog 'icacls \\\"$INSTDIR\\\" /reset'
15+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\update-path.bat\\\" add'
16+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\migrate-config.bat\\\"'
17+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\add-firewall-rule.bat\\\"'
18+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\install-gamepad.bat\\\"'
19+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\install-service.bat\\\"'
20+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\autostart-service.bat\\\"'
21+
NoController:
22+
")
23+
24+
# Extra uninstall commands
25+
# Uninstall service
26+
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
27+
"${CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS}
28+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\delete-firewall-rule.bat\\\"'
29+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\uninstall-service.bat\\\"'
30+
nsExec::ExecToLog '\\\"$INSTDIR\\\\${CMAKE_PROJECT_NAME}.exe\\\" --restore-nvprefs-undo'
31+
MessageBox MB_YESNO|MB_ICONQUESTION \
32+
'Do you want to remove Virtual Gamepad?' \
33+
/SD IDNO IDNO NoGamepad
34+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\uninstall-gamepad.bat\\\"'; skipped if no
35+
NoGamepad:
36+
MessageBox MB_YESNO|MB_ICONQUESTION \
37+
'Do you want to remove $INSTDIR (this includes the configuration, cover images, and settings)?' \
38+
/SD IDNO IDNO NoDelete
39+
RMDir /r \\\"$INSTDIR\\\"; skipped if no
40+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\update-path.bat\\\" remove'
41+
NoDelete:
42+
")
43+
44+
# Adding an option for the start menu
45+
set(CPACK_NSIS_MODIFY_PATH OFF)
46+
set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
47+
# This will be shown on the installed apps Windows settings
48+
set(CPACK_NSIS_INSTALLED_ICON_NAME "${CMAKE_PROJECT_NAME}.exe")
49+
set(CPACK_NSIS_CREATE_ICONS_EXTRA
50+
"${CPACK_NSIS_CREATE_ICONS_EXTRA}
51+
SetOutPath '\$INSTDIR'
52+
CreateShortCut '\$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\${CMAKE_PROJECT_NAME}.lnk' \
53+
'\$INSTDIR\\\\${CMAKE_PROJECT_NAME}.exe' '--shortcut'
54+
")
55+
set(CPACK_NSIS_DELETE_ICONS_EXTRA
56+
"${CPACK_NSIS_DELETE_ICONS_EXTRA}
57+
Delete '\$SMPROGRAMS\\\\$MUI_TEMP\\\\${CMAKE_PROJECT_NAME}.lnk'
58+
")
59+
60+
# Checking for previous installed versions
61+
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON")
62+
63+
set(CPACK_NSIS_HELP_LINK "https://docs.lizardbyte.dev/projects/sunshine/latest/md_docs_2getting__started.html")
64+
set(CPACK_NSIS_URL_INFO_ABOUT "${CMAKE_PROJECT_HOMEPAGE_URL}")
65+
set(CPACK_NSIS_CONTACT "${CMAKE_PROJECT_HOMEPAGE_URL}/support")
66+
67+
set(CPACK_NSIS_MENU_LINKS
68+
"https://docs.lizardbyte.dev/projects/sunshine" "Sunshine documentation"
69+
"https://app.lizardbyte.dev" "LizardByte Web Site"
70+
"https://app.lizardbyte.dev/support" "LizardByte Support")
71+
set(CPACK_NSIS_MANIFEST_DPI_AWARE true)

cmake/packaging/windows_wix.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# WIX Packaging
2+
# see options at: https://cmake.org/cmake/help/latest/cpack_gen/wix.html
3+
4+
# TODO: Replace nsis with wix

0 commit comments

Comments
 (0)