You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 2.2 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. include_directories("..")
  2. file(GLOB_RECURSE SOURCES common/*.cpp naive/*.cpp dispatcher/*.cpp)
  3. file(GLOB SOURCES_ *.cpp)
  4. list(APPEND SOURCES ${SOURCES_})
  5. if(NOT ${MGE_ARCH} STREQUAL "naive")
  6. file(GLOB_RECURSE SOURCES_ fallback/*.cpp)
  7. list(APPEND SOURCES ${SOURCES_})
  8. file(GLOB_RECURSE SOURCES_ cpu/*.cpp)
  9. list(APPEND SOURCES ${SOURCES_})
  10. if(${MGE_ARCH} STREQUAL "fallback")
  11. message(WARNING "build only with fallback")
  12. elseif(${MGE_ARCH} STREQUAL "x86_64" OR ${MGE_ARCH} STREQUAL "i386")
  13. file(GLOB_RECURSE SOURCES_ x86/*.cpp)
  14. list(APPEND SOURCES ${SOURCES_})
  15. endif()
  16. endif()
  17. if(MGE_WITH_CUDA)
  18. file(GLOB_RECURSE SOURCES_ cuda/*.cpp)
  19. list(APPEND SOURCES ${SOURCES_})
  20. file(GLOB_RECURSE CUSOURCES cuda/*.cu)
  21. list(APPEND SOURCES ${CUSOURCES})
  22. endif()
  23. if(MGE_WITH_MIDOUT_PROFILE)
  24. list(APPEND SOURCES ${PROJECT_SOURCE_DIR}/third_party/midout/src/midout.cpp)
  25. endif()
  26. if(MGE_WITH_ATLAS)
  27. file(GLOB_RECURSE SOURCES_ atlas/*.cpp)
  28. list(APPEND SOURCES ${SOURCES_})
  29. endif()
  30. if(MGE_WITH_ROCM)
  31. file(GLOB_RECURSE SOURCES_ rocm/*.cpp)
  32. list(APPEND SOURCES ${SOURCES_})
  33. endif()
  34. add_executable(megdnn_test ${SOURCES})
  35. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing")
  36. target_link_libraries(megdnn_test gtest)
  37. target_link_libraries(megdnn_test megdnn ${MGE_BLAS_LIBS} ${MGE_CUDA_LIBS})
  38. if(MGE_WITH_CUDA)
  39. target_link_libraries(megdnn_test cutlass)
  40. target_include_directories(megdnn_test PRIVATE ${CUDNN_INCLUDE_DIR})
  41. endif()
  42. if(MGE_WITH_ATLAS)
  43. target_link_libraries(megdnn_test atlas-stub)
  44. endif()
  45. target_include_directories(megdnn_test
  46. PRIVATE ${PROJECT_SOURCE_DIR}/third_party/midout/src)
  47. if(APPLE OR ANDROID)
  48. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
  49. else()
  50. set(CMAKE_EXE_LINKER_FLAGS
  51. "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
  52. endif()
  53. if(MGE_ENABLE_COVERAGE)
  54. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
  55. endif()
  56. if(MEG_WITH_ROCM)
  57. target_link_libraries(megdnn_test ${MGE_ROCM_LIBS})
  58. endif()
  59. if(UNIX)
  60. if(APPLE OR ANDROID)
  61. target_link_libraries(megdnn_test dl)
  62. else()
  63. target_link_libraries(megdnn_test dl rt)
  64. endif()
  65. endif()