CMakeLists.txt 8.0 KB
Newer Older
Z
zhunaipan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
message("build ut testcases...")

# virtual project for common include and library file path.
project(ut)

set(PROJECT_DIR "${PROJECT_SOURCE_DIR}/../../..")
add_compile_definitions(ENABLE_DUMP_E2E)
if(ENABLE_DUMP_IR)
    add_compile_definitions(ENABLE_DUMP_IR)
endif(ENABLE_DUMP_IR)
if(ENABLE_D)
    add_compile_definitions(ENABLE_D)
endif()

#add python lib and include for all ut executables;
message("PYTHON_INCLUDE_DIRS = ${PYTHON_INCLUDE_DIRS}")
message("PYTHON_LIBRARIES = ${PYTHON_LIBRARIES}")
include_directories(${PYTHON_INCLUDE_DIRS})
include_directories(${MS_CCSRC_PATH})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/stub/runtime/)
include_directories(${CMAKE_BINARY_DIR})
include_directories(${CUDA_INCLUDE_DIRS})
MESSAGE("check  ut_test ${CMAKE_BINARY_DIR}")

link_directories(${MS_CCSRC_BUILD_PATH})

if(ENABLE_MINDDATA)
    add_definitions(-D ENABLE_MINDDATA)
    link_directories(${MS_CCSRC_BUILD_PATH}/dataset)
    link_directories(${MS_CCSRC_BUILD_PATH}/mindrecord)
