CMakeLists.txt 2.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
include_directories("..")

file(GLOB_RECURSE SOURCES common/*.cpp naive/*.cpp dispatcher/*.cpp)
file(GLOB SOURCES_ *.cpp)
list(APPEND SOURCES ${SOURCES_})

if(NOT ${MGE_ARCH} STREQUAL "naive")
    file(GLOB_RECURSE SOURCES_ fallback/*.cpp)
    list(APPEND SOURCES ${SOURCES_})
    file(GLOB_RECURSE SOURCES_ cpu/*.cpp)
    list(APPEND SOURCES ${SOURCES_})
    if(${MGE_ARCH} STREQUAL "fallback")
        message(WARNING "build only with fallback")
14
    elseif(${MGE_ARCH} STREQUAL "x86_64" OR ${MGE_ARCH} STREQUAL "i386")
15 16 17 18 19 20 21 22 23 24 25 26 27
        file(GLOB_RECURSE SOURCES_ x86/*.cpp)
        list(APPEND SOURCES ${SOURCES_})
    endif()
endif()

if(MGE_WITH_CUDA)
    file(GLOB_RECURSE SOURCES_ cuda/*.cpp)
    list(APPEND SOURCES ${SOURCES_})

    file(GLOB_RECURSE CUSOURCES cuda/*.cu)
    list(APPEND SOURCES ${CUSOURCES})
endif()

28 29 30
if(MGE_WITH_MIDOUT_PROFILE)
    list(APPEND SOURCES ${PROJECT_SOURCE_DIR}/third_party/midout/src/midout.cpp)
endif()
31

32 33 34 35 36 37 38 39 40 41
if(MGE_WITH_CAMBRICON)
    file(GLOB_RECURSE SOURCES_ cambricon/*.cpp)
    list(APPEND SOURCES ${SOURCES_})
endif()

if(MGE_WITH_ATLAS)
    file(GLOB_RECURSE SOURCES_ atlas/*.cpp)
    list(APPEND SOURCES ${SOURCES_})
endif()

42 43 44 45 46
if (MGE_WITH_ROCM)
    file (GLOB_RECURSE SOURCES_ rocm/*.cpp)
    list (APPEND SOURCES ${SOURCES_})
endif()

47

48
add_executable(megdnn_test ${SOURCES})
49
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing")
50
target_link_libraries(megdnn_test gtest)
51
target_link_libraries(megdnn_test megdnn ${MGE_BLAS_LIBS})
52

53 54
if (MGE_WITH_CUDA)
    target_link_libraries(megdnn_test cutlass)
55
    target_include_directories(megdnn_test PRIVATE ${CUDNN_INCLUDE_DIR})
56 57
endif()

58 59 60 61 62
target_include_directories(megdnn_test
    PRIVATE
        ${PROJECT_SOURCE_DIR}/third_party/midout/src
)

63 64 65
if(APPLE OR ANDROID)
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
else()
66 67 68 69 70 71 72
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
endif()

if(MGE_ENABLE_COVERAGE)
    set(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} --coverage")
endif()

73 74 75 76
if (MEG_WITH_ROCM)
    target_link_libraries (megdnn_test ${MGE_ROCM_LIBS})
endif ()

77 78 79 80 81 82
if(UNIX)
    if(APPLE OR ANDROID)
        target_link_libraries(megdnn_test dl)
    else()
        target_link_libraries(megdnn_test dl rt)
    endif()
83
endif()