Skip to content

Commit

Permalink
improve arch detection on apple
Browse files Browse the repository at this point in the history
  • Loading branch information
skyline75489 committed Sep 25, 2024
1 parent d32bbe5 commit e9e2c25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cmake/global_variables.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if(WIN32)
set(ONNXRUNTIME_PROVIDERS_CUDA_LIB "onnxruntime_providers_cuda.dll")
set(ONNXRUNTIME_PROVIDERS_ROCM_LIB "onnxruntime_providers_rocm.dll")
elseif(APPLE)
if(BUILD_APPLE_FRAMEWORK)
if(IOS OR MAC_CATALYST)
add_library(onnxruntime IMPORTED STATIC)
if(PLATFORM_NAME STREQUAL "macabi")
# The xcframework in cmake doesn't seem to support MacCatalyst.
Expand Down Expand Up @@ -70,7 +70,7 @@ file(GLOB generator_srcs CONFIGURE_DEPENDS

set(ortgenai_embed_libs "") # shared libs that will be embedded inside the onnxruntime-genai package

if (BUILD_APPLE_FRAMEWORK)
if (IOS OR MAC_CATALYST)
if (NOT EXISTS "${ORT_LIB_DIR}/onnxruntime.xcframework")
message(FATAL_ERROR "Expected the ONNX Runtime XCFramework to be found at ${ORT_LIB_DIR}/onnxruntime.xcframework. Actual: Not found.")
endif()
Expand Down
4 changes: 3 additions & 1 deletion cmake/ortlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ else()
else()
set(ORT_BINARY_PLATFORM "x64")
if (APPLE)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
if(IOS)
set(ORT_BINARY_PLATFORM ${IOS_ARCH})
elseif(CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
set(ORT_BINARY_PLATFORM "arm64")
endif()
set(ORT_LIB_DIR ${ortlib_SOURCE_DIR}/runtimes/osx-${ORT_BINARY_PLATFORM}/native)
Expand Down

0 comments on commit e9e2c25

Please sign in to comment.