Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NeoMathEngine] macOS cross-compilation fix #1052

Merged
merged 1 commit into from
Apr 24, 2024
Merged
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
12 changes: 9 additions & 3 deletions NeoMathEngine/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,14 @@ if(ANDROID OR LINUX)
)
endif()

set(BUILD_ARCH ${CMAKE_SYSTEM_PROCESSOR})
# macOS cross-compilation
if(USE_FINE_OBJECTS)
set(BUILD_ARCH FINE_CMAKE_BUILD_ARCH)
endif()

# CPU specific settings
if((DARWIN AND CMAKE_SYSTEM_PROCESSOR MATCHES "^arm64.*") OR (ANDROID AND ANDROID_ABI MATCHES "^arm.*") OR (IOS AND IOS_ARCH MATCHES "^arm.*"))
if((DARWIN AND BUILD_ARCH MATCHES "^arm64.*") OR (ANDROID AND ANDROID_ABI MATCHES "^arm.*") OR (IOS AND IOS_ARCH MATCHES "^arm.*"))
set(CPU_ARM_SOURCES
CPU/arm/CpuArmMathEngineBlas.cpp
CPU/arm/CpuArmMathEngineDnn.cpp
Expand Down Expand Up @@ -479,7 +485,7 @@ endif()
# SSE2
if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
target_compile_options(${PROJECT_NAME} PRIVATE /arch:SSE2)
elseif(((LINUX OR DARWIN) AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86.*") OR (ANDROID AND ANDROID_ABI MATCHES "^x86.*") OR (IOS_ARCH MATCHES "^x86.*"))
elseif(((LINUX OR DARWIN) AND BUILD_ARCH MATCHES "x86.*") OR (ANDROID AND ANDROID_ABI MATCHES "^x86.*") OR (IOS_ARCH MATCHES "^x86.*"))
target_compile_options(${PROJECT_NAME} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-msse2>)
endif()

Expand All @@ -489,7 +495,7 @@ if(ANDROID AND ANDROID_ABI STREQUAL "armeabi-v7a")
endif()

# MKL
if(NOT ANDROID AND NOT IOS AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86.*)|(amd64)|(AMD64)")
if(NOT ANDROID AND NOT IOS AND BUILD_ARCH MATCHES "(x86.*)|(amd64)|(AMD64)")

if(USE_FINE_OBJECTS)
set(ENV{MKLROOT} ${FINE_ROOT}/ThirdParty/MKL/${CMAKE_SYSTEM_NAME})
Expand Down