endif()
# fetch ut test files
if(ENABLE_MINDDATA)
    file(GLOB_RECURSE UT_SRCS ./*.cc)
else()
    file(GLOB_RECURSE TEMP_UT_SRCS ./*.cc)
    foreach(OBJ ${TEMP_UT_SRCS})
        if (NOT ${OBJ} MATCHES "./dataset/" AND NOT ${OBJ} MATCHES "./mindrecord/")
            list(APPEND UT_SRCS ${OBJ})
        endif()
    endforeach ()
endif()

file(GLOB_RECURSE MINDSPORE_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
        "../../../mindspore/ccsrc/ir/*.cc"
        "../../../mindspore/ccsrc/common/*.cc"
        "../../../mindspore/ccsrc/utils/*.cc"
        "../../../mindspore/ccsrc/parallel/*.cc"
        "../../../mindspore/ccsrc/pipeline/parse/*.cc"
        "../../../mindspore/ccsrc/pipeline/static_analysis/*.cc"
        "../../../mindspore/ccsrc/pipeline/pipeline.cc"
        "../../../mindspore/ccsrc/pipeline/resource.cc"
        "../../../mindspore/ccsrc/pipeline/pass.cc"
        "../../../mindspore/ccsrc/pipeline/action.cc"
        "../../../mindspore/ccsrc/pipeline/validator.cc"
        "../../../mindspore/ccsrc/pipeline/remove_value_node_dup.cc"
        "../../../mindspore/ccsrc/optimizer/*.cc"
        "../../../mindspore/ccsrc/debug/*.cc"
        "../../../mindspore/ccsrc/operator/*.cc"
        "../../../mindspore/ccsrc/transform/*.cc"
        "../../../mindspore/ccsrc/session/anf_runtime_algorithm.cc"
        "../../../mindspore/ccsrc/session/ascend_session.cc"
Z
zhoufeng 已提交
64
        "../../../mindspore/ccsrc/session/ascend_control_parser.cc"
Z
zhunaipan 已提交
65 66 67 68 69 70 71 72 73
        "../../../mindspore/ccsrc/session/kernel_graph.cc"
        "../../../mindspore/ccsrc/session/session_basic.cc"
        "../../../mindspore/ccsrc/session/session_factory.cc"
        "../../../mindspore/ccsrc/vm/*.cc"
        "../../../mindspore/ccsrc/pynative/*.cc"
        "../../../mindspore/ccsrc/pybind_api/*.cc"
        "../../../mindspore/ccsrc/kernel/akg/*.cc"
        "../../../mindspore/ccsrc/kernel/kash/*.cc"
        "../../../mindspore/ccsrc/kernel/cce/*.cc"
D
dengwentao 已提交
74
        "../../../mindspore/ccsrc/kernel/rts/*.cc"
Z
zhunaipan 已提交
75 76 77 78 79 80 81 82 83
        "../../../mindspore/ccsrc/kernel/hccl/*.cc"
        "../../../mindspore/ccsrc/kernel/kernel_query.cc"
        "../../../mindspore/ccsrc/kernel/kernel_build_info.cc"
        "../../../mindspore/ccsrc/pre_activate/ascend/*.cc"
        "../../../mindspore/ccsrc/pre_activate/common/*.cc"
        "../../../mindspore/ccsrc/pre_activate/gpu/*.cc"
        "../../../mindspore/ccsrc/pre_activate/mem_reuse/*.cc"
        "../../../mindspore/ccsrc/pre_activate/pass/*.cc"
        "../../../mindspore/ccsrc/kernel/aicpu/aicpu_kernel_metadata.cc"
D
dengwentao 已提交
84
        "../../../mindspore/ccsrc/kernel/rts/rt_kernel_info.cc"
Z
zhunaipan 已提交
85 86 87 88
        "../../../mindspore/ccsrc/kernel/common_utils.cc"
        "../../../mindspore/ccsrc/kernel/oplib/*.cc"
        "../../../mindspore/ccsrc/kernel/tbe/*.cc"
        "../../../mindspore/ccsrc/device/kernel_runtime.cc"
K
kswang 已提交
89
        "../../../mindspore/ccsrc/device/memory_manager.cc"
Z
zhunaipan 已提交
90 91 92 93
        "../../../mindspore/ccsrc/device/kernel_runtime_manager.cc"
        "../../../mindspore/ccsrc/device/kernel_info.cc"
        "../../../mindspore/ccsrc/device/ascend/profiling/*.cc"
        "../../../mindspore/ccsrc/device/ascend/kernel_select_ascend.cc"
G
gong chen 已提交
94
        "../../../mindspore/ccsrc/device/ascend/kernel_select_graph_kernel.cc"
Z
zhunaipan 已提交
95 96 97
        "../../../mindspore/ccsrc/device/convert_tensor_utils.cc"
        "../../../mindspore/ccsrc/device/ascend/kernel_build_ascend.cc"
        "../../../mindspore/ccsrc/device/ascend/ascend_kernel_runtime.cc"
K
kswang 已提交
98
        "../../../mindspore/ccsrc/device/ascend/ascend_memory_manager.cc"
Z
zhunaipan 已提交
99
        "../../../mindspore/ccsrc/device/ascend/ascend_device_address.cc"
K
kswang 已提交
100
        "../../../mindspore/ccsrc/device/ascend/ascend_memory_pool.cc"
Z
zhunaipan 已提交
101 102 103 104 105 106
        "../../../mindspore/ccsrc/predict/generator/utils/ir_model_util.cc"
        "../../../mindspore/ccsrc/predict/predict.cc"
        "../../../mindspore/ccsrc/predict/converter/*.cc"
        "../../../mindspore/ccsrc/predict/converter/attr_utils/*.cc"
        "../../../mindspore/ccsrc/predict/converter/lite_model/*.cc"
        "../../../mindspore/ccsrc/predict/converter/lite_model/operations/*.cc"
107 108 109 110 111 112
        "../../../mindspore/ccsrc/kernel/cpu/cpu_kernel.cc"
        "../../../mindspore/ccsrc/kernel/cpu/cpu_kernel_factory.cc"
        "../../../mindspore/ccsrc/kernel/cpu/sparse_apply_adam_cpu_kernel.cc"
        "../../../mindspore/ccsrc/kernel/cpu/sparse_apply_ftrl_cpu_kernel.cc"
        "../../../mindspore/ccsrc/kernel/cpu/sparse_apply_lazy_adam_cpu_kernel.cc"
        "../../../mindspore/ccsrc/kernel/cpu/sparse_apply_proximal_adagrad_cpu_kernel.cc"
Z
zhunaipan 已提交
113 114 115
        )

list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/debug/dump_proto.cc")
H
hangangqiang 已提交
116
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/ir/lite/tensor.cc")
Z
zhunaipan 已提交
117
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/parallel/strategy_checkpoint/parallel_strategy_checkpoint.cc")
Z
ZPaC 已提交
118 119
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/parallel/ps/util.cc")
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/parallel/ps/scheduler.cc")
Z
ZPaC 已提交
120
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/parallel/ps/optimizer_info.cc")
Z
zhunaipan 已提交
121 122
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/utils/anf_ir.pb.cc")
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/utils/node_strategy.pb.cc")
H
hangangqiang 已提交
123 124
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/utils/load_onnx/anf_model_parser.cc")
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/utils/load_onnx/anf_converter.cc")
Z
zhunaipan 已提交
125

S
Shida He 已提交
126 127 128 129 130 131
# remove files for debugger
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/debug/debugger/debugger.cc")
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/debug/debugger/grpc_client.cc")
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/debug/debug_services.cc")
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/debug/debugger/proto_exporter.cc")

Z
zhunaipan 已提交
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
file(GLOB_RECURSE UT_SUTB_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
        "stub/aicpu/*.cc"
        "stub/cce/*.cc"
        "stub/tdt/*.cc"
        "stub/tasksink/*.cc"
        "stub/device/*.cc"
        "stub/kernel/*.cc"
        "stub/runtime/*.cc"
        "stub/anf_ir/*.cc"
        "stub/profiling/*.cc"
        "stub/parallel_strategy_checkpoint/*.cc"
        "stub/hccl/*.cc"
        "stub/ge/*.cc"
        )

add_executable(ut_tests ${UT_SRCS} ${MINDSPORE_SRC_LIST} ${UT_SUTB_SRC_LIST})

if (ENABLE_GE)
    if(ENABLE_TRAIN)
J
jiangjinsheng 已提交
151
        target_link_libraries(ut_tests PRIVATE graph ge_runner)
Z
zhunaipan 已提交
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
    else()
        target_link_libraries(ut_tests PRIVATE graph ge_client)
    endif()

    target_link_libraries(mindspore PRIVATE tsdclient)
endif()

if (CMAKE_SYSTEM_NAME MATCHES "Linux")
    target_link_libraries(ut_tests PRIVATE mindspore::gtest mindspore_gvar ${PYTHON_LIBRARIES} pthread util dl)
    if (ENABLE_MINDDATA)
        target_link_libraries(ut_tests PRIVATE _c_dataengine _c_mindrecord)
    endif()
else()
    target_link_libraries(ut_tests PRIVATE mindspore::gtest mindspore_gvar ${PYTHON_LIBRARIES})
endif()
if (USE_GLOG)
    target_link_libraries(ut_tests PRIVATE mindspore::glog)
endif()

target_link_libraries(ut_tests PRIVATE securec graph)