summaryrefslogtreecommitdiffstats
path: root/llvm/cmake/platforms/iOS.cmake
diff options
context:
space:
mode:
authorChris Bieneman <beanz@apple.com>2014-09-03 23:21:18 +0000
committerChris Bieneman <beanz@apple.com>2014-09-03 23:21:18 +0000
commit5007741d68de6d74afdc072847b453950262950a (patch)
tree4e9a8b243e902a471cfe0752b62bc89950ca7190 /llvm/cmake/platforms/iOS.cmake
parent467e856600c48c9f9bf06260c0ac9b37cda875b5 (diff)
downloadbcm5719-llvm-5007741d68de6d74afdc072847b453950262950a.tar.gz
bcm5719-llvm-5007741d68de6d74afdc072847b453950262950a.zip
Enabling LLVM & Clang to be cross-compiled using CMake from a single configuration command line
The basic idea is similar to the existing cross compilation support. A directory must be configured to build host versions of tablegen tools and llvm-config. This directory can be user provided (and configured), or it can be created during the build. During a build the native build directory will be configured and built to supply the tablegen tools used during the build. A user could also explicitly provide the tablegen executables to run on the CMake command line. llvm-svn: 217105
Diffstat (limited to 'llvm/cmake/platforms/iOS.cmake')
-rw-r--r--llvm/cmake/platforms/iOS.cmake47
1 files changed, 47 insertions, 0 deletions
diff --git a/llvm/cmake/platforms/iOS.cmake b/llvm/cmake/platforms/iOS.cmake
new file mode 100644
index 00000000000..49736432bdf
--- /dev/null
+++ b/llvm/cmake/platforms/iOS.cmake
@@ -0,0 +1,47 @@
+# Toolchain config for iOS.
+#
+# Usage:
+# mkdir build; cd build
+# cmake ..; make
+# mkdir ios; cd ios
+# cmake -DLLVM_IOS_TOOLCHAIN_DIR=/path/to/ios/ndk \
+# -DCMAKE_TOOLCHAIN_FILE=../../cmake/platforms/iOS.cmake ../..
+# make <target>
+
+SET(CMAKE_SYSTEM_NAME Darwin)
+SET(CMAKE_SYSTEM_VERSION 13)
+SET(CMAKE_CXX_COMPILER_WORKS True)
+SET(CMAKE_C_COMPILER_WORKS True)
+SET(DARWIN_TARGET_OS_NAME ios)
+
+IF(NOT DEFINED ENV{SDKROOT})
+ MESSAGE(FATAL_ERROR "SDKROOT env var must be set: " $ENV{SDKROOT})
+ENDIF()
+
+IF(NOT CMAKE_C_COMPILER)
+ execute_process(COMMAND xcrun -sdk iphoneos -find clang
+ OUTPUT_VARIABLE CMAKE_C_COMPILER
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ message(STATUS "Using c compiler ${CMAKE_C_COMPILER}")
+ENDIF()
+
+IF(NOT CMAKE_CXX_COMPILER)
+ execute_process(COMMAND xcrun -sdk iphoneos -find clang++
+ OUTPUT_VARIABLE CMAKE_CXX_COMPILER
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ message(STATUS "Using c compiler ${CMAKE_CXX_COMPILER}")
+ENDIF()
+
+IF (NOT DEFINED IOS_MIN_TARGET)
+execute_process(COMMAND xcodebuild -sdk iphoneos -version SDKVersion
+ OUTPUT_VARIABLE IOS_MIN_TARGET
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ENDIF()
+
+SET(IOS_COMMON_FLAGS "-isysroot $ENV{SDKROOT} -mios-version-min=${IOS_MIN_TARGET}")
+SET(CMAKE_C_FLAGS "${IOS_COMMON_FLAGS}" CACHE STRING "toolchain_cflags" FORCE)
+SET(CMAKE_CXX_FLAGS "${IOS_COMMON_FLAGS}" CACHE STRING "toolchain_cxxflags" FORCE)
+SET(CMAKE_LINK_FLAGS "${IOS_COMMON_FLAGS}" CACHE STRING "toolchain_linkflags" FORCE)
OpenPOWER on IntegriCloud