!6003 Check if required packages exist during compilation of MindSpore

Merge pull request !6003 from yanghaoran/pathfinding
This commit is contained in:
mindspore-ci-bot 2020-09-11 16:17:59 +08:00 committed by Gitee
commit 88aedd5d71
4 changed files with 77 additions and 21 deletions

View File

@ -6,6 +6,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_
endif ()
include(${CMAKE_SOURCE_DIR}/cmake/options.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/check_requirements.cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)
@ -29,19 +30,6 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(PYBIND11_CPP_STANDARD -std=c++17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPTION_CXX_FLAGS}")
find_package(Threads)
if (DEFINED ENV{MS_PATCH_PATH})
find_program(Patch_EXECUTABLE patch PATHS $ENV{MS_PATCH_PATH})
set(Patch_FOUND ${Patch_EXECUTABLE})
else ()
find_package(Patch)
endif ()
if (NOT Patch_FOUND)
message(FATAL_ERROR "Patch not found, please set env variable MS_PATCH_PATH, "
"usually locate in GIT_PATH/usr/bin in windows")
endif ()
message(PATCH_EXECUTABLE = ${Patch_EXECUTABLE})
if (ENABLE_AKG AND (ENABLE_D OR ENABLE_GPU))
add_subdirectory("${CMAKE_SOURCE_DIR}/akg")
endif()

View File

@ -0,0 +1,68 @@
## define customized find fucntions, print customized error messages
function(find_required_package pkg_name)
find_package(${pkg_name})
if (NOT ${pkg_name}_FOUND)
message(FATAL_ERROR "Required package ${pkg_name} not found, please install the package and try building MindSpore again.")
endif()
endfunction()
function(find_required_program prog_name)
find_program(${prog_name}_EXE ${prog_name})
if (NOT ${prog_name}_EXE)
message(FATAL_ERROR "Required program ${prog_name} not found, please install the package and try building MindSpore again.")
endif ()
endfunction()
## find python, quit if the found python is static
set(Python3_USE_STATIC_LIBS FALSE)
find_package(Python3 COMPONENTS Interpreter Development)
if (Python3_FOUND)
message("Python3 found, version: ${Python3_VERSION}")
message("Python3 library path: ${Python3_LIBRARY_DIRS}")
message("Python3 interpreter: ${Python3_EXECUTABLE}")
else()
message(FATAL_ERROR "Python3 not found, please install Python>=3.7.5, and set --enable-shared "
"if you are building Python locally")
endif ()
## packages used both on windows and linux
if (DEFINED ENV{MS_PATCH_PATH})
find_program(Patch_EXECUTABLE patch PATHS $ENV{MS_PATCH_PATH})
set(Patch_FOUND ${Patch_EXECUTABLE})
else ()
find_package(Patch)
endif ()
if (NOT Patch_FOUND)
message(FATAL_ERROR "Patch not found, please set environment variable MS_PATCH_PATH to path where Patch is located, "
"usually found in GIT_PATH/usr/bin on Windows")
endif ()
message(PATCH_EXECUTABLE = ${Patch_EXECUTABLE})
find_required_package(Threads)
## packages used on Linux
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
if (ENABLE_MINDDATA)
find_required_program(tclsh)
endif ()
if (MS_BUILD_GRPC)
find_required_package(OpenSSL)
endif ()
## packages used in GPU mode only
if (ENABLE_GPU)
find_library(gmp_LIB gmp)
find_library(gmpxx_LIB gmpxx)
find_file(gmp_HEADER gmp.h)
if (NOT gmp_LIB OR NOT gmpxx_LIB OR NOT gmp_HEADER)
message(FATAL_ERROR "Required package gmp not found, please install gmp and try building MindSpore again.")
endif ()
find_required_program(automake)
find_required_program(autoconf)
find_required_program(libtoolize)
find_required_package(FLEX)
endif()
endif()

View File

@ -15,14 +15,7 @@ include(${CMAKE_SOURCE_DIR}/cmake/external_libs/json.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/dependency_securec.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/protobuf.cmake)
SET(MS_BUILD_GRPC 0)
if (ENABLE_DEBUGGER OR ENABLE_SERVING OR ENABLE_TESTCASES)
SET(MS_BUILD_GRPC 1)
endif()
if (ENABLE_MINDDATA AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
SET(MS_BUILD_GRPC 1)
endif()
if ("${MS_BUILD_GRPC}")
if (MS_BUILD_GRPC)
# build dependencies of gRPC
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/absl.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/c-ares.cmake)

View File

@ -123,3 +123,10 @@ endif()
if(ENABLE_DEBUGGER)
add_compile_definitions(ENABLE_DEBUGGER)
endif()
if (ENABLE_DEBUGGER OR ENABLE_SERVING OR ENABLE_TESTCASES)
set(MS_BUILD_GRPC ON)
endif()
if (ENABLE_MINDDATA AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
set(MS_BUILD_GRPC ON)
endif()