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