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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. set(Python3_USE_STATIC_LIBS FALSE)
  18. find_package(Python3 COMPONENTS Interpreter Development)
  19. if(Python3_FOUND)
  20. message("Python3 found, version: ${Python3_VERSION}")
  21. message("Python3 library path: ${Python3_LIBRARY}")
  22. message("Python3 interpreter: ${Python3_EXECUTABLE}")
  23. elseif(Python3_LIBRARY AND Python3_EXECUTABLE AND
  24. ${Python3_VERSION} VERSION_GREATER_EQUAL "3.7.0" AND ${Python3_VERSION} VERSION_LESS "3.9.9")
  25. message(WARNING "Maybe python3 environment is broken.")
  26. message("Python3 library path: ${Python3_LIBRARY}")
  27. message("Python3 interpreter: ${Python3_EXECUTABLE}")
  28. else()
  29. message(FATAL_ERROR "Python3 not found, please install Python>=3.7.5, and set --enable-shared "
  30. "if you are building Python locally")
  31. endif()
  32. ## packages used both on windows and linux
  33. if(DEFINED ENV{MS_PATCH_PATH})
  34. find_program(Patch_EXECUTABLE patch PATHS $ENV{MS_PATCH_PATH})
  35. set(Patch_FOUND ${Patch_EXECUTABLE})
  36. else()
  37. find_package(Patch)
  38. endif()
  39. if(NOT Patch_FOUND)
  40. message(FATAL_ERROR "Patch not found, "
  41. "please set environment variable MS_PATCH_PATH to path where Patch is located, "
  42. "usually found in GIT_PATH/usr/bin on Windows")
  43. endif()
  44. message(PATCH_EXECUTABLE = ${Patch_EXECUTABLE})
  45. find_required_package(Threads)
  46. ## packages used on Linux
  47. if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
  48. if(ENABLE_MINDDATA)
  49. find_required_program(tclsh)
  50. endif()
  51. if(MS_BUILD_GRPC)
  52. find_required_package(OpenSSL)
  53. endif()
  54. ## packages used in GPU mode only
  55. if(ENABLE_GPU)
  56. find_library(gmp_LIB gmp)
  57. find_library(gmpxx_LIB gmpxx)
  58. find_file(gmp_HEADER gmp.h)
  59. if(NOT gmp_LIB OR NOT gmpxx_LIB OR NOT gmp_HEADER)
  60. message(FATAL_ERROR "Required package gmp not found, please install gmp and try building MindSpore again.")
  61. endif()
  62. find_required_program(automake)
  63. find_required_program(autoconf)
  64. find_required_program(libtoolize)
  65. find_required_package(FLEX)
  66. endif()
  67. endif()