CMakeLists.txt 10.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
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})
L
liubuyu 已提交
20
include_directories(${CMAKE_SOURCE_DIR}/mindspore/core)
Z
zhunaipan 已提交
21 22 23 24 25 26 27 28 29 30
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)
L
liubuyu 已提交
31 32
    link_directories(${MS_CCSRC_BUILD_PATH}/minddata/dataset)
    link_directories(${MS_CCSRC_BUILD_PATH}/minddata/mindrecord)
Z
zhunaipan 已提交
33 34 35
endif()
# fetch ut test files
if(ENABLE_MINDDATA)
E
ervinzhang 已提交
36 37 38 39 40 41
    file(GLOB_RECURSE UT_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ./*.cc)
    if(NOT ENABLE_PYTHON)
        set(PYTHON_RELATED_SRCS
            dataset/filter_op_test.cc
            dataset/voc_op_test.cc
            dataset/manifest_op_test.cc
42
            dataset/sentence_piece_vocab_op_test.cc
E
ervinzhang 已提交
43 44 45
        )
        list(REMOVE_ITEM UT_SRCS ${PYTHON_RELATED_SRCS})
    endif()
Z
zhunaipan 已提交
46 47 48 49 50 51 52 53
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()
54 55 56 57
# removing serving ut
file(GLOB_RECURSE SERVING_ACL_UT_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} serving/*.cc)
list(REMOVE_ITEM UT_SRCS ${SERVING_ACL_UT_SRCS})
add_subdirectory(serving)
Z
zhunaipan 已提交
58 59

file(GLOB_RECURSE MINDSPORE_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
60 61
        "../../../mindspore/core/base/*.cc"
        "../../../mindspore/core/abstract/*.cc"
L
liubuyu 已提交
62
        "../../../mindspore/core/ir/*.cc"
L
liubuyu 已提交
63
        "../../../mindspore/core/utils/*.cc"
W
WilliamLian 已提交
64
        "../../../mindspore/core/c_ops/*.cc"
Z
zhunaipan 已提交
65 66
        "../../../mindspore/ccsrc/common/*.cc"
        "../../../mindspore/ccsrc/utils/*.cc"
L
liubuyu 已提交
67 68 69 70 71 72 73 74 75 76
        "../../../mindspore/ccsrc/pipeline/jit/parse/*.cc"
        "../../../mindspore/ccsrc/pipeline/jit/static_analysis/*.cc"
        "../../../mindspore/ccsrc/pipeline/jit/pipeline.cc"
        "../../../mindspore/ccsrc/pipeline/jit/resource.cc"
        "../../../mindspore/ccsrc/pipeline/jit/pass.cc"
        "../../../mindspore/ccsrc/pipeline/jit/action.cc"
        "../../../mindspore/ccsrc/pipeline/jit/validator.cc"
        "../../../mindspore/ccsrc/pipeline/jit/remove_value_node_dup.cc"
        "../../../mindspore/ccsrc/frontend/optimizer/*.cc"
        "../../../mindspore/ccsrc/frontend/parallel/*.cc"
Z
zhunaipan 已提交
77
        "../../../mindspore/ccsrc/debug/*.cc"
L
liubuyu 已提交
78 79 80 81 82 83 84 85
        "../../../mindspore/ccsrc/frontend/operator/*.cc"
        "../../../mindspore/ccsrc/transform/graph_ir/*.cc"
        "../../../mindspore/ccsrc/backend/session/anf_runtime_algorithm.cc"
        "../../../mindspore/ccsrc/backend/session/ascend_session.cc"
        "../../../mindspore/ccsrc/backend/session/ascend_control_parser.cc"
        "../../../mindspore/ccsrc/backend/session/kernel_graph.cc"
        "../../../mindspore/ccsrc/backend/session/session_basic.cc"
        "../../../mindspore/ccsrc/backend/session/session_factory.cc"
86
        "../../../mindspore/ccsrc/backend/session/kernel_build_client.cc"
Z
zhunaipan 已提交
87
        "../../../mindspore/ccsrc/vm/*.cc"
L
liubuyu 已提交
88
        "../../../mindspore/ccsrc/pipeline/pynative/*.cc"
Z
zhunaipan 已提交
89
        "../../../mindspore/ccsrc/pybind_api/*.cc"
L
liubuyu 已提交
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
        "../../../mindspore/ccsrc/backend/kernel_compiler/akg/*.cc"
        "../../../mindspore/ccsrc/backend/kernel_compiler/kash/*.cc"
        "../../../mindspore/ccsrc/backend/kernel_compiler/rts/*.cc"
        "../../../mindspore/ccsrc/backend/kernel_compiler/hccl/*.cc"
        "../../../mindspore/ccsrc/backend/kernel_compiler/kernel_query.cc"
        "../../../mindspore/ccsrc/backend/kernel_compiler/kernel_build_info.cc"
        "../../../mindspore/ccsrc/backend/optimizer/ascend/*.cc"
        "../../../mindspore/ccsrc/backend/optimizer/common/*.cc"
        "../../../mindspore/ccsrc/backend/optimizer/gpu/*.cc"
        "../../../mindspore/ccsrc/backend/optimizer/mem_reuse/*.cc"
        "../../../mindspore/ccsrc/backend/optimizer/pass/*.cc"
        "../../../mindspore/ccsrc/backend/kernel_compiler/aicpu/aicpu_kernel_metadata.cc"
        "../../../mindspore/ccsrc/backend/kernel_compiler/rts/rt_kernel_info.cc"
        "../../../mindspore/ccsrc/backend/kernel_compiler/common_utils.cc"
        "../../../mindspore/ccsrc/backend/kernel_compiler/oplib/*.cc"
        "../../../mindspore/ccsrc/backend/kernel_compiler/tbe/*.cc"
        "../../../mindspore/ccsrc/runtime/device/kernel_runtime.cc"
        "../../../mindspore/ccsrc/runtime/device/memory_manager.cc"
        "../../../mindspore/ccsrc/runtime/device/kernel_runtime_manager.cc"
        "../../../mindspore/ccsrc/runtime/device/kernel_info.cc"
        "../../../mindspore/ccsrc/runtime/device/ascend/profiling/*.cc"
        "../../../mindspore/ccsrc/runtime/device/ascend/kernel_select_ascend.cc"
        "../../../mindspore/ccsrc/runtime/device/ascend/kernel_select_graph_kernel.cc"
        "../../../mindspore/ccsrc/runtime/device/convert_tensor_utils.cc"
        "../../../mindspore/ccsrc/runtime/device/ascend/kernel_build_ascend.cc"
        "../../../mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc"
        "../../../mindspore/ccsrc/runtime/device/ascend/ascend_memory_manager.cc"
        "../../../mindspore/ccsrc/runtime/device/ascend/ascend_device_address.cc"
        "../../../mindspore/ccsrc/runtime/device/ascend/ascend_memory_pool.cc"
Z
zhunaipan 已提交
119 120 121 122 123 124
        "../../../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"
L
liubuyu 已提交
125 126 127 128 129 130
        "../../../mindspore/ccsrc/backend/kernel_compiler/cpu/cpu_kernel.cc"
        "../../../mindspore/ccsrc/backend/kernel_compiler/cpu/cpu_kernel_factory.cc"
        "../../../mindspore/ccsrc/backend/kernel_compiler/cpu/sparse_apply_adam_cpu_kernel.cc"
        "../../../mindspore/ccsrc/backend/kernel_compiler/cpu/sparse_apply_ftrl_cpu_kernel.cc"
        "../../../mindspore/ccsrc/backend/kernel_compiler/cpu/sparse_apply_lazy_adam_cpu_kernel.cc"
        "../../../mindspore/ccsrc/backend/kernel_compiler/cpu/sparse_apply_proximal_adagrad_cpu_kernel.cc"
Z
zhunaipan 已提交
131 132
        )

133 134 135 136 137
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
    list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/common/duplex_pipe.cc")
else()
    list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/common/duplex_pipe_win.cc")
endif()
Z
zhunaipan 已提交
138
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/debug/dump_proto.cc")
L
liubuyu 已提交
139 140 141 142 143 144
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/core/ir/lite/tensor.cc")
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/frontend/parallel/strategy_checkpoint/parallel_strategy_checkpoint.cc")
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/frontend/parallel/ps/util.cc")
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/frontend/parallel/ps/scheduler.cc")
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/frontend/parallel/ps/optimizer_info.cc")
list(REMOVE_ITEM MINDSPORE_SRC_LIST "../../../mindspore/ccsrc/frontend/parallel/ps/optimizer_info_builder.cc")
Z
zhunaipan 已提交
145 146
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 已提交
147 148
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 已提交
149

S
Shida He 已提交
150 151 152 153 154 155
# 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 已提交
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
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"
        )

171
add_executable(ut_tests ${UT_SRCS} ${MINDSPORE_SRC_LIST} ${UT_SUTB_SRC_LIST} $<TARGET_OBJECTS:ut_serving_obj>)
Z
zhunaipan 已提交
172 173 174

if (ENABLE_GE)
    if(ENABLE_TRAIN)
J
jiangjinsheng 已提交
175
        target_link_libraries(ut_tests PRIVATE graph ge_runner)
Z
zhunaipan 已提交
176 177 178 179 180 181 182 183
    else()
        target_link_libraries(ut_tests PRIVATE graph ge_client)
    endif()

    target_link_libraries(mindspore PRIVATE tsdclient)
endif()

if (CMAKE_SYSTEM_NAME MATCHES "Linux")
L
liubuyu 已提交
184
    target_link_libraries(ut_tests PRIVATE mindspore::gtest mindspore_gvar ${PYTHON_LIBRARIES} pthread util dl)
Z
zhunaipan 已提交
185 186 187 188
    if (ENABLE_MINDDATA)
        target_link_libraries(ut_tests PRIVATE _c_dataengine _c_mindrecord)
    endif()
else()
L
liubuyu 已提交
189
    target_link_libraries(ut_tests PRIVATE mindspore::gtest mindspore_gvar ${PYTHON_LIBRARIES})
Z
zhunaipan 已提交
190 191 192 193 194 195
endif()
if (USE_GLOG)
    target_link_libraries(ut_tests PRIVATE mindspore::glog)
endif()

target_link_libraries(ut_tests PRIVATE securec graph)
196 197 198 199 200 201 202 203 204 205 206

# link grpc
if (EXISTS ${grpc_ROOT}/lib64)
    set(gRPC_DIR "${grpc_ROOT}/lib64/cmake/grpc")
else ()
    set(gRPC_DIR "${grpc_ROOT}/lib/cmake/grpc")
endif ()
find_package(gRPC CONFIG REQUIRED)
target_link_libraries(ut_tests PRIVATE gRPC::grpc++)
target_link_libraries(ut_tests PRIVATE gRPC::grpc++_reflection)
target_link_libraries(ut_tests PRIVATE protobuf::libprotobuf)