fix missing icon in control panel for Windows

This commit is contained in:
SoftFever
2026-10-15 01:08:01 +08:00
parent 9ab0178dd0
commit 6254ab643a
2 changed files with 48 additions and 1 deletions
+2 -1
View File
@@ -1345,7 +1345,8 @@ set (CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
set (CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/resources/images\\\\OrcaSlicer.ico")
set (CPACK_NSIS_MUI_ICON "${CPACK_PACKAGE_ICON}")
set (CPACK_NSIS_MUI_UNIICON "${CPACK_PACKAGE_ICON}")
set (CPACK_NSIS_INSTALLED_ICON_NAME "$INSTDIR\\\\orca-slicer.exe")
# Relative to the install dir: CPack's NSIS template prefixes $INSTDIR itself.
set (CPACK_NSIS_INSTALLED_ICON_NAME "orca-slicer.exe")
set (CPACK_PACKAGE_CHECKSUM SHA256)
set (CPACK_PACKAGE_INSTALL_REGISTRY_KEY "OrcaSlicer")
set (CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
+46
View File
@@ -42,6 +42,7 @@ call :add_arg build_deps bool d deps "Download and build the dependencies, neede
call :add_arg build_slicer bool s slicer "Build OrcaSlicer"
call :add_arg build_tests bool "" tests "Build the unit tests"
call :add_arg run_tests bool "" run-tests "Build the unit tests and run them"
call :add_arg make_installer bool "" installer "Build OrcaSlicer and package it into an NSIS installer"
call :add_arg pack_deps bool p pack "Bundle the built dependencies into a zip file"
call :add_arg install_deps bool u install-deps "Install or update CMake, Perl and Git with WinGet"
call :add_arg install_vs string "" install-vs "Also install Visual Studio: buildtools or ide"
@@ -185,6 +186,9 @@ if "%build_deps%%build_slicer%%pack_deps%%install_deps%%install_vs%" == "" (
if "%run_tests%" == "ON" set "build_slicer=ON"
)
REM The installer packages the slicer build, so it always needs one.
if "%make_installer%" == "ON" set "build_slicer=ON"
REM Options like --config or -j only shape a build. Without one of the actions
REM there is nothing for them to shape, so say so rather than resolving a whole
REM build and reporting it took no time. The block above may have added one.
@@ -222,6 +226,30 @@ if "%build_slicer%" == "ON" if "%install_slicer%" == "ON" if not "%slicer_target
echo --install needs the executable, but --slicer-target names "%slicer_target%".
exit /b 1
)
REM cpack runs the same install, so it has the same need.
if "%make_installer%" == "ON" if not "%slicer_target%" == "" if /I not "%slicer_target%" == "OrcaSlicer" (
echo --installer needs the executable, but --slicer-target names "%slicer_target%".
exit /b 1
)
REM cpack finds makensis on PATH or through the registry key the NSIS installer
REM writes, so look in the same places, and before the build rather than after
REM it. The value is read past its REG_SZ marker because the name column is
REM localised and may hold spaces.
if not "%make_installer%" == "ON" goto :nsis_ready
if "%dry_run%" == "ON" goto :nsis_ready
where makensis >nul 2>nul && goto :nsis_ready
for %%v in (32 64) do (
for /f "delims=" %%l in ('reg query "HKLM\SOFTWARE\NSIS" /ve /reg:%%v 2^>nul ^| findstr REG_SZ') do (
set "nsis_line=%%l"
set "nsis_line=!nsis_line:*REG_SZ=!"
for /f "tokens=*" %%d in ("!nsis_line!") do if exist "%%d\makensis.exe" goto :nsis_ready
)
)
echo NSIS was not found, and --installer needs it to build the installer.
echo Install it with "winget install NSIS.NSIS", then run this again.
exit /b 1
:nsis_ready
if not "%vs_version%" == "" if "!vs_gen_%vs_version%!" == "" (
echo Unknown Visual Studio release "%vs_version%". Known releases: 2019, 2022, 2026.
exit /b 1
@@ -734,6 +762,14 @@ if "%build_slicer%" == "ON" (
call :print_and_run cmake --build "%build_dir%" --target install --config %build_type%
%error_check%
)
REM cpack installs into its own staging tree, so this does not need -i.
REM Unlike CI it skips the preset cache, whose packaging step prunes the
REM checkout's preset JSONs.
if "%make_installer%" == "ON" (
call :print_and_run cpack -G NSIS -C %build_type% --config "%build_dir%\CPackConfig.cmake" -B "%build_dir%"
%error_check%
)
)
REM Elapsed wall clock. The 1%%a-100 trick strips a leading zero, which set /A
@@ -820,6 +856,16 @@ REM worked out the same way in either run.
if "%build_slicer%" == "ON" if not "%linked%" == "ON" echo Target %slicer_target%
if "%build_slicer%" == "ON" if not "%using_ninja%" == "ON" echo Solution %build_full%\!solution!
if "%pack_deps%" == "ON" if defined bundle echo Bundle !bundle!
if "%make_installer%" == "ON" (
REM The file name carries the version, which only CMake knows, so name
REM the newest match, or the pattern when there is none yet.
set "installer="
for /f "delims=" %%f in ('dir /b /o-d "!build_full!\OrcaSlicer_Windows_Installer_*.exe" 2^>nul') do (
if not defined installer set "installer=!build_full!\%%f"
)
if not defined installer set "installer=!build_full!\OrcaSlicer_Windows_Installer_*.exe"
echo Installer !installer!
)
echo.
echo Next