diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c24da84..97d9eae2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,19 +161,19 @@ if (UNIX) endif() if (APPLE) - exec_program(uname ARGS -v OUTPUT_VARIABLE DARWIN_VERSION) - string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION}) - message(STATUS "DARWIN_VERSION=${DARWIN_VERSION}") - if (DARWIN_VERSION LESS 9) - # 10.4: Universal (32-bit Intel and PowerPC) + message(STATUS "OSX_TARGET_MAJOR=${OSX_TARGET_MAJOR}") + message(STATUS "OSX_TARGET_MINOR=${OSX_TARGET_MINOR}") + + if (NOT (OSX_TARGET_MAJOR EQUAL 10)) + message(FATAL_ERROR "Mac OS X target must be 10.x") + endif () + + if (OSX_TARGET_MINOR LESS 6) + # <= 10.5: 32-bit Intel and PowerPC set(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "" FORCE) - elseif (DARWIN_VERSION LESS 10) - # 10.5: 32-bit Intel only - set(CMAKE_OSX_ARCHITECTURES "i386" - CACHE STRING "" FORCE) else() - # 10.6+: Intel only + # >= 10.6: Intel only set(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "" FORCE) endif() diff --git a/ext/toolchain/commands1.py b/ext/toolchain/commands1.py index 5374bcd2..96484505 100644 --- a/ext/toolchain/commands1.py +++ b/ext/toolchain/commands1.py @@ -451,9 +451,15 @@ class InternalCommands: cmake_args += ' -DCMAKE_BUILD_TYPE=' + target.capitalize() elif sys.platform == "darwin": + macSdkMatch = re.match("(\d+)\.(\d+)", self.macSdk) + if not macSdkMatch: + raise Exception("unknown osx version: " + self.macSdk) + sdkDir = self.getMacSdkDir() cmake_args += " -DCMAKE_OSX_SYSROOT=" + sdkDir cmake_args += " -DCMAKE_OSX_DEPLOYMENT_TARGET=" + self.macSdk + cmake_args += " -DOSX_TARGET_MAJOR=" + macSdkMatch.group(1) + cmake_args += " -DOSX_TARGET_MINOR=" + macSdkMatch.group(2) # if not visual studio, use parent dir sourceDir = generator.getSourceDir()