2021-12-07 10:57:55 +08:00
|
|
|
# Copyright (c) OpenMMLab. All rights reserved.
|
|
|
|
cmake_minimum_required(VERSION 3.14)
|
|
|
|
project(mmdeploy_core)
|
|
|
|
|
|
|
|
#[==[
|
|
|
|
Refer to: https://cmake.org/cmake/help/latest/command/file.html
|
|
|
|
Note We do not recommend using GLOB to collect a list of source files from your source tree.
|
|
|
|
If no CMakeLists.txt file changes when a source is added or removed then the generated build
|
|
|
|
system cannot know when to ask CMake to regenerate. The CONFIGURE_DEPENDS flag may not work
|
|
|
|
reliably on all generators, or if a new generator is added in the future that cannot support it,
|
|
|
|
projects using it will be stuck. Even if CONFIGURE_DEPENDS works reliably, there is still a cost
|
|
|
|
to perform the check on every rebuild.
|
|
|
|
#]==]
|
|
|
|
set(SPDLOG_LIB)
|
|
|
|
find_package(spdlog QUIET)
|
|
|
|
if (spdlog_FOUND)
|
|
|
|
message(STATUS "spdlog is found")
|
2022-02-24 20:08:44 +08:00
|
|
|
set(SPDLOG_LIB spdlog::spdlog)
|
2021-12-07 10:57:55 +08:00
|
|
|
endif ()
|
|
|
|
|
2022-02-24 20:08:44 +08:00
|
|
|
include(${CMAKE_SOURCE_DIR}/cmake/MMDeploy.cmake)
|
2021-12-07 10:57:55 +08:00
|
|
|
|
|
|
|
set(SRCS
|
|
|
|
device_impl.cpp
|
|
|
|
logger.cpp
|
|
|
|
graph.cpp
|
|
|
|
mat.cpp
|
|
|
|
model.cpp
|
|
|
|
module.cpp
|
|
|
|
net.cpp
|
|
|
|
operator.cpp
|
|
|
|
status_code.cpp
|
|
|
|
tensor.cpp
|
2022-02-24 20:08:44 +08:00
|
|
|
registry.cpp
|
2021-12-21 10:47:21 +08:00
|
|
|
utils/device_utils.cpp
|
2021-12-07 10:57:55 +08:00
|
|
|
utils/formatter.cpp
|
|
|
|
utils/stacktrace.cpp)
|
2022-02-24 20:08:44 +08:00
|
|
|
|
|
|
|
mmdeploy_add_library(${PROJECT_NAME} ${SRCS})
|
2021-12-21 21:32:39 +08:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC -DMMDEPLOY_STATUS_USE_SOURCE_LOCATION=1)
|
2022-02-24 20:08:44 +08:00
|
|
|
|
2021-12-21 21:32:39 +08:00
|
|
|
target_include_directories(${PROJECT_NAME}
|
2021-12-07 10:57:55 +08:00
|
|
|
PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/csrc>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/third_party/outcome>
|
2021-12-21 21:32:39 +08:00
|
|
|
# TODO: remove dependency of `json`
|
2021-12-07 10:57:55 +08:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/third_party/json>
|
|
|
|
$<INSTALL_INTERFACE:include/cpp>
|
|
|
|
)
|
2022-02-24 20:08:44 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${SPDLOG_LIB})
|
2022-03-25 23:28:16 +08:00
|
|
|
if (NOT (MSVC OR ANDROID))
|
2022-02-24 20:08:44 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC stdc++fs)
|
|
|
|
endif ()
|
2021-12-21 21:32:39 +08:00
|
|
|
add_library(mmdeploy::core ALIAS ${PROJECT_NAME})
|
2021-12-07 10:57:55 +08:00
|
|
|
|
2021-12-23 14:31:17 +08:00
|
|
|
install(DIRECTORY ${CMAKE_SOURCE_DIR}/csrc/core
|
2021-12-07 10:57:55 +08:00
|
|
|
DESTINATION include/cpp
|
|
|
|
FILES_MATCHING PATTERN "*.h")
|
|
|
|
install(FILES ${CMAKE_SOURCE_DIR}/third_party/outcome/outcome-experimental.hpp
|
|
|
|
DESTINATION include/cpp/core)
|
|
|
|
|
2021-12-23 14:31:17 +08:00
|
|
|
install(DIRECTORY ${CMAKE_SOURCE_DIR}/csrc/experimental
|
2021-12-07 10:57:55 +08:00
|
|
|
DESTINATION include/cpp
|
|
|
|
FILES_MATCHING PATTERN "*.h")
|