From b9247b4c27402dd38ef314f5a769b4dcf8676b0a Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Tue, 3 Dec 2024 23:01:31 -0500 Subject: [PATCH] refactor: cleanup windows deploy files --- CMakeLists.txt | 2 +- cmake/Libraries.cmake | 4 +- deploy/CMakeLists.txt | 59 ++---------------- .../{ => windows}/Microsoft_VC142_CRT_x64.msm | Bin deploy/windows/deploy.cmake | 59 ++++++++++++++++++ deploy/{ => windows}/version.rc.in | 0 deploy/{ => windows}/wix-banner.png | Bin deploy/{ => windows}/wix-dialog.png | Bin deploy/{ => windows}/wix-patch.xml.in | 0 9 files changed, 67 insertions(+), 57 deletions(-) rename deploy/{ => windows}/Microsoft_VC142_CRT_x64.msm (100%) create mode 100644 deploy/windows/deploy.cmake rename deploy/{ => windows}/version.rc.in (100%) rename deploy/{ => windows}/wix-banner.png (100%) rename deploy/{ => windows}/wix-dialog.png (100%) rename deploy/{ => windows}/wix-patch.xml.in (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 19ac1e90d..f6a0ae879 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,7 +110,7 @@ if(APPLE) endif() # Set Output Folders -# TODO Remove when new wix packages are made with cpack and not using post_config macros +# TODO Remove when not using post_config macros set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") set(BIN_TEMP_DIR ${PROJECT_BINARY_DIR}/temp/bin) diff --git a/cmake/Libraries.cmake b/cmake/Libraries.cmake index 4f4bd1d2c..29fc6e453 100644 --- a/cmake/Libraries.cmake +++ b/cmake/Libraries.cmake @@ -35,7 +35,7 @@ macro(configure_libs) message(STATUS "Qt version: ${Qt6_VERSION}") - # TODO SSL check can happen in lib/net when we make wix packages with cpack + # TODO SSL check can happen in lib/net when don't have to deploy it any longer on windows # Apple has to use static libraries because "Use of the Apple-provided OpenSSL # libraries by apps is strongly discouraged." @@ -45,7 +45,7 @@ macro(configure_libs) endif() find_package(OpenSSL ${REQUIRED_OPENSSL_VERSION} REQUIRED COMPONENTS SSL Crypto) - if(WIN32) #Used for dev in TLS and WIX TODO RM when cpack used for wix + if(WIN32) #Used for dev in TLS and WIX cmake_path(SET OPENSSL_ROOT_DIR NORMALIZE "${OPENSSL_INCLUDE_DIR}/..") message(VERBOSE "Set OPENSSL_ROOT_DIR: ${OPENSSL_ROOT_DIR}") set(OPENSSL_EXE_DIR "${OPENSSL_ROOT_DIR}/tools/openssl") diff --git a/deploy/CMakeLists.txt b/deploy/CMakeLists.txt index ec8f5bf25..77a32d207 100644 --- a/deploy/CMakeLists.txt +++ b/deploy/CMakeLists.txt @@ -8,24 +8,10 @@ file(COPY_FILE ONLY_IF_DIFFERENT ) -# Handle Pre install Items -if(WIN32) - - # Configure the windows version rc file - configure_file( - ${CMAKE_CURRENT_LIST_DIR}/version.rc.in - ${PROJECT_BINARY_DIR}/src/version.rc @ONLY - ) -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 ") set(CPACK_PACKAGE_DESCRIPTION ${CMAKE_PROJECT_DESCRIPTION}) set(CPACK_PACKAGE_VENDOR "Deskflow") @@ -38,49 +24,14 @@ if(NOT PACKAGE_VERSION_LABEL) set (PACKAGE_VERSION_LABEL "${CPACK_PACKAGE_VERSION}") endif() -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - - set(CPACK_WIX_UPGRADE_GUID "027D1C8A-E7A5-4754-BB93-B2D45BFDBDC8") - - 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) - set(OS_STRING "win-arm64") - else() - set(OS_STRING "win-${CMAKE_SYSTEM_PROCESSOR}") - endif() +if(WIN32) + include(windows/deploy.cmake) elseif(UNIX AND NOT APPLE) include(linux/deploy.cmake) elseif(APPLE) include(mac/deploy.cmake) +else() + message(STATUS "UNKNOWN System: ${CMAKE_SYSTEM_NAME}") endif() # Always use "deskflow" for start of name diff --git a/deploy/Microsoft_VC142_CRT_x64.msm b/deploy/windows/Microsoft_VC142_CRT_x64.msm similarity index 100% rename from deploy/Microsoft_VC142_CRT_x64.msm rename to deploy/windows/Microsoft_VC142_CRT_x64.msm diff --git a/deploy/windows/deploy.cmake b/deploy/windows/deploy.cmake new file mode 100644 index 000000000..5575e9de2 --- /dev/null +++ b/deploy/windows/deploy.cmake @@ -0,0 +1,59 @@ +# SPDX-FileCopyrightText: 2024 Chris Rizzitello +# SPDX-License-Identifier: MIT + +# HACK This is set when the files is included so its the real path +# calling CMAKE_CURRENT_LIST_DIR after include would return the wrong scope var +set(MY_DIR ${CMAKE_CURRENT_LIST_DIR}) + + +# Configure the windows version rc file +configure_file( + ${MY_DIR}/version.rc.in + ${PROJECT_BINARY_DIR}/src/version.rc @ONLY +) + +# Setup OS_STRING +if(CMAKE_SYSTEM_PROCESSOR MATCHES AMD64) + set(OS_STRING "win-x64") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES ARM64) + set(OS_STRING "win-arm64") +else() + set(OS_STRING "win-${CMAKE_SYSTEM_PROCESSOR}") +endif() + +# 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() + +set(CPACK_PACKAGE_NAME "Deskflow") + +# Menu Entry +set(CPACK_WIX_PROGRAM_MENU_FOLDER "Deskflow") +set(CPACK_PACKAGE_EXECUTABLES "deskflow" "Deskflow") + +# Default Install Path +set(CPACK_PACKAGE_INSTALL_DIRECTORY "Deskflow") + +# Wix Specific Values +set(CPACK_WIX_UPGRADE_GUID "027D1C8A-E7A5-4754-BB93-B2D45BFDBDC8") +set(CPACK_WIX_UI_BANNER "${MY_DIR}/wix-banner.png") +set(CPACK_WIX_UI_DIALOG "${MY_DIR}/wix-dialog.png") + +# 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") + +# The patch has to know the full path of our msm file +set(CPACK_WIX_MSM_FILE "${MY_DIR}/Microsoft_VC142_CRT_x64.msm") +configure_file( + ${MY_DIR}/wix-patch.xml.in + ${CMAKE_CURRENT_BINARY_DIR}/wix-patch.xml @ONLY +) + +# This patch set ups filewall rules, the service and msm module +set(CPACK_WIX_PATCH_FILE "${CMAKE_CURRENT_BINARY_DIR}/wix-patch.xml") diff --git a/deploy/version.rc.in b/deploy/windows/version.rc.in similarity index 100% rename from deploy/version.rc.in rename to deploy/windows/version.rc.in diff --git a/deploy/wix-banner.png b/deploy/windows/wix-banner.png similarity index 100% rename from deploy/wix-banner.png rename to deploy/windows/wix-banner.png diff --git a/deploy/wix-dialog.png b/deploy/windows/wix-dialog.png similarity index 100% rename from deploy/wix-dialog.png rename to deploy/windows/wix-dialog.png diff --git a/deploy/wix-patch.xml.in b/deploy/windows/wix-patch.xml.in similarity index 100% rename from deploy/wix-patch.xml.in rename to deploy/windows/wix-patch.xml.in