summaryrefslogtreecommitdiff
path: root/Tests/CMakeLists.txt
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-12-09 10:28:03 -0500
committerBrad King <brad.king@kitware.com>2020-12-10 12:08:15 -0500
commitb7f0327dcd4032c6a118825adcfdc8dab6295e7f (patch)
tree11acc0447f4c3e16e321f74de9a8fc2006f16dcd /Tests/CMakeLists.txt
parent5f882f6ce518a9f90600ae5c73f633ca5c15a7e5 (diff)
downloadcmake-b7f0327dcd4032c6a118825adcfdc8dab6295e7f.tar.gz
Tests: Cover macOS host architecture selection on Apple Silicon hosts
Add test cases verifying that `CMAKE_APPLE_SILICON_PROCESSOR` set as either a cache or environment variable causes that to be selected as the host architecture. Also verify that sources compile using whatever is selected as the host architecture, even when the explicit setting is not used. Issue: #21554
Diffstat (limited to 'Tests/CMakeLists.txt')
-rw-r--r--Tests/CMakeLists.txt16
1 files changed, 16 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 02759d1324..1fb47cb01a 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -228,6 +228,22 @@ if(BUILD_TESTING)
endif()
endif()
+ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT DEFINED CMake_TEST_APPLE_SILICON)
+ execute_process(COMMAND sysctl -q hw.optional.arm64
+ OUTPUT_VARIABLE _sysctl_stdout
+ ERROR_VARIABLE _sysctl_stderr
+ RESULT_VARIABLE _sysctl_result
+ )
+ if(_sysctl_result EQUAL 0 AND _sysctl_stdout MATCHES "hw.optional.arm64: 1")
+ set(CMake_TEST_APPLE_SILICON 1)
+ else()
+ set(CMake_TEST_APPLE_SILICON 0)
+ endif()
+ unset(_sysctl_result)
+ unset(_sysctl_stderr)
+ unset(_sysctl_stdout)
+ endif()
+
#---------------------------------------------------------------------------
# Add tests below here.