2021-03-04 10:50:37 +08:00
|
|
|
## define customized find functions, print customized error messages
|
2020-09-11 15:07:17 +08:00
|
|
|
function(find_required_package pkg_name)
|
|
|
|
find_package(${pkg_name})
|
2020-12-04 10:51:01 +08:00
|
|
|
if(NOT ${pkg_name}_FOUND)
|
|
|
|
message(FATAL_ERROR "Required package ${pkg_name} not found, "
|
|
|
|
"please install the package and try building MindSpore again.")
|
2020-09-11 15:07:17 +08:00
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(find_required_program prog_name)
|
|
|
|
find_program(${prog_name}_EXE ${prog_name})
|
2020-12-04 10:51:01 +08:00
|
|
|
if(NOT ${prog_name}_EXE)
|
|
|
|
message(FATAL_ERROR "Required program ${prog_name} not found, "
|
|
|
|
"please install the package and try building MindSpore again.")
|
|
|
|
endif()
|
2020-09-11 15:07:17 +08:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
|
|
|
|
## find python, quit if the found python is static
|
|
|
|
set(Python3_USE_STATIC_LIBS FALSE)
|
|
|
|
find_package(Python3 COMPONENTS Interpreter Development)
|
2020-12-04 10:51:01 +08:00
|
|
|
if(Python3_FOUND)
|
2020-09-11 15:07:17 +08:00
|
|
|
message("Python3 found, version: ${Python3_VERSION}")
|
2020-07-06 10:10:49 +08:00
|
|
|
message("Python3 library path: ${Python3_LIBRARY}")
|
2020-09-11 15:07:17 +08:00
|
|
|
message("Python3 interpreter: ${Python3_EXECUTABLE}")
|
2020-12-04 10:51:01 +08:00
|
|
|
elseif(Python3_LIBRARY AND Python3_EXECUTABLE AND
|
2021-03-04 10:50:37 +08:00
|
|
|
${Python3_VERSION} VERSION_GREATER_EQUAL "3.7.0" AND ${Python3_VERSION} VERSION_LESS "3.9.9")
|
2020-07-06 10:10:49 +08:00
|
|
|
message(WARNING "Maybe python3 environment is broken.")
|
|
|
|
message("Python3 library path: ${Python3_LIBRARY}")
|
|
|
|
message("Python3 interpreter: ${Python3_EXECUTABLE}")
|
2020-12-04 10:51:01 +08:00
|
|
|
else()
|
2020-09-11 15:07:17 +08:00
|
|
|
message(FATAL_ERROR "Python3 not found, please install Python>=3.7.5, and set --enable-shared "
|
|
|
|
"if you are building Python locally")
|
2020-12-04 10:51:01 +08:00
|
|
|
endif()
|
2020-09-11 15:07:17 +08:00
|
|
|
|
|
|
|
## packages used both on windows and linux
|
2020-12-04 10:51:01 +08:00
|
|
|
if(DEFINED ENV{MS_PATCH_PATH})
|
2020-09-11 15:07:17 +08:00
|
|
|
find_program(Patch_EXECUTABLE patch PATHS $ENV{MS_PATCH_PATH})
|
|
|
|
set(Patch_FOUND ${Patch_EXECUTABLE})
|
2020-12-04 10:51:01 +08:00
|
|
|
else()
|
2020-09-11 15:07:17 +08:00
|
|
|
find_package(Patch)
|
2020-12-04 10:51:01 +08:00
|
|
|
endif()
|
|
|
|
if(NOT Patch_FOUND)
|
|
|
|
message(FATAL_ERROR "Patch not found, "
|
|
|
|
"please set environment variable MS_PATCH_PATH to path where Patch is located, "
|
2020-09-11 15:07:17 +08:00
|
|
|
"usually found in GIT_PATH/usr/bin on Windows")
|
2020-12-04 10:51:01 +08:00
|
|
|
endif()
|
2020-09-11 15:07:17 +08:00
|
|
|
message(PATCH_EXECUTABLE = ${Patch_EXECUTABLE})
|
|
|
|
|
|
|
|
find_required_package(Threads)
|
|
|
|
|
|
|
|
|
|
|
|
## packages used on Linux
|
2020-12-04 10:51:01 +08:00
|
|
|
if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|
|
|
if(ENABLE_MINDDATA)
|
2020-09-11 15:07:17 +08:00
|
|
|
find_required_program(tclsh)
|
2020-12-04 10:51:01 +08:00
|
|
|
endif()
|
2020-09-11 15:07:17 +08:00
|
|
|
|
|
|
|
## packages used in GPU mode only
|
2020-12-04 10:51:01 +08:00
|
|
|
if(ENABLE_GPU)
|
2020-09-11 15:07:17 +08:00
|
|
|
find_library(gmp_LIB gmp)
|
|
|
|
find_library(gmpxx_LIB gmpxx)
|
|
|
|
find_file(gmp_HEADER gmp.h)
|
2020-12-04 10:51:01 +08:00
|
|
|
if(NOT gmp_LIB OR NOT gmpxx_LIB OR NOT gmp_HEADER)
|
2020-09-11 15:07:17 +08:00
|
|
|
message(FATAL_ERROR "Required package gmp not found, please install gmp and try building MindSpore again.")
|
2020-12-04 10:51:01 +08:00
|
|
|
endif()
|
2020-09-11 15:07:17 +08:00
|
|
|
find_required_program(automake)
|
|
|
|
find_required_program(autoconf)
|
|
|
|
find_required_program(libtoolize)
|
|
|
|
find_required_package(FLEX)
|
|
|
|
endif()
|
|
|
|
endif()
|