Fangjun Kuang
Committed by GitHub

Build building for iOS (#430)

@@ -104,6 +104,8 @@ message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") @@ -104,6 +104,8 @@ message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
104 104
105 if(DEFINED ENV{SHERPA_ONNXRUNTIME_INCLUDE_DIR}) 105 if(DEFINED ENV{SHERPA_ONNXRUNTIME_INCLUDE_DIR})
106 set(location_onnxruntime_header_dir $ENV{SHERPA_ONNXRUNTIME_INCLUDE_DIR}) 106 set(location_onnxruntime_header_dir $ENV{SHERPA_ONNXRUNTIME_INCLUDE_DIR})
  107 +
  108 + include_directories(${location_onnxruntime_header_dir})
107 else() 109 else()
108 find_path(location_onnxruntime_header_dir onnxruntime_cxx_api.h 110 find_path(location_onnxruntime_header_dir onnxruntime_cxx_api.h
109 PATHS 111 PATHS
@@ -122,6 +124,11 @@ if(DEFINED ENV{SHERPA_ONNXRUNTIME_LIB_DIR}) @@ -122,6 +124,11 @@ if(DEFINED ENV{SHERPA_ONNXRUNTIME_LIB_DIR})
122 endif() 124 endif()
123 if(NOT EXISTS ${location_onnxruntime_lib}) 125 if(NOT EXISTS ${location_onnxruntime_lib})
124 set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.a) 126 set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.a)
  127 + if(NOT EXISTS ${location_onnxruntime_lib})
  128 + message(FATAL_ERROR "${location_onnxruntime_lib} cannot be found")
  129 + endif()
  130 + set(onnxruntime_lib_files $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.a)
  131 + message("Use static lib: ${onnxruntime_lib_files}")
125 endif() 132 endif()
126 if(SHERPA_ONNX_ENABLE_GPU) 133 if(SHERPA_ONNX_ENABLE_GPU)
127 set(location_onnxruntime_cuda_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime_providers_cuda.so) 134 set(location_onnxruntime_cuda_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime_providers_cuda.so)
@@ -153,6 +160,7 @@ if(SHERPA_ONNX_ENABLE_GPU) @@ -153,6 +160,7 @@ if(SHERPA_ONNX_ENABLE_GPU)
153 endif() 160 endif()
154 161
155 if(location_onnxruntime_header_dir AND location_onnxruntime_lib) 162 if(location_onnxruntime_header_dir AND location_onnxruntime_lib)
  163 + if(NOT DEFINED onnxruntime_lib_files)
156 add_library(onnxruntime SHARED IMPORTED) 164 add_library(onnxruntime SHARED IMPORTED)
157 set_target_properties(onnxruntime PROPERTIES 165 set_target_properties(onnxruntime PROPERTIES
158 IMPORTED_LOCATION ${location_onnxruntime_lib} 166 IMPORTED_LOCATION ${location_onnxruntime_lib}
@@ -164,6 +172,7 @@ if(location_onnxruntime_header_dir AND location_onnxruntime_lib) @@ -164,6 +172,7 @@ if(location_onnxruntime_header_dir AND location_onnxruntime_lib)
164 IMPORTED_LOCATION ${location_onnxruntime_cuda_lib} 172 IMPORTED_LOCATION ${location_onnxruntime_cuda_lib}
165 ) 173 )
166 endif() 174 endif()
  175 + endif()
167 else() 176 else()
168 message(STATUS "Could not find a pre-installed onnxruntime. Downloading pre-compiled onnxruntime") 177 message(STATUS "Could not find a pre-installed onnxruntime. Downloading pre-compiled onnxruntime")
169 download_onnxruntime() 178 download_onnxruntime()