2020-03-27 14:49:12 +08:00
|
|
|
cmake_minimum_required(VERSION 3.14)
|
|
|
|
project (MindSpore)
|
2020-04-26 11:02:20 +08:00
|
|
|
|
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3.0)
|
|
|
|
message(FATAL_ERROR "GCC vesion ${CMAKE_CXX_COMPILER_VERSION} must not be less than 7.3.0")
|
|
|
|
endif ()
|
|
|
|
|
2020-03-27 14:49:12 +08:00
|
|
|
include(${CMAKE_SOURCE_DIR}/cmake/options.cmake)
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
|
2020-06-04 14:50:53 +08:00
|
|
|
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|
|
|
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)
|
|
|
|
endif ()
|
2020-03-27 14:49:12 +08:00
|
|
|
|
2020-04-13 19:42:12 +08:00
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
2020-06-11 22:42:57 +08:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -Werror -Wno-return-std-move -Wno-unused-private-field -Wno-unused-lambda-capture -Wno-sign-compare -Wno-overloaded-virtual -Wno-unneeded-internal-declaration -Wno-unused-variable -Wno-pessimizing-move -Wno-inconsistent-missing-override -DHALF_ENABLE_CPP11_USER_LITERALS=0 -D_FORTIFY_SOURCE=2")
|
2020-04-13 19:42:12 +08:00
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -Wl,--allow-shlib-undefined -DHALF_ENABLE_CPP11_USER_LITERALS=0 -D_FORTIFY_SOURCE=2")
|
|
|
|
endif()
|
|
|
|
|
2020-07-11 04:26:00 +08:00
|
|
|
if (ENABLE_PYTHON)
|
|
|
|
add_compile_definitions(ENABLE_PYTHON)
|
|
|
|
endif()
|
|
|
|
|
2020-03-27 14:49:12 +08:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -g2 -ggdb -fno-inline-functions -fno-omit-frame-pointer -Wl,--allow-shlib-undefined -D_LIBCPP_INLINE_VISIBILITY='' -D'_LIBCPP_EXTERN_TEMPLATE(...)=' -DHALF_ENABLE_CPP11_USER_LITERALS=0 -D_FORTIFY_SOURCE=2 -Wno-cpp")
|
2020-04-15 17:36:48 +08:00
|
|
|
|
2020-03-27 14:49:12 +08:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/local/include -std=c++17 -Werror -Wall -Wno-deprecated-declarations -fPIC")
|
|
|
|
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)
|
2020-04-26 11:02:20 +08:00
|
|
|
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 ()
|
2020-04-17 16:05:21 +08:00
|
|
|
message(PATCH_EXECUTABLE = ${Patch_EXECUTABLE})
|
|
|
|
|
2020-06-08 15:31:37 +08:00
|
|
|
if (ENABLE_AKG AND ENABLE_D)
|
|
|
|
add_subdirectory("${CMAKE_SOURCE_DIR}/akg")
|
|
|
|
endif()
|
|
|
|
|
2020-03-27 14:49:12 +08:00
|
|
|
include(${CMAKE_SOURCE_DIR}/cmake/mind_expression.cmake)
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/flatbuffers/include)
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/flatbuffers/include/flatbuffers)
|
|
|
|
|
2020-07-21 11:19:00 +08:00
|
|
|
if (NOT ENABLE_ACL)
|
|
|
|
|
2020-03-27 14:49:12 +08:00
|
|
|
include(${CMAKE_SOURCE_DIR}/cmake/dependency_utils.cmake)
|
2020-04-13 15:30:25 +08:00
|
|
|
find_package(Python3 3.7 COMPONENTS Interpreter Development)
|
2020-03-27 14:49:12 +08:00
|
|
|
if(Python3_FOUND)
|
|
|
|
set(PYTHON_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}")
|
|
|
|
set(PYTHON_LIBRARIES "${Python3_LIBRARIES}")
|
2020-04-15 17:36:48 +08:00
|
|
|
if (WIN32)
|
|
|
|
if (Python3_DIR)
|
|
|
|
message("Python3_DIR set already: " ${Python3_DIR})
|
|
|
|
else()
|
|
|
|
string(LENGTH ${PYTHON_LIBRARIES} PYTHON_LIBRARIES_LEN)
|
|
|
|
string(LENGTH "libpythonxx.a" Python3_NAME_LEN)
|
|
|
|
math(EXPR Python3_DIR_LEN ${PYTHON_LIBRARIES_LEN}-${Python3_NAME_LEN})
|
|
|
|
string(SUBSTRING ${Python3_LIBRARIES} 0 ${Python3_DIR_LEN} Python3_DIR)
|
|
|
|
message("Python3_DIR: " ${Python3_DIR})
|
|
|
|
endif()
|
|
|
|
link_directories(${Python3_DIR})
|
|
|
|
endif()
|
2020-03-27 14:49:12 +08:00
|
|
|
else()
|
|
|
|
find_python_package(py_inc py_lib)
|
|
|
|
set(PYTHON_INCLUDE_DIRS "${py_inc}")
|
|
|
|
set(PYTHON_LIBRARIES "${py_lib}")
|
|
|
|
endif()
|
|
|
|
message("PYTHON_INCLUDE_DIRS = ${PYTHON_INCLUDE_DIRS}")
|
|
|
|
message("PYTHON_LIBRARIES = ${PYTHON_LIBRARIES}")
|
|
|
|
include_directories(${PYTHON_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
set(MS_CCSRC_PATH ${CMAKE_SOURCE_DIR}/mindspore/ccsrc)
|
|
|
|
set(MS_CCSRC_BUILD_PATH ${BUILD_PATH}/mindspore/mindspore/ccsrc)
|
|
|
|
|
|
|
|
if (ENABLE_GE)
|
|
|
|
link_directories(${CMAKE_SOURCE_DIR}/third_party/ge/lib)
|
2020-04-03 10:53:46 +08:00
|
|
|
elseif(ENABLE_D OR ENABLE_TESTCASES)
|
2020-03-27 14:49:12 +08:00
|
|
|
include(${CMAKE_SOURCE_DIR}/cmake/dependency_graphengine.cmake)
|
|
|
|
endif()
|
|
|
|
|
2020-03-23 17:33:56 +08:00
|
|
|
if (ENABLE_GE OR ENABLE_D OR ENABLE_TESTCASES)
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/inc)
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/inc/external)
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/inc/framework)
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/third_party/fwkacllib/inc)
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/third_party/fwkacllib/inc/toolchain)
|
|
|
|
endif()
|
2020-03-27 14:49:12 +08:00
|
|
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
|
|
|
|
add_subdirectory(mindspore/ccsrc)
|
|
|
|
if (ENABLE_TESTCASES)
|
|
|
|
add_subdirectory(tests)
|
|
|
|
endif()
|
2020-04-13 15:30:25 +08:00
|
|
|
|
2020-07-21 11:19:00 +08:00
|
|
|
endif() # NOT ENABLE_ACL
|
|
|
|
|
2020-06-21 14:37:27 +08:00
|
|
|
if (ENABLE_SERVING)
|
|
|
|
add_subdirectory(serving)
|
|
|
|
endif()
|
|
|
|
|
2020-07-21 11:19:00 +08:00
|
|
|
if (NOT ENABLE_ACL)
|
2020-06-04 09:59:26 +08:00
|
|
|
include(cmake/package.cmake)
|
2020-07-21 11:19:00 +08:00
|
|
|
endif() # NOT ENABLE_ACL
|