CMakeLists.txt 2.7 KB
Newer Older
1
# BUILD the load and run for lite
2 3
include_directories(PUBLIC
                    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lite/load_and_run/src>)
M
Megvii Engine Team 已提交
4
file(GLOB_RECURSE SOURCES ./*.cpp ${PROJECT_SOURCE_DIR}/lite/src/pack_model/*.cpp)
5

6
add_executable(load_and_run ${SOURCES})
7 8
target_link_libraries(load_and_run lite_static)
target_link_libraries(load_and_run megbrain)
9 10 11 12 13
if(APPLE)
  target_link_libraries(load_and_run gflags)
else()
  target_link_libraries(load_and_run gflags -Wl,--version-script=${MGE_VERSION_SCRIPT})
endif()
14 15

if(LITE_BUILD_WITH_RKNPU)
16 17
  # 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")
18 19 20
endif()

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

if(UNIX)
26 27 28 29 30
  if(APPLE OR ANDROID)
    target_link_libraries(load_and_run dl)
  else()
    target_link_libraries(load_and_run dl rt)
  endif()
31 32
endif()

33
if(LITE_BUILD_WITH_MGE
34 35
   AND NOT WIN32
   AND NOT APPLE)
36 37 38 39
  # FXIME third_party cpp redis do not support build with clang-cl
  target_include_directories(load_and_run PRIVATE ${CPP_REDIS_INCLUDES})
endif()

40 41 42 43
install(
  TARGETS load_and_run
  EXPORT ${LITE_EXPORT_TARGETS}
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
44
if(BUILD_SHARED_LIBS)
45
  if(LITE_BUILD_WITH_MGE
46 47
     AND NOT WIN32
     AND NOT APPLE)
48 49 50
    # FXIME third_party cpp redis do not support build with clang-cl
    list(APPEND SOURCES ${CPP_REDIS_SRCS})
  endif()
51 52 53 54
  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 gflags)
  target_link_libraries(load_and_run_depends_shared megengine)
55

56 57 58 59 60 61 62 63 64
  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()
65

66 67 68 69 70
  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)
71
    endif()
72
  endif()
73

74
  if(LITE_BUILD_WITH_MGE
75 76
     AND NOT WIN32
     AND NOT APPLE)
77 78 79 80 81
    # FXIME third_party cpp redis do not support build with clang-cl
    target_include_directories(load_and_run_depends_shared
                               PRIVATE ${CPP_REDIS_INCLUDES})
  endif()

82 83 84 85
  install(
    TARGETS load_and_run_depends_shared
    EXPORT ${MGE_EXPORT_TARGETS}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
86
endif()