Skip to content

Commit 7a957b8

Browse files
committed
fix default system ID detection under macOS
1 parent 2b8646f commit 7a957b8

File tree

1 file changed

+41
-11
lines changed

1 file changed

+41
-11
lines changed

CMake/Mathematica/FindMathematica.cmake

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -369,12 +369,12 @@ macro (_systemNameToSystemID _systemName _systemProcessor _outSystemIDs)
369369
set (${_outSystemIDs} "Windows")
370370
endif()
371371
elseif ("${_systemName}" STREQUAL "Darwin")
372-
if ("${_systemProcessor}" STREQUAL "i386")
373-
set (${_outSystemIDs} "MacOSX-x86")
372+
if ("${_systemProcessor}" STREQUAL "arm64")
373+
set (${_outSystemIDs} "MacOSX-ARM64")
374374
elseif ("${_systemProcessor}" STREQUAL "x86_64")
375375
set (${_outSystemIDs} "MacOSX-x86-64")
376-
elseif ("${_systemProcessor}" STREQUAL "arm64")
377-
set (${_outSystemIDs} "MacOSX-ARM64")
376+
elseif ("${_systemProcessor}" STREQUAL "i386")
377+
set (${_outSystemIDs} "MacOSX-x86")
378378
elseif ("${_systemProcessor}" MATCHES "ppc64|powerpc64")
379379
set (${_outSystemIDs} "Darwin-PowerPC64")
380380
elseif ("${_systemProcessor}" MATCHES "ppc|powerpc")
@@ -446,7 +446,7 @@ macro (_get_system_IDs _outSystemIDs)
446446
endif()
447447
endforeach()
448448
else()
449-
# determine System ID by checking endianness and pointer size
449+
# determine System ID by checking endianness and system processor
450450
TEST_BIG_ENDIAN(_isBigEndian)
451451
if (_isBigEndian)
452452
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
@@ -464,10 +464,11 @@ macro (_get_system_IDs _outSystemIDs)
464464
endif()
465465
endif()
466466
else()
467-
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
468-
set (${_outSystemIDs} "MacOSX-x86-64")
467+
_systemNameToSystemID("${CMAKE_SYSTEM_NAME}" "${CMAKE_SYSTEM_PROCESSOR}" _systemID)
468+
if (_systemID)
469+
list (APPEND ${_outSystemIDs} ${_systemID})
469470
else()
470-
set (${_outSystemIDs} "MacOSX-x86")
471+
message (FATAL_ERROR "Unsupported macOS architecture ${CMAKE_SYSTEM_PROCESSOR}")
471472
endif()
472473
endif()
473474
endif()
@@ -621,7 +622,7 @@ macro (_get_compatible_system_IDs _systemID _outSystemIDs)
621622
else()
622623
list (APPEND ${_outSystemIDs} "MacOSX-x86-64" "MacOSX-x86")
623624
endif()
624-
elseif ("${_systemID}" MATCHES "MacOSX-ARM64")
625+
elseif ("${_systemID}" STREQUAL "MacOSX-ARM64")
625626
if (Mathematica_VERSION)
626627
# Mathematica 12.3 added support for MacOSX-ARM64
627628
if (NOT "${Mathematica_VERSION}" VERSION_LESS "12.3")
@@ -664,7 +665,7 @@ macro (_get_compatible_system_IDs _systemID _outSystemIDs)
664665
elseif ("${_systemID}" MATCHES "Linux-x86-64|Linux-IA64")
665666
if (Mathematica_VERSION)
666667
if (NOT "${Mathematica_VERSION}" VERSION_LESS "5.2")
667-
# Mathematica 5.2 added support for 64-bit
668+
# Mathematica 5.2 added support for 64-bit Linux x86
668669
list (APPEND ${_outSystemIDs} ${_systemID})
669670
endif()
670671
else()
@@ -673,12 +674,41 @@ macro (_get_compatible_system_IDs _systemID _outSystemIDs)
673674
# Linux 64-bit can run x86 through ia32-libs package
674675
if (Mathematica_VERSION)
675676
if ("${Mathematica_VERSION}" VERSION_LESS "11.3")
676-
# Mathematica 11.3 dropped support for 32-bit Linux
677+
# Mathematica 11.3 dropped support for 32-bit Linux x86
677678
list (APPEND ${_outSystemIDs} "Linux")
678679
endif()
679680
else()
680681
list (APPEND ${_outSystemIDs} "Linux")
681682
endif()
683+
elseif ("${_systemID}" STREQUAL "Linux-ARM64")
684+
if (Mathematica_VERSION)
685+
# Mathematica 13.2 added support for 64-bit Linux ARM
686+
if (NOT "${Mathematica_VERSION}" VERSION_LESS "13.2")
687+
list (APPEND ${_outSystemIDs} ${_systemID})
688+
endif()
689+
else()
690+
list (APPEND ${_outSystemIDs} ${_systemID})
691+
endif()
692+
elseif ("${_systemID}" STREQUAL "Linux-ARM")
693+
if (Mathematica_VERSION)
694+
# Mathematica 10.0 added support for 32-bit Linux ARM
695+
# Mathematica 13.2 dropped support for 32-bit Linux ARM
696+
if (NOT "${Mathematica_VERSION}" VERSION_LESS "10.0" AND
697+
"${Mathematica_VERSION}" VERSION_LESS "13.2")
698+
list (APPEND ${_outSystemIDs} ${_systemID})
699+
endif()
700+
else()
701+
list (APPEND ${_outSystemIDs} ${_systemID})
702+
endif()
703+
elseif ("${_systemID}" STREQUAL "Linux")
704+
if (Mathematica_VERSION)
705+
# Mathematica 11.3 dropped support for 32-bit Linux x86
706+
if ("${Mathematica_VERSION}" VERSION_LESS "11.3")
707+
list (APPEND ${_outSystemIDs} ${_systemID})
708+
endif()
709+
else()
710+
list (APPEND ${_outSystemIDs} ${_systemID})
711+
endif()
682712
else()
683713
list (APPEND ${_outSystemIDs} ${_systemID})
684714
endif()

0 commit comments

Comments
 (0)