From 76fbdeb7d5a65dcb220bc0d73cfb8dd66293fde5 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Fri, 12 Feb 2016 23:36:05 +0000 Subject: [PATCH] cmake: Simplify the iOS.cmake toolchain - Remove a comment that was clearly copy pasted from Android.cmake and isn't relevant. - Remove the toolchain's sensitivity to the environment. It's less error prone to just allow users to set CMAKE_OSX_SYSROOT if they want to use a custom SDK. - Stop explicitly setting -mios-version-min to the default value. It just adds needless complexity. This makes building the native tablegen work for me even when SDKROOT is set in the environment (or passed in as -DCMAKE_OSX_SYSROOT). llvm-svn: 260763 --- llvm/cmake/platforms/iOS.cmake | 55 ++++++++++++------------------------------ 1 file changed, 15 insertions(+), 40 deletions(-) diff --git a/llvm/cmake/platforms/iOS.cmake b/llvm/cmake/platforms/iOS.cmake index 4914059..99692fd 100644 --- a/llvm/cmake/platforms/iOS.cmake +++ b/llvm/cmake/platforms/iOS.cmake @@ -1,39 +1,26 @@ # 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 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}) - execute_process(COMMAND xcodebuild -version -sdk iphoneos Path - OUTPUT_VARIABLE SDKROOT - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) -ELSE() - execute_process(COMMAND xcodebuild -version -sdk $ENV{SDKROOT} Path - OUTPUT_VARIABLE SDKROOT - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) -ENDIF() +if(NOT CMAKE_OSX_SYSROOT) + execute_process(COMMAND xcodebuild -version -sdk iphoneos Path + OUTPUT_VARIABLE SDKROOT + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) -IF(NOT EXISTS ${SDKROOT}) - MESSAGE(FATAL_ERROR "SDKROOT could not be detected!") -ENDIF() + IF(NOT EXISTS ${SDKROOT}) + MESSAGE(FATAL_ERROR "SDKROOT could not be detected!") + ENDIF() -set(CMAKE_OSX_SYSROOT ${SDKROOT}) + message(STATUS "Using SDKROOT ${SDKROOT}") + set(CMAKE_OSX_SYSROOT ${SDKROOT}) +endif() IF(NOT CMAKE_C_COMPILER) - execute_process(COMMAND xcrun -sdk ${SDKROOT} -find clang + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang OUTPUT_VARIABLE CMAKE_C_COMPILER ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -41,7 +28,7 @@ IF(NOT CMAKE_C_COMPILER) ENDIF() IF(NOT CMAKE_CXX_COMPILER) - execute_process(COMMAND xcrun -sdk ${SDKROOT} -find clang++ + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang++ OUTPUT_VARIABLE CMAKE_CXX_COMPILER ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -49,7 +36,7 @@ IF(NOT CMAKE_CXX_COMPILER) ENDIF() IF(NOT CMAKE_AR) - execute_process(COMMAND xcrun -sdk ${SDKROOT} -find ar + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find ar OUTPUT_VARIABLE CMAKE_AR_val ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -58,22 +45,10 @@ IF(NOT CMAKE_AR) ENDIF() IF(NOT CMAKE_RANLIB) - execute_process(COMMAND xcrun -sdk ${SDKROOT} -find ranlib + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find ranlib OUTPUT_VARIABLE CMAKE_RANLIB_val ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) SET(CMAKE_RANLIB ${CMAKE_RANLIB_val} CACHE FILEPATH "Ranlib") message(STATUS "Using ranlib ${CMAKE_RANLIB}") ENDIF() - -IF (NOT DEFINED IOS_MIN_TARGET) -execute_process(COMMAND xcodebuild -sdk ${SDKROOT} -version SDKVersion - OUTPUT_VARIABLE IOS_MIN_TARGET - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) -ENDIF() - -SET(IOS_COMMON_FLAGS "-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) -- 2.7.4