[cpack_installer] add option to specify license url. replicate online artifacts copy

This commit is contained in:
scottr
2021-05-17 16:34:24 -07:00
parent b19779e491
commit 2ddbd36f9a
3 changed files with 40 additions and 9 deletions
+8 -4
View File
@@ -13,10 +13,14 @@ if(NOT PAL_TRAIT_BUILD_CPACK_SUPPORTED)
return()
endif()
# set the common cpack variables first so they are accessible via configure_file
# when the platforms specific properties are applied below
# public facing options will eventually be converted into cpack specific ones below.
# all variables with the "CPACK_" prefix will automatically be cached for use in any
# of the build steps cpack runs e.g. pre-build, standard build, post-build.
set(LY_INSTALLER_DOWNLOAD_URL "" CACHE STRING "URL embded 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 all common cpack variable overrides first so they can be accessible via configure_file
# when the platform specific settings are applied below
set(CPACK_PACKAGE_VENDOR "${PROJECT_NAME}")
set(CPACK_PACKAGE_VERSION "${LY_VERSION_STRING}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Installation Tool")
@@ -28,11 +32,11 @@ set(DEFAULT_LICENSE_NAME "Apache-2.0")
set(DEFAULT_LICENSE_FILE "${CMAKE_SOURCE_DIR}/LICENSE.txt")
set(CPACK_RESOURCE_FILE_LICENSE ${DEFAULT_LICENSE_FILE})
set(CPACK_LICENSE_URL ${LY_INSTALLER_LICENSE_URL})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_VENDOR}/${CPACK_PACKAGE_VERSION}")
# CMAKE_SOURCE_DIR doesn't equate to anything during execution of pre/post build scripts.
# to pass it down, we can utilize the auto-caching of any variable with prefix "CPACK_"
# CMAKE_SOURCE_DIR doesn't equate to anything during execution of pre/post build scripts
set(CPACK_SOURCE_DIR ${CMAKE_SOURCE_DIR}/cmake)
# attempt to apply platform specific settings
@@ -16,11 +16,19 @@
Value="[ProgramFiles64Folder]$(var.CPACK_PACKAGE_INSTALL_DIRECTORY)"
bal:Overridable="yes"/>
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
<bal:WixStandardBootstrapperApplication
LicenseFile="$(var.CPACK_WIX_LICENSE_RTF)"
ShowVersion="yes" />
</BootstrapperApplicationRef>
<?ifdef CPACK_LICENSE_URL?>
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.HyperlinkLicense">
<bal:WixStandardBootstrapperApplication
LicenseUrl="$(var.CPACK_LICENSE_URL)"
ShowVersion="yes" />
</BootstrapperApplicationRef>
<?else?>
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
<bal:WixStandardBootstrapperApplication
LicenseFile="$(var.CPACK_WIX_LICENSE_RTF)"
ShowVersion="yes" />
</BootstrapperApplicationRef>
<?endif?>
<Chain>
<MsiPackage Id="$(var.CPACK_PACKAGE_FILE_NAME)"
@@ -31,6 +31,10 @@ set(_addtional_defines
-dCPACK_PACKAGE_INSTALL_DIRECTORY=${_fixed_package_install_dir}
)
if(CPACK_LICENSE_URL)
list(APPEND _addtional_defines -dCPACK_LICENSE_URL=${CPACK_LICENSE_URL})
endif()
set(_candle_command
${CPACK_WIX_CANDLE_EXECUTABLE}
-nologo
@@ -59,3 +63,18 @@ execute_process(
COMMAND ${_light_command}
COMMAND_ERROR_IS_FATAL ANY
)
# use the internal default path if somehow not specified from cpack_configure_downloads
if(NOT CPACK_UPLOAD_DIRECTORY)
set(CPACK_UPLOAD_DIRECTORY ${CPACK_PACKAGE_DIRECTORY}/CPackUploads)
endif()
# copy the artifacts intended to be uploaded to a remote server into the folder specified
# through cpack_configure_downloads. this mimics the same process cpack does natively for
# some other frameworks that have built-in online installer support.
message(STATUS "Copying installer artifacts to upload directory...")
file(GLOB _artifacts "${_cpack_wix_out_dir}/*.msi" "${_cpack_wix_out_dir}/*.cab")
file(COPY ${_artifacts}
DESTINATION ${CPACK_UPLOAD_DIRECTORY}
)
message(STATUS "Artifacts copied to ${CPACK_UPLOAD_DIRECTORY}")