diff options
author | Brad King <brad.king@kitware.com> | 2022-11-15 13:53:41 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-11-15 13:53:50 (GMT) |
commit | 5dbc7be0da055536c0b7946cad6999829469e3dc (patch) | |
tree | fb3b160f1c53cf74c834942da19d34b8086d48d1 /Modules | |
parent | 82e49021fec49d1b8243444eed44c6862e2d6ddc (diff) | |
parent | a44d415ed33398811716077f2872429a7402752a (diff) | |
download | CMake-5dbc7be0da055536c0b7946cad6999829469e3dc.zip CMake-5dbc7be0da055536c0b7946cad6999829469e3dc.tar.gz CMake-5dbc7be0da055536c0b7946cad6999829469e3dc.tar.bz2 |
Merge topic 'legacy'
a44d415ed3 CMakeDetermineSystem: use execute_process() vs. exec_program()
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7884
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeDetermineSystem.cmake | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index 2c2c2ac..94e92e8 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -33,20 +33,32 @@ # find out on which system cmake runs if(CMAKE_HOST_UNIX) - find_program(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin ) + find_program(CMAKE_UNAME NAMES uname PATHS /bin /usr/bin /usr/local/bin) if(CMAKE_UNAME) if(CMAKE_HOST_SYSTEM_NAME STREQUAL "AIX") - exec_program(${CMAKE_UNAME} ARGS -v OUTPUT_VARIABLE _CMAKE_HOST_SYSTEM_MAJOR_VERSION) - exec_program(${CMAKE_UNAME} ARGS -r OUTPUT_VARIABLE _CMAKE_HOST_SYSTEM_MINOR_VERSION) + execute_process(COMMAND ${CMAKE_UNAME} -v + OUTPUT_VARIABLE _CMAKE_HOST_SYSTEM_MAJOR_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) + execute_process(COMMAND ${CMAKE_UNAME} -r + OUTPUT_VARIABLE _CMAKE_HOST_SYSTEM_MINOR_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) set(CMAKE_HOST_SYSTEM_VERSION "${_CMAKE_HOST_SYSTEM_MAJOR_VERSION}.${_CMAKE_HOST_SYSTEM_MINOR_VERSION}") unset(_CMAKE_HOST_SYSTEM_MAJOR_VERSION) unset(_CMAKE_HOST_SYSTEM_MINOR_VERSION) else() - exec_program(${CMAKE_UNAME} ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION) + execute_process(COMMAND ${CMAKE_UNAME} -r + OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) endif() if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|CYGWIN.*|MSYS.*|^GNU$|Android") - exec_program(${CMAKE_UNAME} ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR - RETURN_VALUE val) + execute_process(COMMAND ${CMAKE_UNAME} -m + OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR + RESULT_VARIABLE val + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin") # If we are running on Apple Silicon, honor CMAKE_APPLE_SILICON_PROCESSOR. if(DEFINED CMAKE_APPLE_SILICON_PROCESSOR) @@ -74,8 +86,11 @@ if(CMAKE_HOST_UNIX) if(_CMAKE_APPLE_SILICON_PROCESSOR) set(CMAKE_HOST_SYSTEM_PROCESSOR "${_CMAKE_APPLE_SILICON_PROCESSOR}") else() - exec_program(${CMAKE_UNAME} ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR - RETURN_VALUE val) + execute_process(COMMAND ${CMAKE_UNAME} -m + OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR + RESULT_VARIABLE val + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) endif() unset(_CMAKE_APPLE_SILICON_PROCESSOR) if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "Power Macintosh") @@ -83,14 +98,23 @@ if(CMAKE_HOST_UNIX) 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) + execute_process(COMMAND arch -s + OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR + RESULT_VARIABLE val + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) else() - exec_program(${CMAKE_UNAME} ARGS -p OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR - RETURN_VALUE val) + execute_process(COMMAND ${CMAKE_UNAME} -p + OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR + RESULT_VARIABLE val + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) if("${val}" GREATER 0) - exec_program(${CMAKE_UNAME} ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR - RETURN_VALUE val) + execute_process(COMMAND ${CMAKE_UNAME} -m + OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR + RESULT_VARIABLE val + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) endif() endif() # check the return of the last uname -m or -p |