Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ SerialPrograms/bin/
discord_social_sdk_win/
discord_partner_sdk.dll
3rdPartyBinaries/discord_social_sdk_mac/
3rdPartyBinaries/onnxruntime-osx-arm64-*/
3rdPartyBinaries/onnxruntime-osx-x86_64-*/


# macOS hidden system file
.DS_Store
Expand Down
Binary file added 3rdPartyBinaries/onnxruntime-osx-arm64-1.23.2.tgz
Binary file not shown.
Binary file not shown.
37 changes: 19 additions & 18 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -343,25 +343,26 @@ if (WIN32)
else() # macOS and Linux
find_package(PkgConfig REQUIRED) # required to execute `pkg_search_module()` below
if (APPLE)
# ==== Get ONNX Runtime paths ====
# First, try to see if there is an ONNX Runtime library built from source.
# Assume the onnxruntime repo, https://github.com/microsoft/onnxruntime is placed in the same folder as
# this Arduino-Source repo:
set(ONNXRUNTIME_ROOTDIR "${REPO_ROOT_DIR}../onnxruntime/")
set(ONNXRUNTIME_HEADER_DIR "${ONNXRUNTIME_ROOTDIR}include/onnxruntime/core/session/")
if(EXISTS "${ONNXRUNTIME_HEADER_DIR}")
# we have ONNX Runtime built from source
message("Use ONNX Runtime built from source at ${ONNXRUNTIME_ROOTDIR}")
target_include_directories(SerialProgramsLib PRIVATE ${ONNXRUNTIME_HEADER_DIR})
target_link_libraries(SerialProgramsLib PRIVATE ${ONNXRUNTIME_ROOTDIR}/build/MacOS/Release/libonnxruntime.dylib)
# prepare onnxruntime if needed
set(ONNXRUNTIME_VERSION "1.23.2")
set(ONNXRUNTIME_WORK_DIR "${REPO_ROOT_DIR}/3rdPartyBinaries")
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
set(ONNXRUNTIME_ARCH "arm64")
else()
message("Built-from-source ONNX Runtime folder ${ONNXRUNTIME_ROOTDIR} does not exist.")
message("Use ONNX Runtime installed by Homebrew.")
pkg_search_module(ONNXRUNTIME REQUIRED libonnxruntime onnxruntime)
target_include_directories(SerialProgramsLib PRIVATE ${ONNXRUNTIME_INCLUDE_DIRS})
target_link_directories(SerialProgramsLib PUBLIC ${ONNXRUNTIME_LIBRARY_DIRS})
target_link_libraries(SerialProgramsLib PUBLIC ${ONNXRUNTIME_LINK_LIBRARIES})
set(ONNXRUNTIME_ARCH "x86_64")
endif()
set(ONNXRUNTIME_LIB_DIR "${ONNXRUNTIME_WORK_DIR}/onnxruntime-osx-${ONNXRUNTIME_ARCH}-${ONNXRUNTIME_VERSION}")
set(ONNXRUNTIME_LIB_TAR "${ONNXRUNTIME_LIB_DIR}.tgz")
set(ONNXRUNTIME_DYLIB "${ONNXRUNTIME_LIB_DIR}/lib/libonnxruntime.dylib")
if (NOT EXISTS "${ONNXRUNTIME_LIB_DIR}")
message(STATUS "ONNXRUNTIME not found, extracting from tgz...")
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xf "${ONNXRUNTIME_LIB_TAR}"
WORKING_DIRECTORY "${ONNXRUNTIME_WORK_DIR}"
)
endif()
target_include_directories(SerialProgramsLib SYSTEM PRIVATE "${ONNXRUNTIME_LIB_DIR}/include")
target_link_libraries(SerialProgramsLib PRIVATE "${ONNXRUNTIME_DYLIB}")
else() # Linux
# ONNX RUNTIME LINUX CONFIG
# NOTE: users can specify their own ONNX_ROOT_PATH (this is the base folder for ONNX) on the command line when evoking cmake.
Expand Down Expand Up @@ -505,7 +506,7 @@ else() # macOS and Linux
target_compile_options(SerialProgramsLib PRIVATE -Wall -Wextra -Wpedantic -Werror -fno-strict-aliasing)
endif()

IF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
# Arm CPU
# Run-time ISA dispatching
target_compile_definitions(SerialProgramsLib PRIVATE PA_AutoDispatch_arm64_20_M1)
Expand Down