1option(ENABLE_D "Enable d" OFF) 2option(ENABLE_GPU "Enable gpu" OFF) 3option(ENABLE_CPU "Enable cpu" OFF) 4option(ENABLE_MINDDATA "Enable minddata compile" OFF) 5option(ENABLE_TESTCASES "Run testcases switch, default off" OFF) 6option(ENABLE_CPP_ST "Run cpp st testcases switch, default off" OFF) 7option(DEBUG_MODE "Debug mode, default off" OFF) 8option(ENABLE_ASAN "Enable Google Sanitizer to find memory bugs") 9option(ENABLE_LOAD_ANF_IR "Enable load ANF-IR as input of 'infer' stage of pipeline" OFF) 10option(ENABLE_COVERAGE "Enable code coverage report" OFF) 11option(USE_GLOG "Use glog to output log" OFF) 12option(ENABLE_SECURITY "Enable security, maintenance function will be disabled, default off" OFF) 13option(ENABLE_PROFILE "Enable pipeline profile function by default, default off" OFF) 14option(ENABLE_TIMELINE "Enable time line record" OFF) 15option(ENABLE_DUMP_PROTO "Enable dump anf graph to file in ProtoBuffer format, default on" ON) 16option(ENABLE_DUMP_IR "Enable dump function graph ir, default on" ON) 17option(ENABLE_MPI "enable mpi" OFF) 18option(ENABLE_AKG "enable akg" OFF) 19option(ENABLE_DEBUGGER "enable debugger" OFF) 20option(ENABLE_RDMA "enable RDMA for RPC" OFF) 21option(ENABLE_PYTHON "Enable python" ON) 22option(ENABLE_ACL "enable acl" OFF) 23option(ENABLE_GLIBCXX "enable_glibcxx" OFF) 24option(MODE_ASCEND_ALL "supports all ascend platform" OFF) 25option(MODE_ASCEND_ACL "supports ascend acl mode only" OFF) 26option(ENABLE_SYM_FILE "enable sym file" OFF) 27option(BUILD_DEV_MODE "MindSpore build nightly dev mode" OFF) 28option(ENABLE_FAST_HASH_TABLE "Enable use fast hash table instead of std ones" ON) 29option(USE_LLVM "Use llvm" OFF) 30option(USE_MS_THREADPOOL_FOR_DNNL "Use ms threadpool for onednn ops" ON) 31option(ONLY_BUILD_DEVICE_PLUGINS "Only build device plugins" OFF) 32option(ENABLE_AIO "Enable aio plugin on linux" OFF) 33option(ENABLE_DVM "enable dvm" OFF) 34option(ENABLE_FFMPEG "Enable ffmpeg" ON) 35 36if(ONLY_BUILD_DEVICE_PLUGINS) 37 if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux") 38 set(ONLY_BUILD_DEVICE_PLUGINS OFF) 39 message(WARNING "-f is supported on only linux.") 40 endif() 41 if(ENABLE_CPU) 42 set(ENABLE_CPU OFF) 43 endif() 44endif() 45 46if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux") 47 set(ENABLE_MPI OFF) 48endif() 49 50if(NOT (CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "Windows")) 51 set(USE_MS_THREADPOOL_FOR_DNNL OFF) 52endif() 53 54if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux") 55 set(ENABLE_GLIBCXX ON) 56endif() 57 58if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 59 if(WIN32) 60 set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -fstack-protector-all") 61 else() 62 set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack") 63 endif() 64endif() 65 66if(CMAKE_SYSTEM_NAME MATCHES "Darwin") 67 set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -Wsign-compare") 68endif() 69 70if(ENABLE_COVERAGE) 71 set(COVERAGE_COMPILER_FLAGS "-g --coverage -fprofile-arcs -ftest-coverage") 72 set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}") 73endif() 74 75if(ENABLE_ASAN) 76 set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -fsanitize=address -fsanitize-recover=address -fno-omit-frame-pointer") 77 if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 78 set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -static-libsan") 79 endif() 80 add_compile_definitions(ENABLE_ASAN) 81endif() 82 83if(DEBUG_MODE) 84 set(CMAKE_BUILD_TYPE "Debug") 85 add_compile_definitions(MEM_REUSE_DEBUG) 86else() 87 set(CMAKE_BUILD_TYPE "Release") 88endif() 89 90if((CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") OR (CMAKE_BUILD_TYPE STREQUAL Release)) 91 set(PYBIND11_LTO_CXX_FLAGS FALSE) 92endif() 93 94if(NOT BUILD_PATH) 95 set(BUILD_PATH "${CMAKE_SOURCE_DIR}/build") 96endif() 97 98if(ENABLE_D) 99 set(ENABLE_TDTQUE ON) 100endif() 101 102if(ENABLE_GPU) 103 add_compile_definitions(ENABLE_GPU_COLLECTIVE) 104endif() 105 106if(ENABLE_CPU) 107 add_compile_definitions(ENABLE_CPU) 108endif() 109 110if(ENABLE_D) 111 add_compile_definitions(ENABLE_D) 112 add_compile_definitions(CUSTOM_OP) 113endif() 114 115if(USE_GLOG) 116 add_compile_definitions(USE_GLOG) 117endif() 118 119if(ENABLE_PROFILE) 120 add_compile_definitions(ENABLE_PROFILE) 121endif() 122 123if(ENABLE_SECURITY) 124 add_compile_definitions(ENABLE_SECURITY) 125endif() 126 127if(ENABLE_TIMELINE) 128 add_compile_definitions(ENABLE_TIMELINE) 129endif() 130 131if(ENABLE_LOAD_ANF_IR) 132 add_compile_definitions(ENABLE_LOAD_ANF_IR) 133endif() 134 135if(ENABLE_TESTCASES) 136 add_compile_definitions(ENABLE_TEST) 137endif() 138 139if(ENABLE_TESTCASES OR (NOT ENABLE_D)) 140 add_compile_definitions(NO_DLIB=1) 141endif() 142 143if(NOT (ENABLE_TESTCASES OR ENABLE_TEST) AND (ENABLE_D OR ENABLE_GPU OR ENABLE_CPU)) 144 add_compile_definitions(WITH_BACKEND) 145endif() 146 147if(ENABLE_DUMP_IR) 148 add_compile_definitions(ENABLE_DUMP_IR) 149endif() 150 151if(ENABLE_FFMPEG) 152 add_compile_definitions(ENABLE_FFMPEG) 153endif() 154 155if(ENABLE_MINDDATA) 156 add_compile_definitions(ENABLE_MINDDATA) 157 if(ENABLE_TDTQUE) 158 add_compile_definitions(ENABLE_TDTQUE) 159 endif() 160endif() 161 162if(ENABLE_DEBUGGER) 163 add_compile_definitions(ENABLE_DEBUGGER) 164endif() 165 166if(ENABLE_DEBUGGER OR ENABLE_TESTCASES) 167 set(MS_BUILD_GRPC ON) 168endif() 169if(ENABLE_MINDDATA AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows") 170 set(MS_BUILD_GRPC ON) 171endif() 172 173if(ENABLE_D AND ENABLE_ACL) 174 set(MODE_ASCEND_ALL ON) 175endif() 176 177if(ENABLE_ACL AND NOT ENABLE_D) 178 set(MODE_ASCEND_ACL ON) 179endif() 180 181if(ENABLE_CPU AND NOT WIN32) 182 add_compile_definitions(ENABLE_ARMOUR) 183endif() 184 185if(ENABLE_AKG AND CMAKE_SYSTEM_NAME MATCHES "Linux") 186 add_compile_definitions(ENABLE_AKG) 187endif() 188 189if(USE_LLVM) 190 add_compile_definitions(USE_LLVM) 191endif() 192 193if(USE_MS_THREADPOOL_FOR_DNNL) 194 add_compile_definitions(USE_MS_THREADPOOL_FOR_DNNL) 195endif() 196 197if(ENABLE_DVM) 198 add_compile_definitions(ENABLE_DVM) 199endif() 200