ENH: check return value for uname -p

This commit is contained in:
Bill Hoffman 2006-05-14 17:42:27 -04:00
parent b2c8f4d800
commit 21564b4d61
1 changed files with 9 additions and 6 deletions

View File

@ -31,16 +31,19 @@ IF(UNIX)
IF(CMAKE_UNAME)
EXEC_PROGRAM(uname ARGS -s OUTPUT_VARIABLE CMAKE_SYSTEM_NAME)
EXEC_PROGRAM(uname ARGS -r OUTPUT_VARIABLE CMAKE_SYSTEM_VERSION)
EXEC_PROGRAM(uname ARGS -p OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR)
IF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "--help")
EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR)
ENDIF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "--help")
IF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "--help")
EXEC_PROGRAM(uname ARGS -p OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR
RETURN_VALUE val)
IF(${val} GREATER 0)
EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR
RETURN_VALUE val)
ENDIF(${val} GREATER 0)
IF(${val} GREATER 0)
SET(CMAKE_SYSTEM_PROCESSOR "unknown")
ENDIF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "--help")
ENDIF(${val} GREATER 0)
SET(CMAKE_UNAME ${CMAKE_UNAME} CACHE INTERNAL "uname command")
# processor may have double quote in the name, and that needs to be removed
STRING(REGEX REPLACE "\"" "" CMAKE_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}")
STRING(REGEX REPLACE "/" "_" CMAKE_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}")
ENDIF(CMAKE_UNAME)
ELSE(UNIX)
IF(WIN32)