Преглед изворни кода

[cpack/2106-3p-manifest] add 3rd party SPDX license manifest file to package

scottr пре 4 година
родитељ
комит
72033a49d7
1 измењених фајлова са 33 додато и 0 уклоњено
  1. 33 0
      cmake/Packaging.cmake

+ 33 - 0
cmake/Packaging.cmake

@@ -108,6 +108,39 @@ install(FILES ${_cmake_package_dest}
     DESTINATION ./Tools/Redistributables/CMake
 )
 
+# temporary workaround for acquiring the 3rd party SPDX license manifest, the desired location is from
+# another git repository that's private.  once it's public, only how the URL is formed should change
+set(LY_INSTALLER_3RD_PARTY_LICENSE_URL "" CACHE STRING "URL to the 3rd party SPDX license manifest file for inclusion in packaging.")
+
+if(${LY_VERSION_STRING} VERSION_GREATER "0.0.0.0" AND NOT LY_INSTALLER_3RD_PARTY_LICENSE_URL)
+    message(FATAL_ERROR "Missing required URL for the 3rd party SPDX license manifest file.  "
+        "Please specifiy where to acquire the file via LY_INSTALLER_3RD_PARTY_LICENSE_URL")
+endif()
+
+string(REPLACE "/" ";" _url_components ${LY_INSTALLER_3RD_PARTY_LICENSE_URL})
+list(POP_BACK _url_components _3rd_party_license_filename)
+
+set(_3rd_party_license_dest ${CPACK_BINARY_DIR}/${_3rd_party_license_filename})
+
+# use the plain file downloader as we don't have the file hash available and using a dummy will
+# delete the file once it fails hash verification
+file(DOWNLOAD
+    ${LY_INSTALLER_3RD_PARTY_LICENSE_URL}
+    ${_3rd_party_license_dest}
+    STATUS _status
+    TLS_VERIFY ON
+)
+list(POP_FRONT _status _status_code)
+
+if (${_status_code} EQUAL 0 AND EXISTS ${_3rd_party_license_dest})
+    install(FILES ${_3rd_party_license_dest}
+        DESTINATION .
+    )
+else()
+    file(REMOVE ${_3rd_party_license_dest})
+    message(FATAL_ERROR "Failed to acquire the 3rd Party license manifest file.  Error: ${_status}")
+endif()
+
 # checks for and removes trailing slash
 function(strip_trailing_slash in_url out_url)
     string(LENGTH ${in_url} _url_length)