From b2fccc826e82682989272922bc2d2c1654c236b5 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 26 May 2021 13:09:13 +0200 Subject: [PATCH] Improve detection of macOS version --- cmake/Modules/DetectMacOSVersion.cmake | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cmake/Modules/DetectMacOSVersion.cmake b/cmake/Modules/DetectMacOSVersion.cmake index 98ff2e057..f5c4988d9 100644 --- a/cmake/Modules/DetectMacOSVersion.cmake +++ b/cmake/Modules/DetectMacOSVersion.cmake @@ -7,10 +7,16 @@ execute_process(COMMAND uname -v OUTPUT_VARIABLE DARWIN_VERSION) string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION}) -if(${DARWIN_VERSION} MATCHES "20") - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++17") - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") - set(MACOS_DISTRIBUTION "macOS Big Sur 11") +if(${DARWIN_VERSION} VERSION_GREATER "19") + execute_process(COMMAND awk "/SOFTWARE LICENSE AGREEMENT FOR macOS/" "/System/Library/CoreServices/Setup Assistant.app/Contents/Resources/en.lproj/OSXSoftwareLicense.rtf" OUTPUT_VARIABLE macOS_NAME) + if(macOS_NAME) + string(REGEX MATCH "macOS*([^\n\r]*)" macOS_NAME ${macOS_NAME}) + string(REGEX REPLACE "macOS " "" macOS_NAME ${macOS_NAME}) + string(REGEX REPLACE ".$" "" macOS_NAME ${macOS_NAME}) + execute_process(COMMAND sw_vers -productVersion OUTPUT_VARIABLE macOS_VERSION) + string(REGEX REPLACE "\n$" "" macOS_VERSION ${macOS_VERSION}) + set(MACOS_DISTRIBUTION "macOS ${macOS_NAME} ${macOS_VERSION}") + endif() endif() if(${DARWIN_VERSION} MATCHES "19")