Skip to content

Commit

Permalink
OS X: Use 'uname -m' for processor (#14712)
Browse files Browse the repository at this point in the history
In commit 2412d9b (Use 'uname -m' for processor on Cygwin, 2010-09-21)
it was pointed out that POSIX requires 'uname -m' but not 'uname -p':

  http://www.opengroup.org/onlinepubs/9699919799/utilities/uname.html

On OS X x86_64, 'uname -p' returns i386 while 'uname -m' returns x86_64.
Since the latter is the POSIX-compliant option trust its value.
However, on OS X ppc, 'uname -m' returns 'Power Macintosh' so add a
special-case to convert that to 'powerpc'.
  • Loading branch information
bradking committed Jan 20, 2014
1 parent 1b39581 commit 9d2a090
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Modules/CMakeDetermineSystem.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@ if(CMAKE_HOST_UNIX)
if(CMAKE_UNAME)
exec_program(uname ARGS -s OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_NAME)
exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION)
if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|CYGWIN.*")
if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|CYGWIN.*|Darwin")
exec_program(uname ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR
RETURN_VALUE val)
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND
CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "Power Macintosh")
# OS X ppc 'uname -m' may report 'Power Macintosh' instead of 'powerpc'
set(CMAKE_HOST_SYSTEM_PROCESSOR "powerpc")
endif()
elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "OpenBSD")
exec_program(arch ARGS -s OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR
RETURN_VALUE val)
Expand Down

0 comments on commit 9d2a090

Please sign in to comment.