mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 16:48:03 +08:00

* [cmake] support Android arm64-v8a & armeabi-v7a native c++ sdk * [cmake] fixed patchelf download on mac and android * [lite] Add threads and power_mode option support * [pybind] update runtime pybind for lite power mode * [python] Add set_lite_power_mode api to runtime * [Lite] add lite enable_fp16 option support * [lite] add more options for lite backend. * [cmake] fixed Paddle Lite typo * [runtime] format LitePowerMode enum comments * [runtime] format lite option comments * [win] Add fastdeploy_init.bat and update docs * [win] Add fastdeploy_init.bat and update docs
66 lines
2.4 KiB
CMake
66 lines
2.4 KiB
CMake
# This function comes from https://blog.csdn.net/yindongjie1221/article/details/90614261
|
|
function(redefine_file_macro targetname)
|
|
get_target_property(source_files "${targetname}" SOURCES)
|
|
foreach(sourcefile ${source_files})
|
|
get_property(defs SOURCE "${sourcefile}"
|
|
PROPERTY COMPILE_DEFINITIONS)
|
|
get_filename_component(filepath "${sourcefile}" ABSOLUTE)
|
|
string(REPLACE ${PROJECT_SOURCE_DIR}/ "" relpath ${filepath})
|
|
list(APPEND defs "__REL_FILE__=\"${relpath}\"")
|
|
set_property(
|
|
SOURCE "${sourcefile}"
|
|
PROPERTY COMPILE_DEFINITIONS ${defs}
|
|
)
|
|
endforeach()
|
|
endfunction()
|
|
|
|
function(download_and_decompress url filename decompress_dir)
|
|
if(NOT EXISTS ${filename})
|
|
message("Downloading file from ${url} to ${filename} ...")
|
|
file(DOWNLOAD ${url} "${filename}.tmp" SHOW_PROGRESS)
|
|
file(RENAME "${filename}.tmp" ${filename})
|
|
endif()
|
|
if(NOT EXISTS ${decompress_dir})
|
|
file(MAKE_DIRECTORY ${decompress_dir})
|
|
endif()
|
|
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 PATHS ${OPENVINO_RUNTIME_DIR}/lib/ ${OPENVINO_RUNTIME_DIR}/lib/intel64 NO_DEFAULT_PATH)
|
|
list(APPEND LIB_LIST ${OPENVINO_LIB})
|
|
|
|
set(TBB_DIR ${OPENVINO_RUNTIME_DIR}/3rdparty/tbb/cmake)
|
|
find_package(TBB PATHS ${TBB_DIR})
|
|
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)
|
|
endfunction()
|
|
|
|
function(get_windows_path win_path origin_path)
|
|
STRING(REGEX REPLACE "/" "\\\\" _win_path ${origin_path})
|
|
set(${win_path} ${_win_path} PARENT_SCOPE)
|
|
endfunction()
|