Skip to content

Commit

Permalink
Merge branch 'master' of github.com:leetal/ios-cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Widerberg committed Apr 5, 2020
2 parents ebafdf2 + 76a6239 commit 2d493ab
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions ios.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
# XCODE_VERSION: Version number (not including Build version) of Xcode detected.
# SDK_VERSION: Version of SDK being used.
# CMAKE_OSX_ARCHITECTURES: Architectures being compiled for (generated from PLATFORM).
# APPLE_TARGET_TRIPLE: Used by autoconf build systems. NOTE: If "ARCHS" are overridden, this will *NOT* be set!
#
# This toolchain defines the following macros for use externally:
#
Expand Down Expand Up @@ -219,6 +220,7 @@ if(PLATFORM_INT STREQUAL "OS")
set(SDK_NAME iphoneos)
if(NOT ARCHS)
set(ARCHS armv7 armv7s arm64)
set(APPLE_TARGET_TRIPLE_INT arm-apple-ios)
endif()
elseif(PLATFORM_INT STREQUAL "OS64")
set(SDK_NAME iphoneos)
Expand All @@ -228,6 +230,7 @@ elseif(PLATFORM_INT STREQUAL "OS64")
else()
set(ARCHS arm64)
endif()
set(APPLE_TARGET_TRIPLE_INT aarch64-apple-ios)
endif()
elseif(PLATFORM_INT STREQUAL "OS64COMBINED")
set(SDK_NAME iphoneos)
Expand All @@ -238,6 +241,7 @@ elseif(PLATFORM_INT STREQUAL "OS64COMBINED")
else()
set(ARCHS arm64 x86_64)
endif()
set(APPLE_TARGET_TRIPLE_INT aarch64-x86_64-apple-ios)
endif()
else()
message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the OS64COMBINED setting work")
Expand All @@ -246,23 +250,27 @@ elseif(PLATFORM_INT STREQUAL "SIMULATOR")
set(SDK_NAME iphonesimulator)
if(NOT ARCHS)
set(ARCHS i386)
set(APPLE_TARGET_TRIPLE_INT i386-apple-ios)
endif()
message(DEPRECATION "SIMULATOR IS DEPRECATED. Consider using SIMULATOR64 instead.")
elseif(PLATFORM_INT STREQUAL "SIMULATOR64")
set(SDK_NAME iphonesimulator)
if(NOT ARCHS)
set(ARCHS x86_64)
set(APPLE_TARGET_TRIPLE_INT x86_64-apple-ios)
endif()
elseif(PLATFORM_INT STREQUAL "TVOS")
set(SDK_NAME appletvos)
if(NOT ARCHS)
set(ARCHS arm64)
set(APPLE_TARGET_TRIPLE_INT aarch64-apple-tvos)
endif()
elseif (PLATFORM_INT STREQUAL "TVOSCOMBINED")
set(SDK_NAME appletvos)
if(MODERN_CMAKE)
if(NOT ARCHS)
set(ARCHS arm64 x86_64)
set(APPLE_TARGET_TRIPLE_INT aarch64-x86_64-apple-tvos)
endif()
else()
message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the TVOSCOMBINED setting work")
Expand All @@ -271,14 +279,17 @@ elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS")
set(SDK_NAME appletvsimulator)
if(NOT ARCHS)
set(ARCHS x86_64)
set(APPLE_TARGET_TRIPLE_INT x86_64-apple-tvos)
endif()
elseif(PLATFORM_INT STREQUAL "WATCHOS")
set(SDK_NAME watchos)
if(NOT ARCHS)
if (XCODE_VERSION VERSION_GREATER 10.0)
set(ARCHS armv7k arm64_32)
set(APPLE_TARGET_TRIPLE_INT aarch64_32-apple-watchos)
else()
set(ARCHS armv7k)
set(APPLE_TARGET_TRIPLE_INT arm-apple-watchos)
endif()
endif()
elseif(PLATFORM_INT STREQUAL "WATCHOSCOMBINED")
Expand All @@ -287,8 +298,10 @@ elseif(PLATFORM_INT STREQUAL "WATCHOSCOMBINED")
if(NOT ARCHS)
if (XCODE_VERSION VERSION_GREATER 10.0)
set(ARCHS armv7k arm64_32 i386)
set(APPLE_TARGET_TRIPLE_INT aarch64_32-i386-apple-watchos)
else()
set(ARCHS armv7k i386)
set(APPLE_TARGET_TRIPLE_INT arm-i386-apple-watchos)
endif()
endif()
else()
Expand All @@ -298,6 +311,7 @@ elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS")
set(SDK_NAME watchsimulator)
if(NOT ARCHS)
set(ARCHS i386)
set(APPLE_TARGET_TRIPLE_INT i386-apple-watchos)
endif()
else()
message(FATAL_ERROR "Invalid PLATFORM: ${PLATFORM_INT}")
Expand Down Expand Up @@ -389,7 +403,6 @@ execute_process(COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version SDKVersion
if (NOT DEFINED CMAKE_DEVELOPER_ROOT AND NOT USED_CMAKE_GENERATOR MATCHES "Xcode")
get_filename_component(PLATFORM_SDK_DIR ${CMAKE_OSX_SYSROOT} PATH)
get_filename_component(CMAKE_DEVELOPER_ROOT ${PLATFORM_SDK_DIR} PATH)

if (NOT DEFINED CMAKE_DEVELOPER_ROOT)
message(FATAL_ERROR "Invalid CMAKE_DEVELOPER_ROOT: "
"${CMAKE_DEVELOPER_ROOT} does not exist.")
Expand Down Expand Up @@ -543,6 +556,10 @@ else()
"Set CMake deployment target" ${FORCE_CACHE})
endif()

