Skip to content

Commit

Permalink
Add remove_duplicate_libraries function
Browse files Browse the repository at this point in the history
  • Loading branch information
joey12300 committed Sep 26, 2022
1 parent f142fcd commit ad03e77
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ install(
${PROJECT_SOURCE_DIR}/ThirdPartyNotices.txt
${PROJECT_SOURCE_DIR}/VERSION_NUMBER
${PROJECT_SOURCE_DIR}/FastDeploy.cmake
${PROJECT_SOURCE_DIR}/FastDeployUtils.cmake
${PROJECT_SOURCE_DIR}/cmake/utils.cmake
DESTINATION ${CMAKE_INSTALL_PREFIX}
)
install(
Expand Down
5 changes: 4 additions & 1 deletion FastDeploy.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set(FASTDEPLOY_INCS "")
list(APPEND FASTDEPLOY_INCS ${CMAKE_CURRENT_LIST_DIR}/include)

# Note(zhoushunjie): include some useful utils function
include(${CMAKE_CURRENT_LIST_DIR}/FastDeployUtils.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/utils.cmake)

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
Expand Down Expand Up @@ -112,6 +112,9 @@ if(ENABLE_PADDLE_FRONTEND)
list(APPEND FASTDEPLOY_LIBS ${PADDLE2ONNX_LIB})
endif()

message("FASTDEPLOY_LIBS = ${FASTDEPLOY_LIBS}")
remove_duplicate_libraries(FASTDEPLOY_LIBS)

# Print compiler information
message(STATUS "")
message(STATUS "*************FastDeploy Building Summary**********")
Expand Down
17 changes: 0 additions & 17 deletions FastDeployUtils.cmake

This file was deleted.

1 change: 0 additions & 1 deletion cmake/openvino.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ file(REMOVE_RECURSE ${THIRD_PARTY_PATH}/install/${OPENVINO_FILENAME}/samples)
file(REMOVE_RECURSE ${THIRD_PARTY_PATH}/install/${OPENVINO_FILENAME}/setupvars.sh)
file(REMOVE_RECURSE ${THIRD_PARTY_PATH}/install/${OPENVINO_FILENAME}/tools)

include(${PROJECT_SOURCE_DIR}/FastDeployUtils.cmake)
get_openvino_libs(${OPENVINO_INSTALL_DIR})
message("OPENVINO_LIBS = ${OPENVINO_LIBS}")
list(APPEND DEPEND_LIBS ${OPENVINO_LIBS})
33 changes: 33 additions & 0 deletions cmake/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,36 @@ function(download_and_decompress url filename decompress_dir)
message("Decompress file ${filename} ...")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xf ${filename} WORKING_DIRECTORY ${decompress_dir})
endfunction()

function(get_openvino_libs OPENVINO_RUNTIME_DIR)
set(LIB_LIST "")
find_library(OPENVINO_LIB openvino ${OPENVINO_RUNTIME_DIR}/lib/ NO_DEFAULT_PATH)
list(APPEND LIB_LIST ${OPENVINO_LIB})

find_package(TBB PATHS "${OPENVINO_RUNTIME_DIR}/3rdparty/tbb")
if (TBB_FOUND)
list(APPEND LIB_LIST ${TBB_IMPORTED_TARGETS})
else()
# TODO(zhoushunjie): Use openvino with tbb on linux in future.
set(OMP_LIB "${OPENVINO_RUNTIME_DIR}/3rdparty/omp/lib/libiomp5.so")
list(APPEND LIB_LIST ${OMP_LIB})
endif()
set(OPENVINO_LIBS ${LIB_LIST} PARENT_SCOPE)
endfunction()

function(remove_duplicate_libraries libraries)
list(LENGTH ${libraries} lib_length)
set(libraries_temp "")
set(full_libraries "")
foreach(lib_path ${${libraries}})
get_filename_component(lib_name ${lib_path} NAME)
list(FIND libraries_temp ${lib_name} lib_idx)
if (${lib_idx} EQUAL -1)
list(APPEND libraries_temp ${lib_name})
list(APPEND full_libraries ${lib_path})
endif()
endforeach()
set(${libraries} ${full_libraries} PARENT_SCOPE)
list(LENGTH full_libraries lib_length)
endfunction()

0 comments on commit ad03e77

Please sign in to comment.