build: wix generation for windows with cpack

This commit is contained in:
sithlord48
2024-11-22 01:37:52 -05:00
committed by Chris Rizzitello
parent b6d5095871
commit f06a789d25
9 changed files with 82 additions and 9 deletions

View File

@ -95,6 +95,8 @@ runs:
- name: Install Wix
if: ${{ runner.os == 'Windows' }}
run: |
dotnet tool install --global wix --version 4.0.4
wix extension add --global WixToolset.UI.wixext/4.0.4
dotnet tool install --global wix --version 5.0.2
wix extension add --global WixToolset.UI.wixext/5.0.2
wix extension add --global WixToolset.Util.wixext/5.0.2
wix extension add --global WixToolset.Firewall.wixext/5.0.2
shell: pwsh

View File

@ -50,6 +50,13 @@ macro(configure_libs)
message(VERBOSE "Set OPENSSL_ROOT_DIR: ${OPENSSL_ROOT_DIR}")
set(OPENSSL_EXE_DIR "${OPENSSL_ROOT_DIR}/tools/openssl")
add_definitions(-DOPENSSL_EXE_DIR="${OPENSSL_EXE_DIR}")
# HACK Install a copy of openssl on windows
install(
FILES
${OPENSSL_EXE_DIR}/openssl.exe
${OPENSSL_EXE_DIR}/openssl.cnf
DESTINATION .
)
endif()

View File

