From 26e5be03b7f416e59e59c8edb60f9d8fb4cc1f8a Mon Sep 17 00:00:00 2001 From: Dmitri Hrybenko Date: Tue, 29 Sep 2015 22:59:00 +0000 Subject: [PATCH] CMake: add an option that forces the use of internal SDK rdar://22866512 Swift SVN r32316 --- CMakeLists.txt | 7 +++++-- cmake/modules/SwiftConfigureSDK.cmake | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6785ac710171a..9c015488abc4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,6 +126,10 @@ option(SWIFT_EMBED_BITCODE_SECTION "If non-empty, embeds LLVM bitcode binary sections in the standard library and overlay binaries for supported platforms" FALSE) +option(SWIFT_DARWIN_USE_INTERNAL_SDK + "If true, selects the internal SDK on Darwin" + FALSE) + option(SWIFT_RUNTIME_CRASH_REPORTER_CLIENT "Whether to enable CrashReporter integration" FALSE) @@ -231,11 +235,10 @@ 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) + set(SWIFT_DARWIN_USE_INTERNAL_SDK TRUE) endif() # Reset CMAKE_SYSTEM_PROCESSOR if not cross-compiling. diff --git a/cmake/modules/SwiftConfigureSDK.cmake b/cmake/modules/SwiftConfigureSDK.cmake index 234107b367d39..820213efc3f98 100644 --- a/cmake/modules/SwiftConfigureSDK.cmake +++ b/cmake/modules/SwiftConfigureSDK.cmake @@ -83,12 +83,15 @@ macro(configure_sdk_darwin set(SWIFT_SDK_${prefix}_PATH "" CACHE PATH "Path to the ${name} SDK") if(NOT SWIFT_SDK_${prefix}_PATH) - if(${SWIFT_USE_INTERNAL_SDK}) + if(${SWIFT_DARWIN_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 OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT EXISTS "${SWIFT_SDK_${prefix}_PATH}/System/Library/Frameworks/module.map") + message(FATAL_ERROR "Internal ${name} SDK not found at SWIFT_SDK_${prefix}_PATH.") + endif() endif() endif()