123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- #
- # Copyright (c) Contributors to the Open 3D Engine Project.
- # For complete copyright and license terms please see the LICENSE at the root of this distribution.
- #
- # SPDX-License-Identifier: Apache-2.0 OR MIT
- #
- #
- set(LY_INSTALLER_WIX_ROOT "" CACHE PATH "Path to the WiX install path")
- if(LY_INSTALLER_WIX_ROOT)
- if(NOT EXISTS ${LY_INSTALLER_WIX_ROOT})
- message(FATAL_ERROR "Invalid path supplied for LY_INSTALLER_WIX_ROOT argument")
- endif()
- else()
- # early out as no path to WiX has been supplied effectively disabling support
- return()
- endif()
- # IMPORTANT: CPACK_WIX_ROOT is a built-in variable that is required to propagate the path supplied
- # via command line down to the cpack internals
- set(CPACK_WIX_ROOT ${LY_INSTALLER_WIX_ROOT})
- set(CPACK_GENERATOR WIX)
- set(_cmake_package_name "cmake-${CPACK_DESIRED_CMAKE_VERSION}-windows-x86_64")
- set(CPACK_CMAKE_PACKAGE_FILE "${_cmake_package_name}.zip")
- set(CPACK_CMAKE_PACKAGE_HASH "fcce74d1d7eaf825234c036702df3f0874dcd3cee8fdf90b56d0c7bfedd29465")
- # workaround for shortening the path cpack installs to by stripping the platform directory
- set(CPACK_TOPLEVEL_TAG "")
- # CPack will generate the WiX product/upgrade GUIDs further down the chain if they weren't supplied
- # however, they are unique for each run. instead, let's do the auto generation here and add it to
- # the cache for run persistence and have the ability to detect if they are still being used.
- set(_wix_guid_namespace "6D43F57A-2917-4AD9-B758-1F13CDB08593")
- function(generate_wix_guid out_value seed)
- string(UUID _guid
- NAMESPACE ${_wix_guid_namespace}
- NAME ${seed}
- TYPE SHA1
- UPPER
- )
- set(${out_value} ${_guid} PARENT_SCOPE)
- endfunction()
- set(_guid_seed_base "${PROJECT_NAME}_${O3DE_INSTALL_VERSION_STRING}")
- generate_wix_guid(_wix_default_product_guid "${_guid_seed_base}_ProductID" )
- generate_wix_guid(_wix_default_upgrade_guid "${_guid_seed_base}_UpgradeCode")
- set(LY_WIX_PRODUCT_GUID "" CACHE STRING "GUID for the Product ID field. Format: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
- set(LY_WIX_UPGRADE_GUID "" CACHE STRING "GUID for the Upgrade Code field. Format: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
- # clear previously cached default values to correct future runs. this will
- # unfortunately only work if the seed properties still haven't changed
- if(LY_WIX_PRODUCT_GUID STREQUAL ${_wix_default_product_guid})
- unset(LY_WIX_PRODUCT_GUID CACHE)
- endif()
- if(LY_WIX_UPGRADE_GUID STREQUAL ${_wix_default_upgrade_guid})
- unset(LY_WIX_UPGRADE_GUID CACHE)
- endif()
- if(NOT (LY_WIX_PRODUCT_GUID AND LY_WIX_UPGRADE_GUID))
- message(STATUS "One or both WiX GUIDs were auto generated. It is recommended you supply your own GUIDs through LY_WIX_PRODUCT_GUID and LY_WIX_UPGRADE_GUID.")
- if(NOT LY_WIX_PRODUCT_GUID)
- set(LY_WIX_PRODUCT_GUID ${_wix_default_product_guid})
- message(STATUS "-> Default LY_WIX_PRODUCT_GUID = ${LY_WIX_PRODUCT_GUID}")
- endif()
- if(NOT LY_WIX_UPGRADE_GUID)
- set(LY_WIX_UPGRADE_GUID ${_wix_default_upgrade_guid})
- message(STATUS "-> Default LY_WIX_UPGRADE_GUID = ${LY_WIX_UPGRADE_GUID}")
- endif()
- endif()
- set(CPACK_WIX_PRODUCT_GUID ${LY_WIX_PRODUCT_GUID})
- set(CPACK_WIX_UPGRADE_GUID ${LY_WIX_UPGRADE_GUID})
- set(CPACK_WIX_PRODUCT_LOGO ${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/product_logo.png)
- set(CPACK_WIX_PRODUCT_ICON ${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/product_icon.ico)
- set(CPACK_WIX_TEMPLATE "${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/Template.wxs.in")
- set(CPACK_WIX_EXTRA_SOURCES
- "${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/PostInstallSetup.wxs"
- "${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/Shortcuts.wxs"
- )
- set(CPACK_WIX_EXTENSIONS
- WixUtilExtension
- )
- set(_embed_artifacts "yes")
- set(_hyperlink_license [[
- <Hypertext Name="EulaHyperlink" X="42" Y="202" Width="-42" Height="51" TabStop="yes" FontId="1" HideWhenDisabled="yes">#(loc.InstallEulaAcceptance)</Hypertext>
- ]])
- set(_raw_text_license [[
- <Richedit Name="EulaRichedit" X="42" Y="202" Width="-42" Height="-84" TabStop="yes" FontId="2" HexStyle="0x800000" />
- <Text Name="EulaAcceptance" X="42" Y="-56" Width="-42" Height="18" TabStop="yes" FontId="1" HideWhenDisabled="yes">#(loc.InstallEulaAcceptance)</Text>
- ]])
- set(WIX_THEME_WARNING_IMAGE ${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/warning.png)
- if(LY_INSTALLER_LICENSE_URL)
- set(WIX_THEME_INSTALL_LICENSE_ELEMENTS ${_hyperlink_license})
- set(WIX_THEME_EULA_ACCEPTANCE_TEXT "<a href=\"#\">Terms of Use</a>")
- else()
- set(WIX_THEME_INSTALL_LICENSE_ELEMENTS ${_raw_text_license})
- set(WIX_THEME_EULA_ACCEPTANCE_TEXT "Terms of Use above")
- endif()
- # theme ux file
- configure_file(
- "${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/BootstrapperTheme.xml.in"
- "${CPACK_BINARY_DIR}/BootstrapperTheme.xml"
- @ONLY
- )
- # theme localization file
- configure_file(
- "${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/BootstrapperTheme.wxl.in"
- "${CPACK_BINARY_DIR}/BootstrapperTheme.wxl"
- @ONLY
- )
- set(_embed_artifacts "no")
- # the bootstrapper will at the very least need a different upgrade guid
- generate_wix_guid(CPACK_WIX_BOOTSTRAP_UPGRADE_GUID "${_guid_seed_base}_Bootstrap_UpgradeCode")
- set(CPACK_WIX_CANDLE_EXTRA_FLAGS
- -dCPACK_EMBED_ARTIFACTS=${_embed_artifacts}
- -dCPACK_CMAKE_PACKAGE_NAME=${_cmake_package_name}
- )
- set(O3DE_INCLUDE_INSTALL_IN_PACKAGE FALSE CACHE BOOL "Option to copy the contents of the most recent install from CMAKE_INSTALL_PREFIX into the CORE package. Useful for including a release build in a profile SDK.")
- if(O3DE_INCLUDE_INSTALL_IN_PACKAGE)
- set(CPACK_INSTALLED_DIRECTORIES "${CMAKE_INSTALL_PREFIX};/CORE")
- endif()
|