@ -46,9 +46,14 @@ elseif(NOT APPLE)
)
endif()
if(WIN32)
set(CPACK_PACKAGE_NAME "Deskflow")
else()
set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
endif()
# Generic Package Items
set(CPACK_STRIP_FILES TRUE)
set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
set(CPACK_PACKAGE_CONTACT "Deskflow <maintainers@deskflow.org>")
set(CPACK_PACKAGE_DESCRIPTION ${CMAKE_PROJECT_DESCRIPTION})
set(CPACK_PACKAGE_VENDOR "Deskflow")
@ -66,16 +71,49 @@ set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_RPM_PACKAGE_LICENSE "GPLv2")
set(CPACK_RPM_PACKAGE_GROUP "Applications/System")
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
cmake_path(SET QT_PATH NORMALIZE "${Qt6_DIR}../../")
set(CPACK_WIX_UPGRADE_GUID "027D1C8A-E7A5-4754-BB93-B2D45BFDBDC8")
# TODO RM with legacy WIX Builder
cmake_path(SET QT_PATH NORMALIZE "${Qt6_DIR}../../")
# TODO RM with legacy WIX Builder
configure_files(
${PROJECT_SOURCE_DIR}/deploy/dist/wix
${PROJECT_BINARY_DIR}/installer
)
set(CPACK_WIX_UI_BANNER "${CMAKE_CURRENT_SOURCE_DIR}/wix-banner.png")
set(CPACK_WIX_UI_DIALOG "${CMAKE_CURRENT_SOURCE_DIR}/wix-dialog.png")
set(CPACK_WIX_MSM_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Microsoft_VC142_CRT_x64.msm")
# Required Extra Extenstions
list(APPEND CPACK_WIX_EXTENSIONS "WixToolset.Util.wixext" "WixToolset.Firewall.wixext")
# Make sure to also put the xmlns for the ext into the wix block on generated files
list(APPEND CPACK_WIX_CUSTOM_XMLNS "util=http://wixtoolset.org/schemas/v4/wxs/util" "firewall=http://wixtoolset.org/schemas/v4/wxs/firewall")
# Inject Service and Firewall changes into geneated Wix File.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/wix-patch.xml.in "${CMAKE_CURRENT_BINARY_DIR}/wix-patch.xml" @ONLY)
set(CPACK_WIX_PATCH_FILE "${CMAKE_CURRENT_BINARY_DIR}/wix-patch.xml")
# Menu Entry
set(CPACK_WIX_PROGRAM_MENU_FOLDER "Deskflow")
set(CPACK_PACKAGE_EXECUTABLES "deskflow" "Deskflow")
# Default Install Path
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Deskflow")
# If Wix4+ is installed make a package
find_program(WIX_APP wix)
if (NOT "${WIX_APP}" STREQUAL "")
set(CPACK_WIX_VERSION 4)
list(APPEND CPACK_GENERATOR "WIX")
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES AMD64)
set(OS_STRING "win-x64")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES ARM64)
@ -105,7 +143,8 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "|.*BSD")
set(OS_STRING ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
endif()
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${PACKAGE_VERSION_LABEL}-${OS_STRING}")
# Always use "deskflow" for start of name
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${PACKAGE_VERSION_LABEL}-${OS_STRING}")
message(STATUS "Package Basename: ${CPACK_PACKAGE_FILE_NAME}")
include(CPack)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

BIN
deploy/wix-banner.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 94 KiB

26
deploy/wix-patch.xml.in Normal file
View File

@ -0,0 +1,26 @@
<CPackWiXPatch>
<CPackWiXFragment Id="CM_CP_deskflow_daemon.exe">
<ServiceInstall Description="Controls the Deskflow foreground processes." DisplayName="Deskflow" ErrorControl="normal" Id="ServiceInstall" Name="Deskflow" Start="auto" Type="ownProcess">
<util:ServiceConfig FirstFailureActionType="restart" ResetPeriodInDays="1" RestartServiceDelayInSeconds="1" SecondFailureActionType="restart" ThirdFailureActionType="restart"/>
</ServiceInstall>
<ServiceControl Id="ServiceControl" Name="Deskflow" Remove="uninstall" Start="install" Stop="both"/>
</CPackWiXFragment>
<CPackWiXFragment Id="CM_CP_deskflow_server.exe">
<firewall:FirewallException Id="ServerFirewallException" Name="Deskflow Server" Program="[INSTALL_ROOT]deskflow-server.exe" Scope="any"/>
</CPackWiXFragment>
<CPackWiXFragment Id="CM_CP_deskflow_client.exe">
<firewall:FirewallException Id="ClientFirewallException" Name="Deskflow Client" Program="[INSTALL_ROOT]deskflow-client.exe" Scope="any"/>
</CPackWiXFragment>
<CPackWiXFragment Id="#PRODUCT">
<StandardDirectory Id="TARGETDIR">
<Merge Id="VCRedist" SourceFile="@CPACK_WIX_MSM_FILE@" DiskId="1" Language="0"/>
</StandardDirectory >
<Feature Id="VCRedist" Title="Visual C++ Runtime" AllowAbsent="no" AllowAdvertise="yes" Display="hidden" InstallDefault="local" TypicalDefault="install">
<MergeRef Id="VCRedist" Primary="yes"/>
</Feature>
<CustomAction Id="Run_Deskflow" ExeCommand="Deskflow" FileRef="CM_FP_deskflow.exe" Return="asyncNoWait"/>
<InstallExecuteSequence>
<Custom Action="Run_Deskflow" OnExit="success" Condition="NOT Installed"/>
</InstallExecuteSequence>
</CPackWiXFragment>
</CPackWiXPatch>

View File

@ -30,7 +30,6 @@ static const char *const kCertificateHashAlgorithm = "-sha256";
static const char *const kCertificateLifetime = "365";
#if defined(Q_OS_WIN)
static const char *const kWinOpenSslDir = "OpenSSL";
static const char *const kWinOpenSslBinary = "openssl.exe";
static const char *const kConfigFile = "openssl.cnf";
#elif defined(Q_OS_UNIX)
@ -44,12 +43,12 @@ namespace deskflow::gui {
QString openSslWindowsDir()
{
auto appDir = QDir(QCoreApplication::applicationDirPath());
auto openSslDir = QDir(appDir.filePath(kWinOpenSslDir));
auto openSslDir = QDir(QCoreApplication::applicationDirPath());
auto openSslBin = QFile(QStringLiteral("%1/%2").arg(openSslDir.absolutePath(), kWinOpenSslBinary));
// in production, openssl is deployed with the app.
// in development, we can use the openssl path available at compile-time.
if (!openSslDir.exists()) {
if (!openSslBin.exists()) {
openSslDir = QDir(OPENSSL_EXE_DIR);
}