CMakeLists.txt 2.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
# BUILD the load and run for lite
include_directories(PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lite/load_and_run/src>)
file (GLOB_RECURSE SOURCES ./*.cpp)

add_executable (load_and_run  ${SOURCES})

target_link_libraries(load_and_run lite_static)
target_link_libraries(load_and_run megbrain)
target_link_libraries(load_and_run gflags)

if(LITE_BUILD_WITH_RKNPU)
    #rknn sdk1.0.0 depend on libc++_shared, use gold to remove NEEDED so symbol check
    target_link_options(load_and_run  PRIVATE "-fuse-ld=gold")
endif()

if(MGE_WITH_ROCM)
    # FIXME: hip obj can not find cpp obj only through lite_static
    target_link_libraries(load_and_run megdnn)
endif()

if(UNIX)
    if(APPLE OR ANDROID)
        target_link_libraries(load_and_run dl)
    else()
        target_link_libraries(load_and_run dl rt)
    endif()
endif()

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
install (TARGETS load_and_run EXPORT ${LITE_EXPORT_TARGETS} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
# FIXME: using shared lib to build load and run(lite shared lib is not work correctly )
# if(BUILD_SHARED_LIBS)
#     add_executable(load_and_run_depends_shared ${SOURCES})
#     target_link_libraries(load_and_run_depends_shared lite_shared)
#     target_link_libraries(load_and_run_depends_shared megengine)
#     target_link_libraries(load_and_run_depends_shared gflags)
    
#     if(WIN32 OR MSVC)
#         target_compile_definitions(load_and_run_depends_shared PRIVATE MGE_DLL_IMPORT_DATA)
#     endif()

#     if(LITE_BUILD_WITH_RKNPU)
#         #rknn sdk1.0.0 depend on libc++_shared, use gold to remove NEEDED so symbol check
#         target_link_options(load_and_run_depends_shared  PRIVATE "-fuse-ld=gold")
#     endif()

#     if(MGE_WITH_ROCM)
#         # FIXME: hip obj can not find cpp obj only through lite_static
#         target_link_libraries(load_and_run_depends_shared megdnn)
#     endif()

#     if(UNIX)
#         if(APPLE OR ANDROID)
#             target_link_libraries(load_and_run_depends_shared dl)
#         else()
#             target_link_libraries(load_and_run_depends_shared dl rt)
#         endif()
#     endif()

#     install(TARGETS load_and_run_depends_shared EXPORT ${MGE_EXPORT_TARGETS} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
# endif()