if(DEFINED APPLE_TARGET_TRIPLE_INT)
set(APPLE_TARGET_TRIPLE ${APPLE_TARGET_TRIPLE_INT} CACHE STRING
"Autoconf target triple compatible variable" ${FORCE_CACHE})
endif()

if(ENABLE_BITCODE_INT)
set(BITCODE "-fembed-bitcode")
Expand Down Expand Up @@ -607,6 +624,9 @@ if(NOT IOS_TOOLCHAIN_HAS_RUN)
## Print status messages to inform of the current state
message(STATUS "Configuring ${SDK_NAME} build for platform: ${PLATFORM_INT}, architecture(s): ${ARCHS}")
message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT_INT}")
if(DEFINED APPLE_TARGET_TRIPLE)
message(STATUS "Autoconf target triple: ${APPLE_TARGET_TRIPLE}")
endif()
message(STATUS "Using minimum deployment version: ${DEPLOYMENT_TARGET}"
" (SDK version: ${SDK_VERSION})")
if(MODERN_CMAKE)
Expand Down Expand Up @@ -664,13 +684,13 @@ if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH CACHE STRING "" ${FORCE_CACHE})
endif()
if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY CACHE STRING "" ${FORCE_CACHE})
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH CACHE STRING "" ${FORCE_CACHE})
endif()
if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY CACHE STRING "" ${FORCE_CACHE})
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH CACHE STRING "" ${FORCE_CACHE})
endif()
if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY CACHE STRING "" ${FORCE_CACHE})
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH CACHE STRING "" ${FORCE_CACHE})
endif()

#
Expand All @@ -688,6 +708,7 @@ macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE XCODE_RELVERSION)
XCODE_ATTRIBUTE_${XCODE_PROPERTY}[variant=${XCODE_RELVERSION_I}] "${XCODE_VALUE}")
endif()
endmacro(set_xcode_property)

# This macro lets you find executable programs on the host system.
macro(find_host_package)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
Expand Down

0 comments on commit 2d493ab

Please sign in to comment.