Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
irexyc committed Jul 28, 2022
1 parent 8f317d8 commit e2ec6bb
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 40 deletions.
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ else ()
set(MMDEPLOY_LIB_TYPE STATIC)
endif ()

if (MMDEPLOY_BUILD_SDK_CSHARP_API)
set(MMDEPLOY_BUILD_SDK_MONOLITHIC ON)
endif ()

set(MMDEPLOY_TASKS "" CACHE INTERNAL "")

# when CUDA devices are enabled, the environment variable ASAN_OPTIONS=protect_shadow_gap=0
Expand Down
2 changes: 1 addition & 1 deletion cmake/MMDeployConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set(MMDEPLOY_VERSION_MAJOR @MMDEPLOY_VERSION_MAJOR@)
set(MMDEPLOY_VERSION_MINOR @MMDEPLOY_VERSION_MINOR@)
set(MMDEPLOY_VERSION_PATCH @MMDEPLOY_VERSION_PATCH@)

if (NOT MMDEPLOY_BUILD_SHARED)
if (NOT MMDEPLOY_BUILD_SHARED AND NOT MMDEPLOY_BUILD_SDK_MONOLITHIC)
if ("cuda" IN_LIST MMDEPLOY_TARGET_DEVICES)
find_package(CUDA REQUIRED)
if(MSVC)
Expand Down
26 changes: 12 additions & 14 deletions csrc/mmdeploy/apis/c/mmdeploy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ macro(add_object name)
if (NOT MSVC)
target_compile_options(${name} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fvisibility=hidden>)
endif ()
target_link_libraries(${name} PRIVATE mmdeploy::core)
set(CAPI_OBJS ${CAPI_OBJS} ${name})
mmdeploy_export(${name})
endmacro()

set(COMMON_LIST
Expand All @@ -24,12 +26,10 @@ set(TASK_LIST ${MMDEPLOY_TASKS})

foreach (TASK ${COMMON_LIST})
set(TARGET_NAME mmdeploy_${TASK})
if (MMDEPLOY_BUILD_SDK_MONOLITHIC)
add_object(${TARGET_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${TASK}.cpp)
else ()
mmdeploy_add_library(${TARGET_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${TASK}.cpp)
endif()
target_link_libraries(${TARGET_NAME} PRIVATE mmdeploy::core)
set(OBJECT_NAME mmdeploy_${TASK}_obj)
add_object(${OBJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${TASK}.cpp)
mmdeploy_add_library(${TARGET_NAME})
target_link_libraries(${TARGET_NAME} PRIVATE ${OBJECT_NAME})
target_include_directories(${TARGET_NAME} PUBLIC
$<INSTALL_INTERFACE:include>)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${TASK}.h
Expand All @@ -43,13 +43,11 @@ target_link_libraries(mmdeploy_pipeline PUBLIC

foreach (TASK ${TASK_LIST})
set(TARGET_NAME mmdeploy_${TASK})
if (MMDEPLOY_BUILD_SDK_MONOLITHIC)
add_object(${TARGET_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${TASK}.cpp)
else ()
mmdeploy_add_library(${TARGET_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${TASK}.cpp)
endif ()
target_link_libraries(${TARGET_NAME} PRIVATE
mmdeploy_pipeline mmdeploy::core)
set(OBJECT_NAME mmdeploy_${TASK}_obj)
add_object(${OBJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${TASK}.cpp)
mmdeploy_add_library(${TARGET_NAME})
target_link_libraries(${TARGET_NAME} PRIVATE ${OBJECT_NAME}
mmdeploy_pipeline)
target_include_directories(${TARGET_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:include>)
Expand All @@ -61,7 +59,7 @@ if (MMDEPLOY_BUILD_SDK_CSHARP_API OR MMDEPLOY_BUILD_SDK_MONOLITHIC)
add_library(mmdeploy SHARED)
mmdeploy_load_static(mmdeploy MMDeployStaticModules)
mmdeploy_load_dynamic(mmdeploy MMDeployDynamicModules)
target_link_libraries(mmdeploy PRIVATE MMDeployLibs ${CAPI_OBJS})
target_link_libraries(mmdeploy PRIVATE ${CAPI_OBJS})
target_include_directories(mmdeploy PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:include>)
Expand Down
10 changes: 3 additions & 7 deletions csrc/mmdeploy/apis/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@ endforeach ()

pybind11_add_module(${PROJECT_NAME} ${MMDEPLOY_PYTHON_SRCS})

if (MMDEPLOY_BUILD_SDK_MONOLITHIC)
target_link_libraries(${PROJECT_NAME} PRIVATE mmdeploy)
else ()
mmdeploy_load_static(${PROJECT_NAME} MMDeployStaticModules)
mmdeploy_load_dynamic(${PROJECT_NAME} MMDeployDynamicModules)
target_link_libraries(${PROJECT_NAME} PRIVATE MMDeployLibs)
endif ()
mmdeploy_load_static(${PROJECT_NAME} MMDeployStaticModules)
mmdeploy_load_dynamic(${PROJECT_NAME} MMDeployDynamicModules)
target_link_libraries(${PROJECT_NAME} PRIVATE MMDeployLibs)

target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/..
Expand Down
2 changes: 1 addition & 1 deletion demo/csrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy"))
endif ()

function(add_example task name)
if (${task} IN_LIST MMDEPLOY_TASKS)
if (TARGET mmdeploy_${task})
# Search for c/cpp sources
file(GLOB _SRCS ${name}.c*)
add_executable(${name} ${_SRCS})
Expand Down
19 changes: 6 additions & 13 deletions tests/test_csrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,9 @@ if (NOT (MMDEPLOY_SHARED_LIBS OR MSVC))
target_compile_options(mmdeploy_tests PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fvisibility=hidden>)
endif ()

if (MMDEPLOY_BUILD_SDK_MONOLITHIC)
target_link_libraries(mmdeploy_tests PRIVATE
MMDeployLibs
mmdeploy
mmdeploy_transform)
else ()
mmdeploy_load_static(mmdeploy_tests MMDeployStaticModules)
mmdeploy_load_dynamic(mmdeploy_tests MMDeployDynamicModules)
target_link_libraries(mmdeploy_tests PRIVATE
MMDeployLibs
mmdeploy_transform
mmdeploy_opencv_utils)
endif ()
mmdeploy_load_static(mmdeploy_tests MMDeployStaticModules)
mmdeploy_load_dynamic(mmdeploy_tests MMDeployDynamicModules)
target_link_libraries(mmdeploy_tests PRIVATE
MMDeployLibs
mmdeploy_transform
mmdeploy_opencv_utils)

0 comments on commit e2ec6bb

Please sign in to comment.