Files
jellyfin-desktop/CMakeModules/CompleteBundleWin.cmake.in
T
Andrew Rabert 747275054e Bundle VC runtime DLLs for Windows installer
- Support user-level install (no admin required)
- Bundle MSVC runtime DLLs from deps/vcruntime
- Offer system-wide VCRedist install when running as admin
- Add portable ZIP artifact (windows_zip target)
- Add combined windows_all target for installer + ZIP
2025-12-26 03:49:48 -05:00

80 lines
3.2 KiB
CMake

set(PROJECT_SOURCE_DIR @PROJECT_SOURCE_DIR@)
set(QTROOT "@QTROOT@")
message(STATUS "Running windeployqt from: ${QTROOT}/bin/windeployqt.exe")
message(STATUS "Target: ${CMAKE_INSTALL_PREFIX}/Jellyfin Desktop.exe")
execute_process(
COMMAND "${QTROOT}/bin/windeployqt.exe" --verbose 9 --qmldir @SOURCE_ROOT@/src/ui "${CMAKE_INSTALL_PREFIX}/Jellyfin Desktop.exe"
RESULT_VARIABLE WINDEPLOYQT_RESULT
)
if(NOT WINDEPLOYQT_RESULT EQUAL 0)
message(FATAL_ERROR "windeployqt failed with exit code: ${WINDEPLOYQT_RESULT}")
endif()
# windeployqt may miss Qt6Xml.dll - copy explicitly
file(INSTALL "${QTROOT}/bin/Qt6Xml.dll" DESTINATION "${CMAKE_INSTALL_PREFIX}")
# on windows windeployqt doesnt install non qt libraries, let cmake do that
# include(BundleUtilities)
foreach(d @CMAKE_FIND_ROOT_PATH@)
list(APPEND SEARCHDIRS ${d}/bin)
list(APPEND SEARCHDIRS ${d}/lib)
endforeach()
get_filename_component(CEC_DIR @CEC_LIBRARY@ DIRECTORY)
list(APPEND SEARCHDIRS ${CEC_DIR})
# fixup_bundle("${CMAKE_INSTALL_PREFIX}/Jellyfin Desktop.exe" "" "${SEARCHDIRS}")
#install(PROGRAMS ${VCREDIST_DIR}/vcredist_msvc2017_x64.exe DESTINATION .)
# Install MPV DLL (MPV_LIBRARY points to .lib, we need the .dll)
get_filename_component(MPV_DIR "@MPV_LIBRARY@" DIRECTORY)
file(INSTALL "${MPV_DIR}/libmpv-2.dll" DESTINATION "${CMAKE_INSTALL_PREFIX}")
# Install fallback libmpv if present
get_filename_component(MPV_FALLBACK_DIR "${MPV_DIR}/../mpv-fallback" ABSOLUTE)
if(EXISTS "${MPV_FALLBACK_DIR}/libmpv-2.dll")
file(INSTALL "${MPV_FALLBACK_DIR}/libmpv-2.dll" DESTINATION "${CMAKE_INSTALL_PREFIX}" RENAME "libmpv-fallback.dll")
message(STATUS "Installed fallback libmpv")
endif()
if(@DO_ENABLE_ANGLE_DEP@)
message(STATUS "Deploying separate ANGLE deps")
file(INSTALL @DEPENDENCY_CACHE_DIR@/libEGL.dll @DEPENDENCY_CACHE_DIR@/libGLESv2.dll @DEPENDENCY_CACHE_DIR@/d3dcompiler_47.dll DESTINATION ${CMAKE_INSTALL_PREFIX})
else()
message(STATUS "Not using separate ANGLE deps")
endif()
# Bundle MSVC runtime DLLs (pre-extracted by setup-windows.bat)
set(VCRUNTIME_DIR "@PROJECT_SOURCE_DIR@/deps/vcruntime")
set(VCREDIST_EXE "@PROJECT_SOURCE_DIR@/deps/vc_redist.x64.exe")
if(EXISTS "${VCRUNTIME_DIR}" AND EXISTS "${VCREDIST_EXE}")
# Copy runtime DLLs to redist subfolder
file(MAKE_DIRECTORY "${CMAKE_INSTALL_PREFIX}/redist")
file(GLOB RUNTIME_DLLS "${VCRUNTIME_DIR}/*.dll")
foreach(dll_path ${RUNTIME_DLLS})
get_filename_component(dll_name "${dll_path}" NAME)
file(INSTALL "${dll_path}" DESTINATION "${CMAKE_INSTALL_PREFIX}/redist")
message(STATUS "Bundled runtime: ${dll_name}")
endforeach()
# Copy VCRedist installer for bundling
file(INSTALL "${VCREDIST_EXE}" DESTINATION "${CMAKE_INSTALL_PREFIX}")
message(STATUS "Bundled VCRedist installer: vc_redist.x64.exe")
else()
message(WARNING "VCRuntime DLLs not found. Run setup-windows.bat first.")
endif()
if(@DO_SIGN@)
file(GLOB_RECURSE EXES ${CMAKE_INSTALL_PREFIX}/*.exe ${CMAKE_INSTALL_PREFIX}/*.dll)
set(ENV{errorlevel} 1)
foreach(e ${EXES})
message("-- Signing: ${PROJECT_SOURCE_DIR}/scripts/WindowsSign.cmd ${e}")
execute_process(COMMAND ${PROJECT_SOURCE_DIR}/scripts/WindowsSign.cmd "${e}" RESULT_VARIABLE RES)
endforeach()
endif()