CMakeLists.txt 1.7 KB
Newer Older
1 2 3
include_directories("./src/include")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
4 5 6 7 8 9 10 11 12
file(
  GLOB_RECURSE
  SOURCES
  ./*.cpp
  ../src/core/test/*.cpp
  ../src/gopt/test/*.cpp
  ../src/opr/test/*.cpp
  ../src/plugin/test/*.cpp
  ../src/serialization/test/*.cpp)
13
if(MGE_WITH_JIT)
14 15
  file(GLOB_RECURSE SOURCES_ ../src/jit/test/*.cpp)
  list(APPEND SOURCES ${SOURCES_})
16 17
endif()
if(MGE_WITH_DISTRIBUTED)
18 19
  file(GLOB_RECURSE SOURCES_ ../src/opr-mm/test/*.cpp)
  list(APPEND SOURCES ${SOURCES_})
20
endif()
21 22 23
if(MGE_WITH_CUDA AND MGE_WITH_TRT)
  file(GLOB_RECURSE SOURCES_ ../src/tensorrt/test/*.cpp)
  list(APPEND SOURCES ${SOURCES_})
24 25 26
endif()

add_executable(megbrain_test ${SOURCES})
27
if(WIN32 OR MSVC)
28
  target_compile_definitions(megbrain_test PRIVATE MGE_WINDOWS_STATIC_LINK)
29
endif()
M
Megvii Engine Team 已提交
30
target_link_libraries(megbrain_test gtest gmock)
31
target_link_libraries(megbrain_test megbrain megdnn ${MGE_CUDA_LIBS})
32 33
if(MGE_WITH_CUDA)
  target_include_directories(megbrain_test PRIVATE ${CUDNN_INCLUDE_DIR})
34
endif()
35
if(CXX_SUPPORT_WCLASS_MEMACCESS)
36 37 38 39 40 41 42 43
  if(MGE_WITH_CUDA)
    target_compile_options(
      megbrain_test
      PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=-Wno-class-memaccess>"
              "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:-Wno-class-memaccess>")
  else()
    target_compile_options(megbrain_test PRIVATE "-Wno-class-memaccess")
  endif()
44 45
endif()

46
if(UNIX)
47 48 49 50 51
  if(APPLE OR ANDROID)
    target_link_libraries(megbrain_test dl)
  else()
    target_link_libraries(megbrain_test dl rt)
  endif()
52 53
endif()

54 55
if(MGE_WITH_DISTRIBUTED)
  target_link_libraries(megbrain_test megray)
56
endif()
57 58

if(MGE_WITH_JIT)
59 60 61 62
  if(MGE_WITH_JIT_MLIR)
    add_subdirectory(${PROJECT_SOURCE_DIR}/src/jit/test/mlir
                     ${CMAKE_CURRENT_BINARY_DIR}/../src/jit/test/mlir)
  endif()
63
endif()