LicenseScan.cmake.in 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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_ROOT_FOLDER "@LY_ROOT_FOLDER@")
  9. set(CMAKE_SCRIPT_MODE_FILE TRUE)
  10. # Scan the engine and 3rd Party folders for licenses
  11. cmake_path(SET _license_script_path "@LY_ROOT_FOLDER@/scripts/license_scanner")
  12. cmake_path(SET _license_script "${_license_script_path}/license_scanner.py")
  13. cmake_path(SET _license_config "${_license_script_path}/scanner_config.json")
  14. set(_license_scan_path "@LY_ROOT_FOLDER@" "@LY_PACKAGE_UNPACK_LOCATION@")
  15. set(_license_command
  16. @LY_PYTHON_CMD@ -s
  17. -u ${_license_script}
  18. --config-file ${_license_config}
  19. --license-file-path @CPACK_3P_LICENSE_FILE@
  20. --package-file-path @CPACK_3P_MANIFEST_FILE@
  21. )
  22. message("Scanning ${_license_scan_path} for package licenses")
  23. execute_process(
  24. COMMAND ${_license_command} --scan-path ${_license_scan_path}
  25. RESULT_VARIABLE _license_result
  26. ERROR_VARIABLE _license_errors
  27. OUTPUT_VARIABLE _license_output
  28. ECHO_OUTPUT_VARIABLE
  29. )
  30. if(NOT ${_license_result} EQUAL 0)
  31. message(FATAL_ERROR "An error occurred during license scan. ${_license_errors}")
  32. endif()