From 39d11975b2706d533229e3c1341a4cc6b8aadb36 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Sat, 19 Feb 2022 06:17:46 +0000 Subject: [PATCH] Update build requirements for Apple CMake version 3.20 or higher (needed to support Xcode project generation) clang version 12.0 or higher (needed to support arm64+x64 universal binary compilation) XCode 12.2 is the oldest version which includes clang version 12.0 --- CMakeLists.txt | 9 +++++++++ docs/CONTRIBUTING/Compiling.md | 10 +++++++++- docs/CONTRIBUTING/Dependencies.md | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0735fa3cc..3f7d62996 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 2.8.12) if(APPLE) + # Building for Apple requires at least CMake 3.20.0 + cmake_minimum_required(VERSION 3.20.0) + SET(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Build architectures for Mac OS X" FORCE) SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum SDK for Mac OS X" FORCE) SET(CMAKE_XCODE_GENERATE_SCHEME ON) @@ -194,6 +197,12 @@ option(ENABLE_ASAN "Enable address sanitizer" OFF) option(ENABLE_TSAN "Enable thread sanitizer" OFF) option(ENABLE_MSAN "Enable memory sanitizer" OFF) +if(APPLE) + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.0) + message(FATAL_ERROR "Xcode 12.2 or newer is required to build for Apple") + endif() +endif() + if(ENABLE_ASAN) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer") message(STATUS "Enabling address sanitizer - may cause issues if capturing, only recommended for use with replay only") diff --git a/docs/CONTRIBUTING/Compiling.md b/docs/CONTRIBUTING/Compiling.md index 9ec54dfe7..080a1657b 100644 --- a/docs/CONTRIBUTING/Compiling.md +++ b/docs/CONTRIBUTING/Compiling.md @@ -27,7 +27,15 @@ Configuration is available for cmake, [documented elsewhere](https://cmake.org/d First check that you have all of the [required dependencies](Dependencies.md#mac). -Mac support is pretty early and while it will compile, it's not usable for debugging yet and is not officially supported. Builds happen with cmake the same way as Linux. +Mac support is pretty early and while it will compile, it's not usable for debugging yet and is not officially supported. + +To build with make, use cmake the same way as Linux. + +To build with Xcode, use the cmake Xcode generator to create the Xcode project: + +``` +cmake -DCMAKE_BUILD_TYPE=Debug -Bbuild -H. -GXcode +``` ## Android diff --git a/docs/CONTRIBUTING/Dependencies.md b/docs/CONTRIBUTING/Dependencies.md index 91b7880bb..ddbdbbe2a 100644 --- a/docs/CONTRIBUTING/Dependencies.md +++ b/docs/CONTRIBUTING/Dependencies.md @@ -95,7 +95,7 @@ sudo apt-get install libx11-dev libx11-xcb-dev mesa-common-dev libgl1-mesa-dev l ## Mac -Mac requires a recent version of CMake, and the same Qt version as the other platforms (at least 5.6.2). If you're using [homebrew](http://brew.sh) then this will do the trick: +Mac requires Xcode version 12.2 or newer, CMake version 3.20 or newer, and Qt5 version 5.15.2 or newer. If you're using [homebrew](http://brew.sh) then this will do the trick: ``` brew install cmake qt5