Skip to content

Commit

Permalink
Build building for iOS (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj authored Nov 16, 2023
1 parent 049fb9f commit eeda1e1
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions cmake/onnxruntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")

if(DEFINED ENV{SHERPA_ONNXRUNTIME_INCLUDE_DIR})
set(location_onnxruntime_header_dir $ENV{SHERPA_ONNXRUNTIME_INCLUDE_DIR})

include_directories(${location_onnxruntime_header_dir})
else()
find_path(location_onnxruntime_header_dir onnxruntime_cxx_api.h
PATHS
Expand All @@ -122,6 +124,11 @@ if(DEFINED ENV{SHERPA_ONNXRUNTIME_LIB_DIR})
endif()
if(NOT EXISTS ${location_onnxruntime_lib})
set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.a)
if(NOT EXISTS ${location_onnxruntime_lib})
message(FATAL_ERROR "${location_onnxruntime_lib} cannot be found")
endif()
set(onnxruntime_lib_files $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.a)
message("Use static lib: ${onnxruntime_lib_files}")
endif()
if(SHERPA_ONNX_ENABLE_GPU)
set(location_onnxruntime_cuda_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime_providers_cuda.so)
Expand Down Expand Up @@ -153,16 +160,18 @@ if(SHERPA_ONNX_ENABLE_GPU)
endif()

if(location_onnxruntime_header_dir AND location_onnxruntime_lib)
add_library(onnxruntime SHARED IMPORTED)
set_target_properties(onnxruntime PROPERTIES
IMPORTED_LOCATION ${location_onnxruntime_lib}
INTERFACE_INCLUDE_DIRECTORIES "${location_onnxruntime_header_dir}"
)
if(SHERPA_ONNX_ENABLE_GPU AND location_onnxruntime_cuda_lib)
add_library(onnxruntime_providers_cuda SHARED IMPORTED)
set_target_properties(onnxruntime_providers_cuda PROPERTIES
IMPORTED_LOCATION ${location_onnxruntime_cuda_lib}
if(NOT DEFINED onnxruntime_lib_files)
add_library(onnxruntime SHARED IMPORTED)
set_target_properties(onnxruntime PROPERTIES
IMPORTED_LOCATION ${location_onnxruntime_lib}
INTERFACE_INCLUDE_DIRECTORIES "${location_onnxruntime_header_dir}"
)
if(SHERPA_ONNX_ENABLE_GPU AND location_onnxruntime_cuda_lib)
add_library(onnxruntime_providers_cuda SHARED IMPORTED)
set_target_properties(onnxruntime_providers_cuda PROPERTIES
IMPORTED_LOCATION ${location_onnxruntime_cuda_lib}
)
endif()
endif()
else()
message(STATUS "Could not find a pre-installed onnxruntime. Downloading pre-compiled onnxruntime")
Expand Down

0 comments on commit eeda1e1

Please sign in to comment.