CMakeLists.txt 1.9 KB
Newer Older
1 2 3 4 5 6 7
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
set(MGB_TEST_DIR ${PROJECT_SOURCE_DIR}/test/src)

file(GLOB_RECURSE SOURCES ../src/test/*.cpp ../src/impl/*.cpp ${MGB_TEST_DIR}/*.cpp)

# disable distributed tests
if(NOT MGE_WITH_DISTRIBUTED)
8 9
  list(FILTER SOURCES EXCLUDE REGEX ".*test/collective_comm.cpp")
  list(FILTER SOURCES EXCLUDE REGEX ".*test/io_remote.cpp")
10 11 12 13
endif()

# TODO: turn python binding into a static/object library
add_executable(imperative_test ${SOURCES} ${SRCS})
14
add_dependencies(imperative_test mgb_opdef)
15 16 17
target_include_directories(
  imperative_test PRIVATE ${MGB_TEST_DIR}/include ../src/include ${MGB_OPDEF_OUT_DIR}
                          ${CPP_REDIS_INCLUDES})
18 19

# Python binding
20 21 22
target_include_directories(
  imperative_test PRIVATE ${MODULE_SRC_INCLUDE} ${PYTHON_INCLUDE_DIRS}
                          ${NUMPY_INCLUDE_DIR})
23 24 25
target_compile_definitions(imperative_test PRIVATE MODULE_NAME=C)
target_compile_options(imperative_test PRIVATE -Wno-unused-parameter)

26 27 28 29 30 31 32 33 34
set(LINK_LIBS
    megbrain
    megdnn
    ${MGE_CUDA_LIBS}
    gtest
    gmock
    pybind11::embed
    range-v3
    nlohmann_json::nlohmann_json)
35

36
if(MGE_WITH_CUDA)
37
  list(APPEND LINK_LIBS cudart)
38 39
endif()

40 41 42 43
if(MGE_WITH_CUPTI)
  list(APPEND LINK_LIBS libcupti)
endif()

44
if(MGE_WITH_DISTRIBUTED)
45
  list(APPEND LINK_LIBS megray)
46 47 48 49
endif()

target_link_libraries(imperative_test ${LINK_LIBS})
if(CXX_SUPPORT_WCLASS_MEMACCESS)
50 51 52 53 54 55 56 57
  if(MGE_WITH_CUDA)
    target_compile_options(
      imperative_test
      PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=-Wno-class-memaccess>"
              "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:-Wno-class-memaccess>")
  else()
    target_compile_options(imperative_test PRIVATE "-Wno-class-memaccess")
  endif()
58 59 60
endif()

if(UNIX)
61 62 63 64 65
  if(APPLE OR ANDROID)
    target_link_libraries(imperative_test dl)
  else()
    target_link_libraries(imperative_test dl rt)
  endif()
66 67 68
endif()

install(TARGETS imperative_test RUNTIME DESTINATION test)