Files
swift-mirror/stdlib/public/Platform/CMakeLists.txt
Michael Gottesman 8437819b5a [CMake] Revert recent changes.
These changes caused a number of issues:

1. No debug info is emitted when a release-debug info compiler is built.
2. OS X deployment target specification is broken.
3. Swift options were broken without any attempt any recreating that
functionality. The specific option in question is --force-optimized-typechecker.

Such refactorings should be done in a fashion that does not break existing
users and use cases.

This reverts commit e6ce2ff388.
This reverts commit e8645f3750.
This reverts commit 89b038ea7e.
This reverts commit 497cac64d9.
This reverts commit 953ad094da.
This reverts commit e096d1c033.

rdar://30549345
2017-02-15 22:26:06 -08:00

108 lines
4.4 KiB
CMake

set(swift_platform_name)
set(swift_platform_flags)
set(swift_platform_sources
Platform.swift
Misc.c
TiocConstants.swift
tgmath.swift.gyb)
add_swift_library(swiftDarwin ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
Darwin.swift.gyb
${swift_platform_sources}
POSIXError.swift
MachError.swift
SWIFT_COMPILE_FLAGS -Xfrontend -disable-objc-attr-requires-foundation-module "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
TARGET_SDKS ALL_APPLE_PLATFORMS
API_NOTES_NON_OVERLAY)
add_swift_library(swiftGlibc ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
Glibc.swift.gyb
${swift_platform_sources}
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
TARGET_SDKS ANDROID CYGWIN FREEBSD LINUX
DEPENDS glibc_modulemap)
add_swift_library(swiftMSVCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
msvcrt.swift
${swift_platform_sources}
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
TARGET_SDKS WINDOWS)
set(glibc_modulemap_target_list)
foreach(sdk ${SWIFT_SDKS})
if(NOT "${sdk}" STREQUAL "LINUX" AND
NOT "${sdk}" STREQUAL "FREEBSD" AND
NOT "${sdk}" STREQUAL "ANDROID" AND
NOT "${sdk}" STREQUAL "CYGWIN")
continue()
endif()
foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
set(arch_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}")
set(module_dir "${SWIFTLIB_DIR}/${arch_subdir}")
# Determine the location of glibc headers based on the target.
set(GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH "/usr/include")
set(GLIBC_SYSROOT_RELATIVE_ARCH_INCLUDE_PATH ${GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH})
# Some SDKs place their headers in architecture-specific subfolders.
if((${sdk} STREQUAL "LINUX" OR ${sdk} STREQUAL "FREEBSD") AND CMAKE_LIBRARY_ARCHITECTURE)
set(GLIBC_SYSROOT_RELATIVE_ARCH_INCLUDE_PATH "${GLIBC_SYSROOT_RELATIVE_ARCH_INCLUDE_PATH}/${CMAKE_LIBRARY_ARCHITECTURE}")
endif()
set(GLIBC_INCLUDE_PATH "${SWIFT_SDK_${sdk}_PATH}/${GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH}")
set(GLIBC_ARCH_INCLUDE_PATH "${SWIFT_SDK_${sdk}_PATH}/${GLIBC_SYSROOT_RELATIVE_ARCH_INCLUDE_PATH}")
set(glibc_modulemap_source "glibc.modulemap.gyb")
set(glibc_modulemap_out "${module_dir}/glibc.modulemap")
# Configure the module map based on the target. Each platform needs to
# reference different headers, based on what's available in their glibc.
# This is the 'glibc.modulemap' in the 'resource-dir', so
# it's the one we'll look at during the build process.
handle_gyb_source_single(glibc_modulemap_target
SOURCE "${glibc_modulemap_source}"
OUTPUT "${glibc_modulemap_out}"
FLAGS
"-DCMAKE_SDK=${sdk}"
"-DGLIBC_INCLUDE_PATH=${GLIBC_INCLUDE_PATH}"
"-DGLIBC_ARCH_INCLUDE_PATH=${GLIBC_ARCH_INCLUDE_PATH}")
list(APPEND glibc_modulemap_target_list ${glibc_modulemap_target})
# If this SDK is a target for a non-native host, create a native modulemap
# without a sysroot prefix. This is the one we'll install instead.
if(NOT "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_PATH}" STREQUAL "/")
set(glibc_sysroot_relative_modulemap_out "${module_dir}/sysroot-relative-modulemaps/glibc.modulemap")
handle_gyb_source_single(glibc_modulemap_native_target
SOURCE "${glibc_modulemap_source}"
OUTPUT "${glibc_sysroot_relative_modulemap_out}"
FLAGS
"-DCMAKE_SDK=${sdk}"
"-DGLIBC_INCLUDE_PATH=${GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH}"
"-DGLIBC_ARCH_INCLUDE_PATH=${GLIBC_SYSROOT_RELATIVE_ARCH_INCLUDE_PATH}")
list(APPEND glibc_modulemap_target_list ${glibc_modulemap_native_target})
set(glibc_modulemap_out ${glibc_sysroot_relative_modulemap_out})
endif()
# FIXME: When SDK is a cross-compile target (SDK != Host), the generated
# modulemap will be relative to the Host, with hardcoded paths.
# It is not relocatable to the target platform itself.
# This only affects ANDROID right now, but could affect cross-compiled LINUX targets
swift_install_in_component(sdk-overlay
FILES "${glibc_modulemap_out}"
DESTINATION "lib/swift/${arch_subdir}")
endforeach()
endforeach()
add_custom_target(glibc_modulemap DEPENDS ${glibc_modulemap_target_list})