summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMichael Hirsch <scivision@users.noreply.gitlab.kitware.com>2022-11-07 19:37:03 (GMT)
committerMichael Hirsch <scivision@users.noreply.gitlab.kitware.com>2022-11-13 19:26:39 (GMT)
commita44d415ed33398811716077f2872429a7402752a (patch)
tree84d2f50dae918d59b54cdde21ce6a5df1371b69d /Modules
parent168b82e68b2160d3a40d89ababc7f3158b8d27b9 (diff)
downloadCMake-a44d415ed33398811716077f2872429a7402752a.zip
CMake-a44d415ed33398811716077f2872429a7402752a.tar.gz
CMake-a44d415ed33398811716077f2872429a7402752a.tar.bz2
CMakeDetermineSystem: use execute_process() vs. exec_program()
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeDetermineSystem.cmake52
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