diff --git a/Runtimes/Core/CMakeLists.txt b/Runtimes/Core/CMakeLists.txt index 05f2439653a..959cc5c5fd3 100644 --- a/Runtimes/Core/CMakeLists.txt +++ b/Runtimes/Core/CMakeLists.txt @@ -68,6 +68,7 @@ include(DefaultSettings) include(EmitSwiftInterface) include(PlatformInfo) include(gyb) +include(Plist) include("${SwiftCore_VENDOR_MODULE_DIR}/Settings.cmake" OPTIONAL) diff --git a/Runtimes/Core/cmake/modules/Plist.cmake b/Runtimes/Core/cmake/modules/Plist.cmake new file mode 100644 index 00000000000..d2f9e6c65c0 --- /dev/null +++ b/Runtimes/Core/cmake/modules/Plist.cmake @@ -0,0 +1,31 @@ +function(generate_plist project_name project_version target) + set(PLIST_INFO_PLIST "Info.plist") + set(PLIST_INFO_NAME "${project_name}") + + # Underscores aren't permitted in the bundle identifier. + string(REPLACE "_" "" PLIST_INFO_UTI "com.apple.dt.runtime.${PLIST_INFO_NAME}") + set(PLIST_INFO_VERSION "${project_version}") + set(PLIST_INFO_BUILD_VERSION "${project_version}") + + set(PLIST_INFO_PLIST_OUT "${PLIST_INFO_PLIST}") + set(PLIST_INFO_PLIST_IN "${PROJECT_SOURCE_DIR}/${PLIST_INFO_PLIST}.in") + + if(APPLE) + target_link_options(${target} PRIVATE + "SHELL:-Xlinker -sectcreate -Xlinker __TEXT -Xlinker __info_plist -Xlinker ${CMAKE_CURRENT_BINARY_DIR}/${PLIST_INFO_PLIST_OUT}") + endif() + + configure_file( + "${PLIST_INFO_PLIST_IN}" + "${PLIST_INFO_PLIST_OUT}" + @ONLY + NEWLINE_STYLE UNIX) + + set_property(TARGET ${target} APPEND PROPERTY LINK_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${PLIST_INFO_PLIST_OUT}") + + # If Application Extensions are enabled, pass the linker flag marking + # the dylib as safe. + if (CXX_SUPPORTS_FAPPLICATION_EXTENSION AND (NOT DISABLE_APPLICATION_EXTENSION)) + list(APPEND link_flags "-Wl,-application_extension") + endif() +endfunction() diff --git a/Runtimes/Core/core/CMakeLists.txt b/Runtimes/Core/core/CMakeLists.txt index a2cb3d4220f..6f8b24ba212 100644 --- a/Runtimes/Core/core/CMakeLists.txt +++ b/Runtimes/Core/core/CMakeLists.txt @@ -347,6 +347,9 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Swift.swiftmodule" emit_swift_interface(swiftCore) install_swift_interface(swiftCore) +# Configure plist creation for Darwin platforms. +generate_plist("${CMAKE_PROJECT_NAME}" "${CMAKE_PROJECT_VERSION}" swiftCore) + include("${SwiftCore_VENDOR_MODULE_DIR}/swiftCore.cmake" OPTIONAL) # TODO: Embedded SwiftCore builds diff --git a/Runtimes/Resync.cmake b/Runtimes/Resync.cmake index a3a11bf1411..2fb3584ab6b 100644 --- a/Runtimes/Resync.cmake +++ b/Runtimes/Resync.cmake @@ -59,6 +59,18 @@ copy_library_sources(include "" "Core") # Copy magic linker symbols copy_library_sources("linker-support" "" "Core") +# Copy Plist +message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Core/Info.plist.in") +file(COPY_FILE + "${StdlibSources}/Info.plist.in" # From + "${CMAKE_CURRENT_LIST_DIR}/Core/Info.plist.in" # To + RESULT _output + ONLY_IF_DIFFERENT) +if(_output) + message(SEND_ERROR + "Copy ${StdlibSources}/Info.plist.in] -> Core/Info.plist.in Failed: ${_output}") +endif() + set(CoreLibs LLVMSupport SwiftShims