From cf5e7fcee70fa831ae5bc8b1e6b5e8e146a97837 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Fri, 8 Dec 2023 23:38:25 -0800 Subject: [PATCH] Use CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR for cross-compiling --- CMakeLists.txt | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b98e1bbe..5f00301d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,17 +1,12 @@ set(CMAKE_CXX_STANDARD 11) cmake_minimum_required(VERSION 3.11) -# Set APPLE_ARM to TRUE if running on Apple Silicon -if(APPLE) - execute_process(COMMAND uname -m OUTPUT_VARIABLE OSX_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE) - if (OSX_ARCH STREQUAL "arm64") - set(APPLE_ARM TRUE) - else() # x86_64 - set(APPLE_ARM FALSE) - endif() +# Check if CMAKE_SYSTEM_NAME is Darwin (macOS) and CMAKE_SYSTEM_PROCESSOR is arm64 +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") + set(APPLE_ARM TRUE) else() set(APPLE_ARM FALSE) -endif(APPLE) +endif() # Set the project name and language if(APPLE)