get_python_package_hash.cmake 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. # This script will get the current python package hash. To use this script, invoke it using CMake
  8. # script mode (-P option) with the cwd being the engine root folder (the one with cmake as a subfolder)
  9. # on the command line, define LY_3RDPARTY_PATH to a valid directory
  10. # and PAL_PLATFORM_NAME to the platform you'd like to get or update python for.
  11. # defines must come before the script call.
  12. # example:
  13. # cmake -DPAL_PLATFORM_NAME:string=Windows -DLY_ROOT_FOLDER:string=%CMD_DIR% -P get_python_package_hash.cmake
  14. cmake_minimum_required(VERSION 3.22)
  15. if(${CMAKE_ARGC} LESS 4)
  16. message(FATAL_ERROR "Missing required engine root argument.")
  17. endif()
  18. if(${CMAKE_ARGC} LESS 5)
  19. message(FATAL_ERROR "Missing required platform name argument.")
  20. endif()
  21. #! ly_set: override the ly_set macro that the Python_<platform>.cmake file will use to set
  22. # the environments.
  23. #
  24. macro(ly_set name)
  25. set(${name} "${ARGN}")
  26. if(LY_PARENT_SCOPE)
  27. set(${name} "${ARGN}" PARENT_SCOPE)
  28. endif()
  29. endmacro()
  30. #! ly_associate_package: Stub out since this script is only reading the package hash
  31. #
  32. macro("ly_associate_package")
  33. endmacro()
  34. # The first required argument is the platform name
  35. set(ENGINE_ROOT ${CMAKE_ARGV3})
  36. set(PAL_PLATFORM_NAME ${CMAKE_ARGV4})
  37. # The optional second argument is the architecture
  38. if(${CMAKE_ARGC} GREATER 5)
  39. set(PLATFORM_ARCH "_${CMAKE_ARGV5}")
  40. endif()
  41. string(TOLOWER ${PAL_PLATFORM_NAME} PAL_PLATFORM_NAME_LOWERCASE)
  42. include(${ENGINE_ROOT}/cmake/3rdParty/Platform/${PAL_PLATFORM_NAME}/Python_${PAL_PLATFORM_NAME_LOWERCASE}${PLATFORM_ARCH}.cmake)
  43. # Note: using 'message(STATUS ..' will print to STDOUT, but will always include a double hyphen '--'. Instead we will
  44. # use the cmake echo command directly to do this
  45. execute_process(COMMAND ${CMAKE_COMMAND} -E echo ${LY_PYTHON_PACKAGE_HASH})