Skip to content

Commit

Permalink
CMake: Cross compiling requires internal SDK.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sonnyfalk committed Aug 26, 2015
1 parent 7a49d7e commit a24c051
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
17 changes: 10 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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(
Expand All @@ -400,15 +403,15 @@ 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")
endif()

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(
Expand All @@ -420,15 +423,15 @@ 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")
endif()

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")
Expand Down
7 changes: 3 additions & 4 deletions cmake/modules/SwiftConfigureSDK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.

Expand All @@ -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
Expand Down

0 comments on commit a24c051

Please sign in to comment.