set(sources
  module.map
  )
set(output_dir "${SWIFTLIB_DIR}/glibc")

set(commands
    COMMAND ${CMAKE_COMMAND} "-E" "make_directory" "${output_dir}")
set(outputs)
foreach(input ${sources})
  list(APPEND commands
      COMMAND
        "${CMAKE_COMMAND}" "-E" "copy_if_different"
        "${CMAKE_CURRENT_SOURCE_DIR}/${input}"
        "${output_dir}/${input}")
  list(APPEND outputs "${output_dir}/${input}")
endforeach()
# Put the output dir itself last so that it isn't considered the primary output.
list(APPEND outputs "${output_dir}")
add_custom_command_target(unused_var
    ${commands}
    CUSTOM_TARGET_NAME "copy_glibc_module"
    OUTPUT "${outputs}"
    DEPENDS "${sources}"
    COMMENT "Copying Glibc module to ${output_dir}")

swift_install_in_component(stdlib-experimental
    FILES ${sources}
    DESTINATION "lib/swift/glibc")

add_swift_library(swiftGlibc IS_SDK_OVERLAY
  Glibc.swift
  FILE_DEPENDS copy_glibc_module "${SWIFTLIB_DIR}/glibc"
  INSTALL_IN_COMPONENT stdlib-experimental)


set(sources
  module.map
  )
set(output_dir "${SWIFTLIB_DIR}/glibc")

set(commands
    COMMAND ${CMAKE_COMMAND} "-E" "make_directory" "${output_dir}")
set(outputs)
foreach(input ${sources})
  list(APPEND commands
      COMMAND
        "${CMAKE_COMMAND}" "-E" "copy_if_different"
        "${CMAKE_CURRENT_SOURCE_DIR}/${input}"
        "${output_dir}/${input}")
  list(APPEND outputs "${output_dir}/${input}")
endforeach()
# Put the output dir itself last so that it isn't considered the primary output.
list(APPEND outputs "${output_dir}")
add_custom_command_target(unused_var
    ${commands}
    CUSTOM_TARGET_NAME "copy_glibc_module"
    OUTPUT "${outputs}"
    DEPENDS "${sources}"
    COMMENT "Copying Glibc module to ${output_dir}")

swift_install_in_component(stdlib
    FILES ${sources}
    DESTINATION "lib/swift/glibc")

add_swift_library(swiftGlibc IS_SDK_OVERLAY
  Glibc.swift
  FILE_DEPENDS copy_glibc_module "${SWIFTLIB_DIR}/glibc"
  INSTALL_IN_COMPONENT stdlib-experimental)


Install Glibc module.map in the stdlib install component
Install Glibc module.map in the stdlib install component

This module map was missing in the buildbot_linux preset's install
components because it doesn't include stdlib-experimental. This file
is actually critical to use the C library on Linux.

Fixes rdar://problem/22645751

Swift SVN r31879
