From a24c051e5225c4485937f72721a1c5f9d8bf7f9f Mon Sep 17 00:00:00 2001 From: Sonny Falk Date: Wed, 26 Aug 2015 22:43:01 +0000 Subject: [PATCH] CMake: Cross compiling requires internal SDK. Refactor configure_sdk_darwin(), remove the "internal" parameter since all calls are the same, make it respect SWIFT_USE_INTERNAL_SDK instead. Make it use the internal SDK only if cross compiling tools, since it's required. Swift SVN r31509 --- CMakeLists.txt | 17 ++++++++++------- cmake/modules/SwiftConfigureSDK.cmake | 7 +++---- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 676cd25deed9f..6600a3064632e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -228,8 +228,11 @@ find_program(LIPO "lipo") if("${SWIFT_NATIVE_LLVM_TOOLS_PATH}" STREQUAL "") set(SWIFT_CROSS_COMPILING FALSE) + set(SWIFT_USE_INTERNAL_SDK FALSE) else() set(SWIFT_CROSS_COMPILING TRUE) + # Cross compiling tools requires the internal SDK. + set(SWIFT_USE_INTERNAL_SDK TRUE) endif() # Reset CMAKE_SYSTEM_PROCESSOR if not cross-compiling. @@ -362,7 +365,7 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") is_sdk_requested(OSX swift_build_osx) if(swift_build_osx) - configure_sdk_darwin(OSX "OS X" "10.9" macosx macosx macosx "x86_64" FALSE) + configure_sdk_darwin(OSX "OS X" "10.9" macosx macosx macosx "x86_64") configure_target_variant(OSX-DA "OS X Debug+Asserts" OSX DA "Debug+Asserts") configure_target_variant(OSX-RA "OS X Release+Asserts" OSX RA "Release+Asserts") configure_target_variant(OSX-R "OS X Release" OSX R "Release") @@ -379,7 +382,7 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") is_sdk_requested(IOS swift_build_ios) if(swift_build_ios AND ${swift_can_crosscompile_stdlib}) - configure_sdk_darwin(IOS "iOS" "7.0" iphoneos ios ios "armv7;armv7s;arm64" FALSE) + configure_sdk_darwin(IOS "iOS" "7.0" iphoneos ios ios "armv7;armv7s;arm64") configure_target_variant(IOS-DA "iOS Debug+Asserts" IOS DA "Debug+Asserts") configure_target_variant(IOS-RA "iOS Release+Asserts" IOS RA "Release+Asserts") configure_target_variant(IOS-R "iOS Release" IOS R "Release") @@ -388,7 +391,7 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") is_sdk_requested(IOS_SIMULATOR swift_build_ios_simulator) if(swift_build_ios_simulator AND ${swift_can_crosscompile_stdlib}) configure_sdk_darwin(IOS_SIMULATOR "iOS Simulator" "7.0" iphonesimulator - ios-simulator ios "i386;x86_64" FALSE) + ios-simulator ios "i386;x86_64") configure_target_variant( IOS_SIMULATOR-DA "iOS Debug+Asserts" IOS_SIMULATOR DA "Debug+Asserts") configure_target_variant( @@ -400,7 +403,7 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") if(${SWIFT_ENABLE_TARGET_TVOS}) is_sdk_requested(TVOS swift_build_tvos) if(swift_build_tvos AND ${swift_can_crosscompile_stdlib}) - configure_sdk_darwin(TVOS "tvOS" "9.0" appletvos tvos tvos "arm64" FALSE) + configure_sdk_darwin(TVOS "tvOS" "9.0" appletvos tvos tvos "arm64") configure_target_variant(TVOS-DA "tvOS Debug+Asserts" TVOS DA "Debug+Asserts") configure_target_variant(TVOS-RA "tvOS Release+Asserts" TVOS RA "Release+Asserts") configure_target_variant(TVOS-R "tvOS Release" TVOS R "Release") @@ -408,7 +411,7 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") is_sdk_requested(TVOS_SIMULATOR swift_build_tvos_simulator) if(swift_build_tvos_simulator AND ${swift_can_crosscompile_stdlib}) - configure_sdk_darwin(TVOS_SIMULATOR "tvOS Simulator" "9.0" appletvsimulator tvos-simulator tvos "x86_64" FALSE) + configure_sdk_darwin(TVOS_SIMULATOR "tvOS Simulator" "9.0" appletvsimulator tvos-simulator tvos "x86_64") configure_target_variant( TVOS_SIMULATOR-DA "tvOS Debug+Asserts" TVOS_SIMULATOR DA "Debug+Asserts") configure_target_variant( @@ -420,7 +423,7 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") is_sdk_requested(WATCHOS swift_build_watchos) if(swift_build_watchos AND ${swift_can_crosscompile_stdlib}) - configure_sdk_darwin(WATCHOS "watchOS" "2.0" watchos watchos watchos "armv7k" FALSE) + configure_sdk_darwin(WATCHOS "watchOS" "2.0" watchos watchos watchos "armv7k") configure_target_variant(WATCHOS-DA "watchOS Debug+Asserts" WATCHOS DA "Debug+Asserts") configure_target_variant(WATCHOS-RA "watchOS Release+Asserts" WATCHOS RA "Release+Asserts") configure_target_variant(WATCHOS-R "watchOS Release" WATCHOS R "Release") @@ -428,7 +431,7 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") is_sdk_requested(WATCHOS_SIMULATOR swift_build_watchos_simulator) if(swift_build_watchos_simulator AND ${swift_can_crosscompile_stdlib}) - configure_sdk_darwin(WATCHOS_SIMULATOR "watchOS Simulator" "2.0" watchsimulator watchos-simulator watchos "i386" FALSE) + configure_sdk_darwin(WATCHOS_SIMULATOR "watchOS Simulator" "2.0" watchsimulator watchos-simulator watchos "i386") configure_target_variant(WATCHOS_SIMULATOR-DA "watchOS Debug+Asserts" WATCHOS_SIMULATOR DA "Debug+Asserts") configure_target_variant(WATCHOS_SIMULATOR-RA "watchOS Release+Asserts" WATCHOS_SIMULATOR RA "Release+Asserts") configure_target_variant(WATCHOS_SIMULATOR-R "watchOS Release" WATCHOS_SIMULATOR R "Release") diff --git a/cmake/modules/SwiftConfigureSDK.cmake b/cmake/modules/SwiftConfigureSDK.cmake index b6b40dd9c5160..234107b367d39 100644 --- a/cmake/modules/SwiftConfigureSDK.cmake +++ b/cmake/modules/SwiftConfigureSDK.cmake @@ -37,8 +37,6 @@ endfunction() # version_min_name # The name used in the -mOS-version-min flag # triple_name # The name used in Swift's -triple # architectures # A list of architectures this SDK supports -# internal # Whether the prefer the internal SDK, if present, -# # for building C code and linking # ) # # Sadly there are three OS naming conventions. @@ -62,7 +60,7 @@ endfunction() # SWIFT_SDK_${prefix}_ARCH_${ARCH}_TRIPLE Triple name macro(configure_sdk_darwin prefix name deployment_version xcrun_name - version_min_name triple_name architectures internal) + version_min_name triple_name architectures) # Note: this has to be implemented as a macro because it sets global # variables. @@ -85,7 +83,8 @@ macro(configure_sdk_darwin set(SWIFT_SDK_${prefix}_PATH "" CACHE PATH "Path to the ${name} SDK") if(NOT SWIFT_SDK_${prefix}_PATH) - if(${internal}) + if(${SWIFT_USE_INTERNAL_SDK}) + # Prefer the internal SDK, if present, for building C code and linking. execute_process( COMMAND "xcrun" "--sdk" "${xcrun_name}.internal" "--show-sdk-path" OUTPUT_VARIABLE SWIFT_SDK_${prefix}_PATH