[main] post install hook to configure cmake and python
Merge pull request #971 from aws-lumberyard-dev/cpack_installer
This commit is contained in:
@@ -17,6 +17,8 @@ endif()
|
||||
set(LY_INSTALLER_DOWNLOAD_URL "" CACHE STRING "URL embedded into the installer to download additional artifacts")
|
||||
set(LY_INSTALLER_LICENSE_URL "" CACHE STRING "Optionally embed a link to the license instead of raw text")
|
||||
|
||||
set(CPACK_DESIRED_CMAKE_VERSION 3.20.2)
|
||||
|
||||
# set all common cpack variable overrides first so they can be accessible via configure_file
|
||||
# when the platform specific settings are applied below. additionally, any variable with
|
||||
# the "CPACK_" prefix will automatically be cached for use in any phase of cpack namely
|
||||
@@ -38,6 +40,7 @@ set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_VENDOR}/${CPACK_PACKAGE_VER
|
||||
|
||||
# neither of the SOURCE_DIR variables equate to anything during execution of pre/post build scripts
|
||||
set(CPACK_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR}/_CPack) # to match other CPack out dirs
|
||||
|
||||
# attempt to apply platform specific settings
|
||||
ly_get_absolute_pal_filename(pal_dir ${CPACK_SOURCE_DIR}/Platform/${PAL_HOST_PLATFORM_NAME})
|
||||
@@ -48,6 +51,53 @@ if(NOT CPACK_GENERATOR)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# pull down the desired copy of CMake so it can be included in the package
|
||||
if(NOT (CPACK_CMAKE_PACKAGE_FILE AND CPACK_CMAKE_PACKAGE_HASH))
|
||||
message(FATAL_ERROR
|
||||
"Packaging is missing one or more following properties required to include CMake: "
|
||||
" CPACK_CMAKE_PACKAGE_FILE, CPACK_CMAKE_PACKAGE_HASH")
|
||||
endif()
|
||||
|
||||
set(_cmake_package_dest ${CPACK_BINARY_DIR}/${CPACK_CMAKE_PACKAGE_FILE})
|
||||
|
||||
string(REPLACE "." ";" _version_componets "${CPACK_DESIRED_CMAKE_VERSION}")
|
||||
list(GET _version_componets 0 _major_version)
|
||||
list(GET _version_componets 1 _minor_version)
|
||||
|
||||
set(_url_version_tag "v${_major_version}.${_minor_version}")
|
||||
set(_package_url "https://cmake.org/files/${_url_version_tag}/${CPACK_CMAKE_PACKAGE_FILE}")
|
||||
|
||||
message(STATUS "Ensuring CMake ${CPACK_DESIRED_CMAKE_VERSION} is available for packaging...")
|
||||
download_file(
|
||||
URL ${_package_url}
|
||||
TARGET_FILE ${_cmake_package_dest}
|
||||
EXPECTED_HASH ${CPACK_CMAKE_PACKAGE_HASH}
|
||||
RESULTS _results
|
||||
)
|
||||
list(GET _results 0 _status_code)
|
||||
|
||||
if (${_status_code} EQUAL 0 AND EXISTS ${_cmake_package_dest})
|
||||
message(STATUS "-> Package found and verified!")
|
||||
else()
|
||||
file(REMOVE ${_cmake_package_dest})
|
||||
list(REMOVE_AT _results 0)
|
||||
|
||||
set(_error_message "An error occurred, code ${_status_code}. URL ${_package_url} - ${_results}")
|
||||
|
||||
if(${_status_code} EQUAL 1)
|
||||
string(APPEND _error_message
|
||||
" Please double check the CPACK_CMAKE_PACKAGE_FILE and "
|
||||
"CPACK_CMAKE_PACKAGE_HASH properties before trying again.")
|
||||
endif()
|
||||
|
||||
message(FATAL_ERROR ${_error_message})
|
||||
endif()
|
||||
|
||||
install(FILES ${_cmake_package_dest}
|
||||
DESTINATION ./Tools/Redistributables/CMake
|
||||
COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT}
|
||||
)
|
||||
|
||||
# IMPORTANT: required to be included AFTER setting all property overrides
|
||||
include(CPack REQUIRED)
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<?xml version='1.0' encoding='windows-1252'?>
|
||||
|
||||
<?include "cpack_variables.wxi"?>
|
||||
|
||||
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'
|
||||
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
|
||||
<Fragment>
|
||||
|
||||
<!-- RemoveFolderEx works on properties instead of directory references -->
|
||||
<Property Id="INSTALLPATH">
|
||||
<RegistrySearch Id="INSTALLPATH_REGSEARCH"
|
||||
Root="HKLM"
|
||||
Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)\$(var.CPACK_PACKAGE_VERSION)"
|
||||
Name="Install Path"
|
||||
Type="raw"/>
|
||||
</Property>
|
||||
|
||||
<DirectoryRef Id="INSTALL_ROOT">
|
||||
<!-- this will clear out any additional files as part of the installation that weren't originally
|
||||
included of the MSI table -->
|
||||
<Component Id="SanitizeInstallFolder" Guid="{85468941-52E6-4C04-A66D-8E3CA3BBF04A}">
|
||||
<Condition><![CDATA[Installed OR NOT MANUALPRODUCTFOUND]]></Condition>
|
||||
<util:RemoveFolderEx On="uninstall" Property="INSTALLPATH"/>
|
||||
|
||||
<!-- registry entry is required to properly initialize the property during uninstall-->
|
||||
<RegistryValue Root="HKLM"
|
||||
Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)\$(var.CPACK_PACKAGE_VERSION)"
|
||||
Name="Install Path"
|
||||
Type="string"
|
||||
Value="[INSTALL_ROOT]"
|
||||
KeyPath="yes"/>
|
||||
</Component>
|
||||
|
||||
<!-- installation directory references for use in post install commands -->
|
||||
<Directory Id="root.cmake" Name="cmake">
|
||||
<Directory Id="root.cmake.runtime" Name="runtime"/>
|
||||
</Directory>
|
||||
<Directory Id="root.python" Name="python"/>
|
||||
<Directory Id="root.tools" Name="Tools">
|
||||
<Directory Id="root.tools.redist" Name="Redistributables">
|
||||
<Directory Id="root.tools.redist.cmake" Name="CMake"/>
|
||||
</Directory>
|
||||
</Directory>
|
||||
</DirectoryRef>
|
||||
|
||||
<CustomAction Id="ExtractCMake"
|
||||
ExeCommand=""[SystemFolder]cmd.exe" /C tar -x -f "[root.tools.redist.cmake]$(var.CPACK_CMAKE_PACKAGE_NAME).zip" -C "[root.tools.redist]CMake""
|
||||
Directory="INSTALL_ROOT"
|
||||
Execute="deferred"
|
||||
Impersonate="no"/>
|
||||
|
||||
<CustomAction Id="MoveCMake"
|
||||
ExeCommand=""[SystemFolder]cmd.exe" /C move "[root.tools.redist.cmake]$(var.CPACK_CMAKE_PACKAGE_NAME)" "[root.cmake]runtime""
|
||||
Directory="INSTALL_ROOT"
|
||||
Execute="deferred"
|
||||
Impersonate="no"/>
|
||||
|
||||
<CustomAction Id="ConfigurePython"
|
||||
ExeCommand=""[SystemFolder]cmd.exe" /C set "LY_CMAKE_PATH=[root.cmake.runtime]bin" && "[root.python]get_python.bat""
|
||||
Directory="INSTALL_ROOT"
|
||||
Execute="deferred"
|
||||
Impersonate="no"/>
|
||||
|
||||
</Fragment>
|
||||
</Wix>
|
||||
@@ -17,8 +17,7 @@
|
||||
<!-- auto distribute the installable files across N cab files -->
|
||||
<MediaTemplate EmbedCab="$(var.CPACK_EMBED_ARTIFACTS)"/>
|
||||
|
||||
<MajorUpgrade
|
||||
Schedule="afterInstallInitialize"
|
||||
<MajorUpgrade Schedule="afterInstallInitialize"
|
||||
AllowSameVersionUpgrades="yes"
|
||||
DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit."/>
|
||||
|
||||
@@ -41,8 +40,24 @@
|
||||
<FeatureRef Id="ProductFeature">
|
||||
<ComponentRef Id="DesktopShortcuts"/>
|
||||
<ComponentRef Id="StartMenuShortcuts"/>
|
||||
|
||||
<!-- for removing cmake and python on uninstall -->
|
||||
<ComponentRef Id="SanitizeInstallFolder"/>
|
||||
</FeatureRef>
|
||||
|
||||
<InstallExecuteSequence>
|
||||
<!-- limit the actions to first time install and repairs -->
|
||||
<Custom Action="ExtractCMake" Before="InstallFinalize">
|
||||
NOT Installed Or REINSTALL
|
||||
</Custom>
|
||||
<Custom Action="MoveCMake" After="ExtractCMake">
|
||||
NOT Installed Or REINSTALL
|
||||
</Custom>
|
||||
<Custom Action="ConfigurePython" After="MoveCMake">
|
||||
NOT Installed Or REINSTALL
|
||||
</Custom>
|
||||
</InstallExecuteSequence>
|
||||
|
||||
<UIRef Id="$(var.CPACK_WIX_UI_REF)" />
|
||||
|
||||
<?include "properties.wxi"?>
|
||||
|
||||
@@ -28,6 +28,10 @@ endif()
|
||||
|
||||
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 "15a49e2ab81c1822d75b1b1a92f7863f58e31f6d6aac1c4103eef2b071be3112")
|
||||
|
||||
# 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.
|
||||
@@ -83,9 +87,14 @@ set(CPACK_WIX_PRODUCT_ICON ${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/produc
|
||||
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")
|
||||
|
||||
if(LY_INSTALLER_DOWNLOAD_URL)
|
||||
@@ -101,4 +110,5 @@ endif()
|
||||
|
||||
set(CPACK_WIX_CANDLE_EXTRA_FLAGS
|
||||
-dCPACK_EMBED_ARTIFACTS=${_embed_artifacts}
|
||||
-dCPACK_CMAKE_PACKAGE_NAME=${_cmake_package_name}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user