ios simulator arm64 and arm64e support (#1086)

* Adding support for iphonesimulator arm64 architecture for m1 arm64 based simulator and optional parameter for deployment target
This commit is contained in:
Swasti Gupta 2023-01-27 23:43:03 -08:00 коммит произвёл GitHub
Родитель 0a6b18fd7e
Коммит e8eb28fab9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 28 добавлений и 19 удалений

Просмотреть файл

@ -26,6 +26,9 @@ if(APPLE)
# iOS build options
option(BUILD_IOS "Build for iOS" NO)
option(FORCE_RESET_OSX_DEPLOYMENT_TARGET "Clear the OSX Deployment Target Set" YES)
if (DEFINED FORCE_RESET_DEPLOYMENT_TARGET)
set(FORCE_RESET_OSX_DEPLOYMENT_TARGET ${FORCE_RESET_DEPLOYMENT_TARGET})
endif()
if(BUILD_IOS)
set(TARGET_ARCH "APPLE")
@ -34,14 +37,14 @@ if(APPLE)
if(FORCE_RESET_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE)
endif()
if((${IOS_PLAT} STREQUAL "iphonesimulator") AND (${IOS_ARCH} STREQUAL "arm64"))
# iOS arm64 simulator is supported starting BigSur
# Unfortunately, CMAKE produces a device binary (not simulator) when providing -miphoneos-version-min flag when building iOS arm64 simulator
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -miphoneos-version-min=${IOS_DEPLOYMENT_TARGET}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -miphoneos-version-min=${IOS_DEPLOYMENT_TARGET}")
if((${IOS_PLAT} STREQUAL "iphonesimulator") AND ((${IOS_ARCH} STREQUAL "arm64") OR (${IOS_ARCH} STREQUAL "arm64e")))
# iOS arm64 simulator is supported starting BigSur
# Unfortunately, CMAKE produces a device binary (not simulator) when providing -miphoneos-version-min flag when building iOS arm64 simulator
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -miphoneos-version-min=${IOS_DEPLOYMENT_TARGET}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -miphoneos-version-min=${IOS_DEPLOYMENT_TARGET}")
endif()
endif()
if((${IOS_PLAT} STREQUAL "iphoneos") OR (${IOS_PLAT} STREQUAL "iphonesimulator"))
@ -54,12 +57,12 @@ if(APPLE)
set(IOS_PLATFORM "iphonesimulator")
set(CMAKE_SYSTEM_PROCESSOR x86_64)
elseif(${IOS_ARCH} STREQUAL "arm64")
set(IOS_PLATFORM "iphoneos")
set(IOS_PLATFORM ${IOS_PLAT})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch arm64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch arm64")
set(CMAKE_SYSTEM_PROCESSOR arm64)
elseif(${IOS_ARCH} STREQUAL "arm64e")
set(IOS_PLATFORM "iphoneos")
set(IOS_PLATFORM ${IOS_PLAT})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch arm64e")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch arm64e")
set(CMAKE_SYSTEM_PROCESSOR arm64e)

Просмотреть файл

@ -23,14 +23,22 @@ IOS_ARCH="x86_64"
fi
# Set Platform: device or simulator
if [ "$2" == "device" ] || [ "$3" == "device" ]; then
if [ "$2" == "device" ] || [ "$3" == "device" ] || [ "$4" == "device" ]; then
IOS_PLAT="iphoneos"
else
IOS_PLAT="iphonesimulator"
fi
# Set target iOS minver
IOS_DEPLOYMENT_TARGET=10.0
default_ios_target=10.0
if [ -z $IOS_DEPLOYMENT_TARGET ]; then
export IOS_DEPLOYMENT_TARGET=${default_ios_target}
export FORCE_RESET_DEPLOYMENT_TARGET=YES
else
export FORCE_RESET_DEPLOYMENT_TARGET=NO
fi
echo "ios deployment target="$IOS_DEPLOYMENT_TARGET
echo "force reset deployment target="$FORCE_RESET_DEPLOYMENT_TARGET
# Install build tools and recent sqlite3
FILE=.buildtools
@ -54,7 +62,7 @@ cd out
CMAKE_PACKAGE_TYPE=tgz
cmake_cmd="cmake -DBUILD_IOS=YES -DIOS_ARCH=$IOS_ARCH -DIOS_PLAT=$IOS_PLAT -DIOS_DEPLOYMENT_TARGET=$IOS_DEPLOYMENT_TARGET -DBUILD_UNIT_TESTS=YES -DBUILD_FUNC_TESTS=YES -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PACKAGE_TYPE=$CMAKE_PACKAGE_TYPE $CMAKE_OPTS .."
cmake_cmd="cmake -DCMAKE_OSX_SYSROOT=$IOS_PLAT -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_IOS_ARCH_ABI=$IOS_ARCH -DCMAKE_OSX_DEPLOYMENT_TARGET=$IOS_DEPLOYMENT_TARGET -DBUILD_IOS=YES -DIOS_ARCH=$IOS_ARCH -DIOS_PLAT=$IOS_PLAT -DIOS_DEPLOYMENT_TARGET=$IOS_DEPLOYMENT_TARGET -DBUILD_UNIT_TESTS=YES -DBUILD_FUNC_TESTS=YES -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PACKAGE_TYPE=$CMAKE_PACKAGE_TYPE -DFORCE_RESET_DEPLOYMENT_TARGET=$FORCE_RESET_DEPLOYMENT_TARGET $CMAKE_OPTS .."
echo $cmake_cmd
eval $cmake_cmd

Просмотреть файл

@ -70,6 +70,7 @@ while getopts "h?vl:D:" opt; do
echo "Environment variables: "
echo "CMAKE_OPTS - any additional cmake options. "
echo "GIT_PULL_TOKEN - authorization token for Microsoft-proprietary modules. "
echo "MACOSX_DEPLOYMENT_TARGET - optional parameter for setting macosx deployment target "
echo "Plus any other environment variables respected by CMake build system. "
exit 0
;;
@ -91,12 +92,9 @@ if [ "$LINK_TYPE" == "shared" ]; then
fi
# Set target MacOS minver
if [ "$MAC_ARCH" == "arm64" ]; then
export MACOSX_DEPLOYMENT_TARGET=11.10
else
export MACOSX_DEPLOYMENT_TARGET=10.10
fi
default_mac_os_target=$([ "$MAC_ARCH" == "arm64" ] && echo "11.10" || echo "10.10")
[ -z $MACOSX_DEPLOYMENT_TARGET ] && export MACOSX_DEPLOYMENT_TARGET=${default_mac_os_target}
echo "macosx deployment target="$MACOSX_DEPLOYMENT_TARGET
# Install build tools and recent sqlite3
FILE=.buildtools