Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glibc module: detect location of glibc header files #282

Merged
merged 1 commit into from
Dec 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 29 additions & 23 deletions stdlib/public/Glibc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
set(sources
module.map
)
Glibc.swift
)

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}")
# Set correct paths to glibc headers
set(GLIBC_INCLUDE_PATH "/usr/include")
if(CMAKE_LIBRARY_ARCHITECTURE)
set(GLIBC_ARCH_INCLUDE_PATH "${GLIBC_INCLUDE_PATH}/${CMAKE_LIBRARY_ARCHITECTURE}")
else()
set(GLIBC_ARCH_INCLUDE_PATH "${GLIBC_INCLUDE_PATH}")
endif()
if (NOT EXISTS "${GLIBC_ARCH_INCLUDE_PATH}/sys")
message(FATAL_ERROR "Glibc headers were not found.")
endif()

# Generate module.map
configure_file(module.map.in "${CMAKE_CURRENT_BINARY_DIR}/module.map" @ONLY)

add_custom_command_target(unused_var
${commands}
COMMAND
"${CMAKE_COMMAND}" "-E" "make_directory" "${output_dir}"
COMMAND
"${CMAKE_COMMAND}" "-E" "copy_if_different"
"${CMAKE_CURRENT_BINARY_DIR}/module.map"
"${output_dir}/module.map"
CUSTOM_TARGET_NAME "copy_glibc_module"
OUTPUT "${outputs}"
DEPENDS "${sources}"
OUTPUT "${output_dir}/module.map" "${output_dir}"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/module.map"
COMMENT "Copying Glibc module to ${output_dir}")

swift_install_in_component(stdlib
FILES ${sources}
FILES "${output_dir}/module.map"
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)

${sources}
FILE_DEPENDS copy_glibc_module "${output_dir}"
INSTALL_IN_COMPONENT stdlib-experimental)
Loading