mindspore/cmake/options.cmake

128 lines
3.7 KiB
CMake
Raw Normal View History

option(ENABLE_D "Enable d" OFF)
option(ENABLE_GPU "Enable gpu" OFF)
option(ENABLE_CPU "Enable cpu" OFF)
option(ENABLE_GE "Enable graph engine as backend to execute" OFF)
option(ENABLE_MINDDATA "Enable minddata compile" OFF)
option(ENABLE_TRAIN "Enable ge train, default off(only infer)" OFF)
option(ENABLE_TESTCASES "Run testcases switch, default off" OFF)
option(ENABLE_CPP_ST "Run cpp st testcases switch, default off" OFF)
option(DEBUG_MODE "Debug mode, default off" OFF)
option(ENABLE_ASAN "Enable Google Sanitizer to find memory bugs")
option(ENABLE_LOAD_ANF_IR "Enable load ANF-IR as input of 'infer' stage of pipeline" OFF)
option(ENABLE_COVERAGE "Enable code coverage report" OFF)
option(USE_GLOG "Use glog to output log" OFF)
option(ENABLE_PROFILE "Enable pipeline profile, default off" OFF)
option(ENABLE_TIMELINE "Enable time line record" OFF)
option(ENABLE_DUMP_PROTO "Enable dump anf graph to file in ProtoBuffer format, default on" ON)
2021-01-23 20:20:31 +08:00
option(ENABLE_DUMP_IR "Enable dump function graph ir, default on" ON)
option(ENABLE_MPI "enable mpi" OFF)
option(ENABLE_AKG "enable akg" OFF)
2020-06-11 22:42:57 +08:00
option(ENABLE_DEBUGGER "enable debugger" OFF)
2020-06-08 15:31:37 +08:00
option(ENABLE_IBVERBS "enable IBVERBS for parameter server" OFF)
2020-07-11 04:26:00 +08:00
option(ENABLE_PYTHON "Enable python" ON)
option(ENABLE_ACL "enable acl" OFF)
2021-01-23 20:20:31 +08:00
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(WIN32)
2020-04-15 17:36:48 +08:00
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -fstack-protector-all")
else()
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack")
endif()
endif()
2021-01-23 20:20:31 +08:00
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -Wsign-compare")
endif()
2021-01-23 20:20:31 +08:00
if(ENABLE_COVERAGE)
set(COVERAGE_COMPILER_FLAGS "-g --coverage -fprofile-arcs -ftest-coverage")
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}")
endif()
2021-01-23 20:20:31 +08:00
if(ENABLE_ASAN)
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -fsanitize=address -fsanitize-recover=address -fno-omit-frame-pointer")
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -static-libsan")
endif()
endif()
2021-01-23 20:20:31 +08:00
if(DEBUG_MODE)
set(CMAKE_BUILD_TYPE "Debug")
2020-04-17 16:45:50 +08:00
else()
set(CMAKE_BUILD_TYPE "Release")
endif()
2021-01-23 20:20:31 +08:00
if((CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") OR (CMAKE_BUILD_TYPE STREQUAL Release))
set(PYBIND11_LTO_CXX_FLAGS FALSE)
endif()
2021-01-23 20:20:31 +08:00
if(NOT BUILD_PATH)
set(BUILD_PATH "${CMAKE_SOURCE_DIR}/build")
endif()
2021-01-23 20:20:31 +08:00
if(ENABLE_GE OR ENABLE_D)
set(ENABLE_TDTQUE ON)
endif()
2021-01-23 20:20:31 +08:00
if(ENABLE_GPU)
set(ENABLE_GPUQUE ON)
2020-04-15 22:18:50 +08:00
add_compile_definitions(ENABLE_GPU_COLLECTIVE)
endif()
2021-01-23 20:20:31 +08:00
if(ENABLE_CPU)
add_compile_definitions(ENABLE_CPU)
endif()
2021-01-23 20:20:31 +08:00
if(ENABLE_GE)
add_compile_definitions(ENABLE_GE)
add_compile_definitions(CUSTOM_OP)
endif()
if(ENABLE_TRAIN)
add_compile_definitions(ENABLE_TRAIN=1)
else()
add_compile_definitions(ENABLE_TRAIN=0)
endif()
if(USE_GLOG)
add_compile_definitions(USE_GLOG)
endif()
2021-01-23 20:20:31 +08:00
if(ENABLE_PROFILE)
add_compile_definitions(ENABLE_PROFILE)
endif()
2021-01-23 20:20:31 +08:00
if(ENABLE_TIMELINE)
add_compile_definitions(ENABLE_TIMELINE)
endif()
2021-01-23 20:20:31 +08:00
if(ENABLE_LOAD_ANF_IR)
add_compile_definitions(ENABLE_LOAD_ANF_IR)
endif()
2021-01-23 20:20:31 +08:00
if(ENABLE_TESTCASES OR (NOT ENABLE_D AND NOT ENABLE_GE))
add_compile_definitions(NO_DLIB=1)
endif()
if(ENABLE_DUMP_IR)
add_compile_definitions(ENABLE_DUMP_IR)
2021-01-23 20:20:31 +08:00
endif()
if(ENABLE_MINDDATA)
add_compile_definitions(ENABLE_MINDDATA)
2021-01-23 20:20:31 +08:00
if(ENABLE_TDTQUE)
add_compile_definitions(ENABLE_TDTQUE)
endif()
endif()
2020-06-11 22:42:57 +08:00
if(ENABLE_DEBUGGER)
add_compile_definitions(ENABLE_DEBUGGER)
endif()
2020-09-11 15:07:17 +08:00
2021-01-23 20:20:31 +08:00
if(ENABLE_DEBUGGER OR ENABLE_TESTCASES)
2020-09-11 15:07:17 +08:00
set(MS_BUILD_GRPC ON)
endif()
2021-01-23 20:20:31 +08:00
if(ENABLE_MINDDATA AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
2020-09-11 15:07:17 +08:00
set(MS_BUILD_GRPC ON)
endif()