You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

check_requirements.cmake 2.8 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ## define customized find functions, print customized error messages
  2. function(find_required_package pkg_name)
  3. find_package(${pkg_name})
  4. if(NOT ${pkg_name}_FOUND)
  5. message(FATAL_ERROR "Required package ${pkg_name} not found, "
  6. "please install the package and try building MindSpore again.")
  7. endif()
  8. endfunction()
  9. function(find_required_program prog_name)
  10. find_program(${prog_name}_EXE ${prog_name})
  11. if(NOT ${prog_name}_EXE)
  12. message(FATAL_ERROR "Required program ${prog_name} not found, "
  13. "please install the package and try building MindSpore again.")
  14. endif()
  15. endfunction()
  16. ## find python, quit if the found python is static
  17. if(CMAKE_SYSTEM_NAME MATCHES "Windows")
  18. set(Python3_FIND_REGISTRY LAST)
  19. set(Python3_FIND_STRATEGY LOCATION)
  20. endif()
  21. set(Python3_USE_STATIC_LIBS FALSE)
  22. set(Python3_FIND_VIRTUALENV ONLY)
  23. find_package(Python3 COMPONENTS Interpreter Development)
  24. if(Python3_FOUND)
  25. message("Python3 found, version: ${Python3_VERSION}")
  26. message("Python3 library path: ${Python3_LIBRARY}")
  27. message("Python3 interpreter: ${Python3_EXECUTABLE}")
  28. elseif(Python3_LIBRARY AND Python3_EXECUTABLE AND
  29. ${Python3_VERSION} VERSION_GREATER_EQUAL "3.7.0" AND ${Python3_VERSION} VERSION_LESS "3.9.9")
  30. message(WARNING "Maybe python3 environment is broken.")
  31. message("Python3 library path: ${Python3_LIBRARY}")
  32. message("Python3 interpreter: ${Python3_EXECUTABLE}")
  33. else()
  34. message(FATAL_ERROR "Python3 not found, please install Python>=3.7.5, and set --enable-shared "
  35. "if you are building Python locally")
  36. endif()
  37. ## packages used both on windows and linux
  38. if(DEFINED ENV{MS_PATCH_PATH})
  39. find_program(Patch_EXECUTABLE patch PATHS $ENV{MS_PATCH_PATH})
  40. set(Patch_FOUND ${Patch_EXECUTABLE})
  41. else()
  42. find_package(Patch)
  43. endif()
  44. if(NOT Patch_FOUND)
  45. message(FATAL_ERROR "Patch not found, "
  46. "please set environment variable MS_PATCH_PATH to path where Patch is located, "
  47. "usually found in GIT_PATH/usr/bin on Windows")
  48. endif()
  49. message(PATCH_EXECUTABLE = ${Patch_EXECUTABLE})
  50. find_required_package(Threads)
  51. ## packages used on Linux
  52. if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
  53. if(ENABLE_MINDDATA)
  54. find_required_program(tclsh)
  55. endif()
  56. ## packages used in GPU mode only
  57. if(ENABLE_GPU)
  58. find_library(gmp_LIB gmp)
  59. find_library(gmpxx_LIB gmpxx)
  60. find_file(gmp_HEADER gmp.h)
  61. if(NOT gmp_LIB OR NOT gmpxx_LIB OR NOT gmp_HEADER)
  62. message(FATAL_ERROR "Required package gmp not found, please install gmp and try building MindSpore again.")
  63. endif()
  64. find_required_program(automake)
  65. find_required_program(autoconf)
  66. find_required_program(libtoolize)
  67. find_required_package(FLEX)
  68. endif()
  69. endif()