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

CMake: Attempt to deduce target architure on APPLE via CMAKE_OSX_ARCHITECTURES #937

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
22 changes: 15 additions & 7 deletions cmake/GammaRayProbeABI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,25 @@ if(WIN32)
# on Mac we apparently always get i386 on x86
elseif(APPLE)
if(NOT CMAKE_SYSTEM_PROCESSOR)
message(
FATAL_ERROR
"Unknown target architecture. Make sure to specify CMAKE_SYSTEM_PROCESSOR in your toolchain file!"
)
list(LENGTH CMAKE_OSX_ARCHITECTURES _num_archs)
if(_num_archs EQUAL 1)
set(_apple_processor ${CMAKE_OSX_ARCHITECTURES})
else()
message(
FATAL_ERROR
"Unknown target architecture. Make sure to specify CMAKE_SYSTEM_PROCESSOR in your toolchain file!"
)
endif()
else()
set(_apple_processor ${CMAKE_SYSTEM_PROCESSOR})
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "i386" AND CMAKE_SIZEOF_VOID_P EQUAL 8)

if(_apple_processor MATCHES "i386" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
set(GAMMARAY_PROBE_ABI "${GAMMARAY_PROBE_ABI}-x86_64")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" AND CMAKE_SIZEOF_VOID_P EQUAL 4)
elseif(_apple_processor MATCHES "x86_64" AND CMAKE_SIZEOF_VOID_P EQUAL 4)
set(GAMMARAY_PROBE_ABI "${GAMMARAY_PROBE_ABI}-i686")
else()
set(GAMMARAY_PROBE_ABI "${GAMMARAY_PROBE_ABI}-${CMAKE_SYSTEM_PROCESSOR}")
set(GAMMARAY_PROBE_ABI "${GAMMARAY_PROBE_ABI}-${_apple_processor}")
endif()

# on Android we derive this from ANDROID_ABI
Expand Down