Packaging_windows.cmake 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #
  2. # Copyright (c) Contributors to the Open 3D Engine Project.
  3. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. #
  8. set(LY_INSTALLER_WIX_ROOT "" CACHE PATH "Path to the WiX install path")
  9. if(LY_INSTALLER_WIX_ROOT)
  10. if(NOT EXISTS ${LY_INSTALLER_WIX_ROOT})
  11. message(FATAL_ERROR "Invalid path supplied for LY_INSTALLER_WIX_ROOT argument")
  12. endif()
  13. else()
  14. # early out as no path to WiX has been supplied effectively disabling support
  15. return()
  16. endif()
  17. # IMPORTANT: CPACK_WIX_ROOT is a built-in variable that is required to propagate the path supplied
  18. # via command line down to the cpack internals
  19. set(CPACK_WIX_ROOT ${LY_INSTALLER_WIX_ROOT})
  20. set(CPACK_GENERATOR WIX)
  21. set(_cmake_package_name "cmake-${CPACK_DESIRED_CMAKE_VERSION}-windows-x86_64")
  22. set(CPACK_CMAKE_PACKAGE_FILE "${_cmake_package_name}.zip")
  23. set(CPACK_CMAKE_PACKAGE_HASH "fcce74d1d7eaf825234c036702df3f0874dcd3cee8fdf90b56d0c7bfedd29465")
  24. # workaround for shortening the path cpack installs to by stripping the platform directory
  25. set(CPACK_TOPLEVEL_TAG "")
  26. # CPack will generate the WiX product/upgrade GUIDs further down the chain if they weren't supplied
  27. # however, they are unique for each run. instead, let's do the auto generation here and add it to
  28. # the cache for run persistence and have the ability to detect if they are still being used.
  29. set(_wix_guid_namespace "6D43F57A-2917-4AD9-B758-1F13CDB08593")
  30. function(generate_wix_guid out_value seed)
  31. string(UUID _guid
  32. NAMESPACE ${_wix_guid_namespace}
  33. NAME ${seed}
  34. TYPE SHA1
  35. UPPER
  36. )
  37. set(${out_value} ${_guid} PARENT_SCOPE)
  38. endfunction()
  39. set(_guid_seed_base "${PROJECT_NAME}_${O3DE_INSTALL_VERSION_STRING}")
  40. generate_wix_guid(_wix_default_product_guid "${_guid_seed_base}_ProductID" )
  41. generate_wix_guid(_wix_default_upgrade_guid "${_guid_seed_base}_UpgradeCode")
  42. set(LY_WIX_PRODUCT_GUID "" CACHE STRING "GUID for the Product ID field. Format: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
  43. set(LY_WIX_UPGRADE_GUID "" CACHE STRING "GUID for the Upgrade Code field. Format: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
  44. # clear previously cached default values to correct future runs. this will
  45. # unfortunately only work if the seed properties still haven't changed
  46. if(LY_WIX_PRODUCT_GUID STREQUAL ${_wix_default_product_guid})
  47. unset(LY_WIX_PRODUCT_GUID CACHE)
  48. endif()
  49. if(LY_WIX_UPGRADE_GUID STREQUAL ${_wix_default_upgrade_guid})
  50. unset(LY_WIX_UPGRADE_GUID CACHE)
  51. endif()
  52. if(NOT (LY_WIX_PRODUCT_GUID AND LY_WIX_UPGRADE_GUID))
  53. 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.")
  54. if(NOT LY_WIX_PRODUCT_GUID)
  55. set(LY_WIX_PRODUCT_GUID ${_wix_default_product_guid})
  56. message(STATUS "-> Default LY_WIX_PRODUCT_GUID = ${LY_WIX_PRODUCT_GUID}")
  57. endif()
  58. if(NOT LY_WIX_UPGRADE_GUID)
  59. set(LY_WIX_UPGRADE_GUID ${_wix_default_upgrade_guid})
  60. message(STATUS "-> Default LY_WIX_UPGRADE_GUID = ${LY_WIX_UPGRADE_GUID}")
  61. endif()
  62. endif()
  63. set(CPACK_WIX_PRODUCT_GUID ${LY_WIX_PRODUCT_GUID})
  64. set(CPACK_WIX_UPGRADE_GUID ${LY_WIX_UPGRADE_GUID})
  65. set(CPACK_WIX_PRODUCT_LOGO ${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/product_logo.png)
  66. set(CPACK_WIX_PRODUCT_ICON ${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/product_icon.ico)
  67. set(CPACK_WIX_TEMPLATE "${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/Template.wxs.in")
  68. set(CPACK_WIX_EXTRA_SOURCES
  69. "${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/PostInstallSetup.wxs"
  70. "${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/Shortcuts.wxs"
  71. )
  72. set(CPACK_WIX_EXTENSIONS
  73. WixUtilExtension
  74. )
  75. set(_embed_artifacts "yes")
  76. set(_hyperlink_license [[
  77. <Hypertext Name="EulaHyperlink" X="42" Y="202" Width="-42" Height="51" TabStop="yes" FontId="1" HideWhenDisabled="yes">#(loc.InstallEulaAcceptance)</Hypertext>
  78. ]])
  79. set(_raw_text_license [[
  80. <Richedit Name="EulaRichedit" X="42" Y="202" Width="-42" Height="-84" TabStop="yes" FontId="2" HexStyle="0x800000" />
  81. <Text Name="EulaAcceptance" X="42" Y="-56" Width="-42" Height="18" TabStop="yes" FontId="1" HideWhenDisabled="yes">#(loc.InstallEulaAcceptance)</Text>
  82. ]])
  83. set(WIX_THEME_WARNING_IMAGE ${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/warning.png)
  84. if(LY_INSTALLER_LICENSE_URL)
  85. set(WIX_THEME_INSTALL_LICENSE_ELEMENTS ${_hyperlink_license})
  86. set(WIX_THEME_EULA_ACCEPTANCE_TEXT "&lt;a href=\"#\"&gt;Terms of Use&lt;/a&gt;")
  87. else()
  88. set(WIX_THEME_INSTALL_LICENSE_ELEMENTS ${_raw_text_license})
  89. set(WIX_THEME_EULA_ACCEPTANCE_TEXT "Terms of Use above")
  90. endif()
  91. # theme ux file
  92. configure_file(
  93. "${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/BootstrapperTheme.xml.in"
  94. "${CPACK_BINARY_DIR}/BootstrapperTheme.xml"
  95. @ONLY
  96. )
  97. # theme localization file
  98. configure_file(
  99. "${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/BootstrapperTheme.wxl.in"
  100. "${CPACK_BINARY_DIR}/BootstrapperTheme.wxl"
  101. @ONLY
  102. )
  103. set(_embed_artifacts "no")
  104. # the bootstrapper will at the very least need a different upgrade guid
  105. generate_wix_guid(CPACK_WIX_BOOTSTRAP_UPGRADE_GUID "${_guid_seed_base}_Bootstrap_UpgradeCode")
  106. set(CPACK_WIX_CANDLE_EXTRA_FLAGS
  107. -dCPACK_EMBED_ARTIFACTS=${_embed_artifacts}
  108. -dCPACK_CMAKE_PACKAGE_NAME=${_cmake_package_name}
  109. )
  110. 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.")
  111. if(O3DE_INCLUDE_INSTALL_IN_PACKAGE)
  112. set(CPACK_INSTALLED_DIRECTORIES "${CMAKE_INSTALL_PREFIX};/CORE")
  113. endif()