Add remove_duplicate_libraries function

This commit is contained in:
zhoushunjie
2022-09-26 11:24:57 +08:00
parent f142fcdf60
commit ad03e771dd
5 changed files with 38 additions and 20 deletions

View File

@@ -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()