xref: /aosp_15_r20/external/deqp/framework/delibs/cmake/toolchain-ios.cmake (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker# This file is based off of the Platform/Darwin.cmake and Platform/UnixPaths.cmake
2*35238bceSAndroid Build Coastguard Worker# files which are included with CMake 2.8.4
3*35238bceSAndroid Build Coastguard Worker# It has been altered for iOS development
4*35238bceSAndroid Build Coastguard Worker
5*35238bceSAndroid Build Coastguard Worker# Options:
6*35238bceSAndroid Build Coastguard Worker#
7*35238bceSAndroid Build Coastguard Worker# IOS_PLATFORM = OS (default) or SIMULATOR
8*35238bceSAndroid Build Coastguard Worker#   This decides if SDKS will be selected from the iPhoneOS.platform or iPhoneSimulator.platform folders
9*35238bceSAndroid Build Coastguard Worker#   OS - the default, used to build for iPhone and iPad physical devices, which have an arm arch.
10*35238bceSAndroid Build Coastguard Worker#   SIMULATOR - used to build for the Simulator platforms, which have an x86 arch.
11*35238bceSAndroid Build Coastguard Worker#
12*35238bceSAndroid Build Coastguard Worker# CMAKE_IOS_DEVELOPER_ROOT = automatic(default) or /path/to/platform/Developer folder
13*35238bceSAndroid Build Coastguard Worker#   By default this location is automatcially chosen based on the IOS_PLATFORM value above.
14*35238bceSAndroid Build Coastguard Worker#   If set manually, it will override the default location and force the user of a particular Developer Platform
15*35238bceSAndroid Build Coastguard Worker#
16*35238bceSAndroid Build Coastguard Worker# CMAKE_IOS_SDK_ROOT = automatic(default) or /path/to/platform/Developer/SDKs/SDK folder
17*35238bceSAndroid Build Coastguard Worker#   By default this location is automatcially chosen based on the CMAKE_IOS_DEVELOPER_ROOT value.
18*35238bceSAndroid Build Coastguard Worker#   In this case it will always be the most up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path.
19*35238bceSAndroid Build Coastguard Worker#   If set manually, this will force the use of a specific SDK version
20*35238bceSAndroid Build Coastguard Worker
21*35238bceSAndroid Build Coastguard Worker# Standard settings
22*35238bceSAndroid Build Coastguard Workerset (CMAKE_SYSTEM_NAME Darwin)
23*35238bceSAndroid Build Coastguard Workerset (CMAKE_SYSTEM_VERSION 1)
24*35238bceSAndroid Build Coastguard Workerset (UNIX True)
25*35238bceSAndroid Build Coastguard Workerset (APPLE True)
26*35238bceSAndroid Build Coastguard Workerset (IOS True)
27*35238bceSAndroid Build Coastguard Worker
28*35238bceSAndroid Build Coastguard Worker# Required as of cmake 2.8.10
29*35238bceSAndroid Build Coastguard Workerset (CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE)
30*35238bceSAndroid Build Coastguard Worker
31*35238bceSAndroid Build Coastguard Worker# Determine the cmake host system version so we know where to find the iOS SDKs
32*35238bceSAndroid Build Coastguard Workerfind_program (CMAKE_UNAME uname /bin /usr/bin /usr/local/bin)
33*35238bceSAndroid Build Coastguard Workerif (CMAKE_UNAME)
34*35238bceSAndroid Build Coastguard Worker	exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION)
35*35238bceSAndroid Build Coastguard Worker	string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}")
36*35238bceSAndroid Build Coastguard Workerendif ()
37*35238bceSAndroid Build Coastguard Worker
38*35238bceSAndroid Build Coastguard Worker# Force the compilers to gcc for iOS
39*35238bceSAndroid Build Coastguard Workerinclude (CMakeForceCompiler)
40*35238bceSAndroid Build Coastguard WorkerCMAKE_FORCE_C_COMPILER ("clang" Clang)
41*35238bceSAndroid Build Coastguard WorkerCMAKE_FORCE_CXX_COMPILER ("clang++" Clang++)
42*35238bceSAndroid Build Coastguard Worker
43*35238bceSAndroid Build Coastguard Worker# Skip the platform compiler checks for cross compiling
44*35238bceSAndroid Build Coastguard Workerset (CMAKE_CXX_COMPILER_WORKS TRUE)
45*35238bceSAndroid Build Coastguard Workerset (CMAKE_C_COMPILER_WORKS TRUE)
46*35238bceSAndroid Build Coastguard Worker
47*35238bceSAndroid Build Coastguard Worker# All iOS/Darwin specific settings - some may be redundant
48*35238bceSAndroid Build Coastguard Workerset (CMAKE_SHARED_LIBRARY_PREFIX "lib")
49*35238bceSAndroid Build Coastguard Workerset (CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
50*35238bceSAndroid Build Coastguard Workerset (CMAKE_SHARED_MODULE_PREFIX "lib")
51*35238bceSAndroid Build Coastguard Workerset (CMAKE_SHARED_MODULE_SUFFIX ".so")
52*35238bceSAndroid Build Coastguard Workerset (CMAKE_MODULE_EXISTS 1)
53*35238bceSAndroid Build Coastguard Workerset (CMAKE_DL_LIBS "")
54*35238bceSAndroid Build Coastguard Worker
55*35238bceSAndroid Build Coastguard Workerset (CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
56*35238bceSAndroid Build Coastguard Workerset (CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
57*35238bceSAndroid Build Coastguard Workerset (CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
58*35238bceSAndroid Build Coastguard Workerset (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
59*35238bceSAndroid Build Coastguard Worker
60*35238bceSAndroid Build Coastguard Worker# Hidden visibilty is required for cxx on iOS
61*35238bceSAndroid Build Coastguard Workerset (CMAKE_C_FLAGS_INIT "")
62*35238bceSAndroid Build Coastguard Workerset (CMAKE_CXX_FLAGS_INIT "-headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden")
63*35238bceSAndroid Build Coastguard Worker
64*35238bceSAndroid Build Coastguard Workerset (CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
65*35238bceSAndroid Build Coastguard Workerset (CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
66*35238bceSAndroid Build Coastguard Worker
67*35238bceSAndroid Build Coastguard Workerset (CMAKE_PLATFORM_HAS_INSTALLNAME 1)
68*35238bceSAndroid Build Coastguard Workerset (CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -headerpad_max_install_names")
69*35238bceSAndroid Build Coastguard Workerset (CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -headerpad_max_install_names")
70*35238bceSAndroid Build Coastguard Workerset (CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
71*35238bceSAndroid Build Coastguard Workerset (CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
72*35238bceSAndroid Build Coastguard Workerset (CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a")
73*35238bceSAndroid Build Coastguard Worker
74*35238bceSAndroid Build Coastguard Worker# hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree
75*35238bceSAndroid Build Coastguard Worker# (where install_name_tool was hardcoded) and where CMAKE_INSTALL_NAME_TOOL isn't in the cache
76*35238bceSAndroid Build Coastguard Worker# and still cmake didn't fail in CMakeFindBinUtils.cmake (because it isn't rerun)
77*35238bceSAndroid Build Coastguard Worker# hardcode CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did before, Alex
78*35238bceSAndroid Build Coastguard Workerif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
79*35238bceSAndroid Build Coastguard Worker	find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool)
80*35238bceSAndroid Build Coastguard Workerendif ()
81*35238bceSAndroid Build Coastguard Worker
82*35238bceSAndroid Build Coastguard Worker# Setup iOS platform unless specified manually with IOS_PLATFORM
83*35238bceSAndroid Build Coastguard Workerif (NOT DEFINED IOS_PLATFORM)
84*35238bceSAndroid Build Coastguard Worker	set (IOS_PLATFORM "OS")
85*35238bceSAndroid Build Coastguard Workerendif ()
86*35238bceSAndroid Build Coastguard Workerset (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform")
87*35238bceSAndroid Build Coastguard Worker
88*35238bceSAndroid Build Coastguard Worker# Check the platform selection and setup for developer root
89*35238bceSAndroid Build Coastguard Workerif (${IOS_PLATFORM} STREQUAL "OS")
90*35238bceSAndroid Build Coastguard Worker	set (IOS_PLATFORM_LOCATION "iPhoneOS.platform")
91*35238bceSAndroid Build Coastguard Worker
92*35238bceSAndroid Build Coastguard Worker	# This causes the installers to properly locate the output libraries
93*35238bceSAndroid Build Coastguard Worker	set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos")
94*35238bceSAndroid Build Coastguard Workerelseif (${IOS_PLATFORM} STREQUAL "SIMULATOR")
95*35238bceSAndroid Build Coastguard Worker	set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform")
96*35238bceSAndroid Build Coastguard Worker
97*35238bceSAndroid Build Coastguard Worker	# This causes the installers to properly locate the output libraries
98*35238bceSAndroid Build Coastguard Worker	set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator")
99*35238bceSAndroid Build Coastguard Workerelse ()
100*35238bceSAndroid Build Coastguard Worker	message (FATAL_ERROR "Unsupported IOS_PLATFORM value selected. Please choose OS or SIMULATOR")
101*35238bceSAndroid Build Coastguard Workerendif ()
102*35238bceSAndroid Build Coastguard Worker
103*35238bceSAndroid Build Coastguard Worker# Setup iOS developer location unless specified manually with CMAKE_IOS_DEVELOPER_ROOT
104*35238bceSAndroid Build Coastguard Worker# Note Xcode 4.3 changed the installation location, choose the most recent one available
105*35238bceSAndroid Build Coastguard Workerset (XCODE_POST_43_ROOT "/Applications/Xcode.app/Contents/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
106*35238bceSAndroid Build Coastguard Workerset (XCODE_PRE_43_ROOT "/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
107*35238bceSAndroid Build Coastguard Workerif (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
108*35238bceSAndroid Build Coastguard Worker	if (EXISTS ${XCODE_POST_43_ROOT})
109*35238bceSAndroid Build Coastguard Worker		set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_POST_43_ROOT})
110*35238bceSAndroid Build Coastguard Worker	elseif ()
111*35238bceSAndroid Build Coastguard Worker		set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_PRE_43_ROOT})
112*35238bceSAndroid Build Coastguard Worker	endif ()
113*35238bceSAndroid Build Coastguard Workerendif ()
114*35238bceSAndroid Build Coastguard Workerset (CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT} CACHE PATH "Location of iOS Platform")
115*35238bceSAndroid Build Coastguard Worker
116*35238bceSAndroid Build Coastguard Worker# Find and use the most recent iOS sdk unless specified manually with CMAKE_IOS_SDK_ROOT
117*35238bceSAndroid Build Coastguard Workerif (NOT DEFINED CMAKE_IOS_SDK_ROOT)
118*35238bceSAndroid Build Coastguard Worker	file (GLOB _CMAKE_IOS_SDKS "${CMAKE_IOS_DEVELOPER_ROOT}/SDKs/*")
119*35238bceSAndroid Build Coastguard Worker	if (_CMAKE_IOS_SDKS)
120*35238bceSAndroid Build Coastguard Worker		list (SORT _CMAKE_IOS_SDKS)
121*35238bceSAndroid Build Coastguard Worker		list (REVERSE _CMAKE_IOS_SDKS)
122*35238bceSAndroid Build Coastguard Worker		list (GET _CMAKE_IOS_SDKS 0 CMAKE_IOS_SDK_ROOT)
123*35238bceSAndroid Build Coastguard Worker	else ()
124*35238bceSAndroid Build Coastguard Worker		message (FATAL_ERROR "No iOS SDK's found in default search path ${CMAKE_IOS_DEVELOPER_ROOT}. Manually set CMAKE_IOS_SDK_ROOT or install the iOS SDK.")
125*35238bceSAndroid Build Coastguard Worker	endif ()
126*35238bceSAndroid Build Coastguard Worker	message (STATUS "Toolchain using default iOS SDK: ${CMAKE_IOS_SDK_ROOT}")
127*35238bceSAndroid Build Coastguard Workerendif ()
128*35238bceSAndroid Build Coastguard Workerset (CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK")
129*35238bceSAndroid Build Coastguard Worker
130*35238bceSAndroid Build Coastguard Worker# Set the sysroot default to the most recent SDK
131*35238bceSAndroid Build Coastguard Workerset (CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support")
132*35238bceSAndroid Build Coastguard Worker
133*35238bceSAndroid Build Coastguard Worker# set the architecture for iOS
134*35238bceSAndroid Build Coastguard Worker# NOTE: Currently both ARCHS_STANDARD_32_BIT and ARCHS_UNIVERSAL_IPHONE_OS set armv7 only, so set both manually
135*35238bceSAndroid Build Coastguard Workerif (${IOS_PLATFORM} STREQUAL "OS")
136*35238bceSAndroid Build Coastguard Worker	set (IOS_ARCH	armv7)
137*35238bceSAndroid Build Coastguard Worker#	set (IOS_ARCH	armv6 armv7 armv7s)
138*35238bceSAndroid Build Coastguard Worker	set (DE_CPU		"DE_CPU_ARM")
139*35238bceSAndroid Build Coastguard Workerelse (${IOS_PLATFORM} STREQUAL "SIMULATOR")
140*35238bceSAndroid Build Coastguard Worker	set (IOS_ARCH	i386)
141*35238bceSAndroid Build Coastguard Worker	set (DE_CPU		"DE_CPU_X86")
142*35238bceSAndroid Build Coastguard Workerendif ()
143*35238bceSAndroid Build Coastguard Worker
144*35238bceSAndroid Build Coastguard Workerset (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE string  "Build architecture for iOS")
145*35238bceSAndroid Build Coastguard Worker
146*35238bceSAndroid Build Coastguard Worker# Set the find root to the iOS developer roots and to user defined paths
147*35238bceSAndroid Build Coastguard Workerset (CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE string  "iOS find search path root")
148*35238bceSAndroid Build Coastguard Worker
149*35238bceSAndroid Build Coastguard Worker# default to searching for frameworks first
150*35238bceSAndroid Build Coastguard Workerset (CMAKE_FIND_FRAMEWORK FIRST)
151*35238bceSAndroid Build Coastguard Worker
152*35238bceSAndroid Build Coastguard Worker# set up the default search directories for frameworks
153*35238bceSAndroid Build Coastguard Workerset (CMAKE_SYSTEM_FRAMEWORK_PATH
154*35238bceSAndroid Build Coastguard Worker	${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks
155*35238bceSAndroid Build Coastguard Worker	${CMAKE_IOS_SDK_ROOT}/System/Library/PrivateFrameworks
156*35238bceSAndroid Build Coastguard Worker	${CMAKE_IOS_SDK_ROOT}/Developer/Library/Frameworks
157*35238bceSAndroid Build Coastguard Worker)
158*35238bceSAndroid Build Coastguard Worker
159*35238bceSAndroid Build Coastguard Worker# only search the iOS sdks, not the remainder of the host filesystem
160*35238bceSAndroid Build Coastguard Workerset (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
161*35238bceSAndroid Build Coastguard Workerset (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
162*35238bceSAndroid Build Coastguard Workerset (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
163*35238bceSAndroid Build Coastguard Worker
164*35238bceSAndroid Build Coastguard Worker# dE Defines - DE_CPU is set earlier
165*35238bceSAndroid Build Coastguard Workerset(DE_PTR_SIZE	4)
166*35238bceSAndroid Build Coastguard Workerset(DE_OS		"DE_OS_IOS")
167*35238bceSAndroid Build Coastguard Workerset(DE_COMPILER	"DE_COMPILER_CLANG")
168