Skip to content

Commit

Permalink
fix macos cmake arch var to allow overriding via command line
Browse files Browse the repository at this point in the history
only generate fat if compiler supports it
  • Loading branch information
Robert Ramirez committed Aug 24, 2021
1 parent e9f5b3d commit 40de718
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,25 @@ cmake_minimum_required(VERSION 3.19)
string(REGEX REPLACE "(.*)/" "" THIS_FOLDER_NAME "${CMAKE_CURRENT_SOURCE_DIR}")
project(${THIS_FOLDER_NAME})

set(CMAKE_OSX_ARCHITECTURES x86_64;arm64)
if (APPLE)
if (${CMAKE_GENERATOR} MATCHES "Xcode")
if (${XCODE_VERSION} VERSION_LESS 10)
message(STATUS "Xcode 10 or higher is required. Please install from the Mac App Store.")
return ()
elseif(${XCODE_VERSION} VERSION_GREATER_EQUAL 12)
set(C74_BUILD_FAT YES)
endif ()
endif ()

if (NOT CMAKE_OSX_ARCHITECTURES)
if(C74_BUILD_FAT)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "macOS architecture" FORCE)
else()
set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "macOS architecture" FORCE)
endif()
endif()
message("CMAKE_OSX_ARCHITECTURES set to ${CMAKE_OSX_ARCHITECTURES}")
endif()

MACRO(SUBDIRLIST result curdir)
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
Expand Down

0 comments on commit 40de718

Please sign in to comment.