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.7 kB

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