1option(ENABLE_D "Enable d" OFF) 2option(ENABLE_GPU "Enable gpu" OFF) 3option(ENABLE_CPU "Enable cpu" OFF) 4option(ENABLE_GE "Enable graph engine as backend to execute" OFF) 5option(ENABLE_MINDDATA "Enable minddata compile" OFF) 6option(ENABLE_TRAIN "Enable ge train, default off(only infer)" OFF) 7option(ENABLE_TESTCASES "Run testcases switch, default off" OFF) 8option(ENABLE_CPP_ST "Run cpp st testcases switch, default off" OFF) 9option(DEBUG_MODE "Debug mode, default off" OFF) 10option(ENABLE_ASAN "Enable Google Sanitizer to find memory bugs") 11option(ENABLE_LOAD_ANF_IR "Enable load ANF-IR as input of 'infer' stage of pipeline" OFF) 12option(ENABLE_COVERAGE "Enable code coverage report" OFF) 13option(USE_GLOG "Use glog to output log" OFF) 14option(ENABLE_SECURITY "Enable security, maintenance function will be disabled, default off" OFF) 15option(ENABLE_PROFILE "Enable pipeline profile, default off" OFF) 16option(ENABLE_TIMELINE "Enable time line record" OFF) 17option(ENABLE_DUMP_PROTO "Enable dump anf graph to file in ProtoBuffer format, default on" ON) 18option(ENABLE_DUMP_IR "Enable dump function graph ir, default on" ON) 19option(ENABLE_MPI "enable mpi" OFF) 20option(ENABLE_AKG "enable akg" OFF) 21option(ENABLE_DEBUGGER "enable debugger" OFF) 22option(ENABLE_IBVERBS "enable IBVERBS for parameter server" OFF) 23option(ENABLE_PYTHON "Enable python" ON) 24option(ENABLE_ACL "enable acl" OFF) 25option(ENABLE_GLIBCXX "enable_glibcxx" OFF) 26option(MODE_ASCEND_ALL "supports all ascend platform" OFF) 27option(MODE_ASCEND_ACL "supports ascend acl mode only" OFF) 28option(ENABLE_SYM_FILE "enable sym file" OFF) 29 30if(NOT ENABLE_D AND NOT ENABLE_TESTCASES AND NOT ENABLE_ACL AND NOT ENABLE_GE) 31 set(ENABLE_GLIBCXX ON) 32endif() 33 34if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 35 if(WIN32) 36 set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -fstack-protector-all") 37 else() 38 set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack") 39 endif() 40endif() 41 42if(CMAKE_SYSTEM_NAME MATCHES "Darwin") 43 set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -Wsign-compare") 44endif() 45 46if(ENABLE_COVERAGE) 47 set(COVERAGE_COMPILER_FLAGS "-g --coverage -fprofile-arcs -ftest-coverage") 48 set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}") 49endif() 50 51if(ENABLE_ASAN) 52 set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -fsanitize=address -fsanitize-recover=address -fno-omit-frame-pointer") 53 if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 54 set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -static-libsan") 55 endif() 56endif() 57 58if(DEBUG_MODE) 59 set(CMAKE_BUILD_TYPE "Debug") 60 add_compile_definitions(MEM_REUSE_DEBUG) 61else() 62 set(CMAKE_BUILD_TYPE "Release") 63endif() 64 65if((CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") OR (CMAKE_BUILD_TYPE STREQUAL Release)) 66 set(PYBIND11_LTO_CXX_FLAGS FALSE) 67endif() 68 69if(NOT BUILD_PATH) 70 set(BUILD_PATH "${CMAKE_SOURCE_DIR}/build") 71endif() 72 73if(ENABLE_GE OR ENABLE_D) 74 set(ENABLE_TDTQUE ON) 75endif() 76 77if(ENABLE_GPU) 78 set(ENABLE_GPUQUE ON) 79 add_compile_definitions(ENABLE_GPU_COLLECTIVE) 80endif() 81 82if(ENABLE_CPU) 83 add_compile_definitions(ENABLE_CPU) 84endif() 85 86if(ENABLE_GE) 87 add_compile_definitions(ENABLE_GE) 88 add_compile_definitions(CUSTOM_OP) 89endif() 90 91if(ENABLE_TRAIN) 92 add_compile_definitions(ENABLE_TRAIN=1) 93else() 94 add_compile_definitions(ENABLE_TRAIN=0) 95endif() 96 97if(USE_GLOG) 98 add_compile_definitions(USE_GLOG) 99endif() 100 101if(ENABLE_PROFILE) 102 add_compile_definitions(ENABLE_PROFILE) 103endif() 104 105if(ENABLE_SECURITY) 106 add_compile_definitions(ENABLE_SECURITY) 107endif() 108 109if(ENABLE_TIMELINE) 110 add_compile_definitions(ENABLE_TIMELINE) 111endif() 112 113if(ENABLE_LOAD_ANF_IR) 114 add_compile_definitions(ENABLE_LOAD_ANF_IR) 115endif() 116 117if(ENABLE_TESTCASES OR (NOT ENABLE_D AND NOT ENABLE_GE)) 118 add_compile_definitions(NO_DLIB=1) 119endif() 120 121if(ENABLE_DUMP_IR) 122 add_compile_definitions(ENABLE_DUMP_IR) 123endif() 124 125if(ENABLE_MINDDATA) 126 add_compile_definitions(ENABLE_MINDDATA) 127 if(ENABLE_TDTQUE) 128 add_compile_definitions(ENABLE_TDTQUE) 129 endif() 130endif() 131 132if(ENABLE_DEBUGGER) 133 add_compile_definitions(ENABLE_DEBUGGER) 134endif() 135 136if(ENABLE_DEBUGGER OR ENABLE_TESTCASES) 137 set(MS_BUILD_GRPC ON) 138endif() 139if(ENABLE_MINDDATA AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows") 140 set(MS_BUILD_GRPC ON) 141endif() 142 143if(ENABLE_D AND ENABLE_ACL) 144 set(MODE_ASCEND_ALL ON) 145endif() 146 147if(ENABLE_ACL AND NOT ENABLE_D) 148 set(MODE_ASCEND_ACL ON) 149endif() 150 151if(ENABLE_CPU AND NOT WIN32) 152 add_compile_definitions(ENABLE_ARMOUR) 153endif() 154