|
1 | 1 | set(sources
|
2 |
| - module.map |
3 |
| - ) |
| 2 | + Glibc.swift |
| 3 | +) |
| 4 | + |
4 | 5 | set(output_dir "${SWIFTLIB_DIR}/glibc")
|
5 | 6 |
|
6 |
| -set(commands |
7 |
| - COMMAND ${CMAKE_COMMAND} "-E" "make_directory" "${output_dir}") |
8 |
| -set(outputs) |
9 |
| -foreach(input ${sources}) |
10 |
| - list(APPEND commands |
11 |
| - COMMAND |
12 |
| - "${CMAKE_COMMAND}" "-E" "copy_if_different" |
13 |
| - "${CMAKE_CURRENT_SOURCE_DIR}/${input}" |
14 |
| - "${output_dir}/${input}") |
15 |
| - list(APPEND outputs "${output_dir}/${input}") |
16 |
| -endforeach() |
17 |
| -# Put the output dir itself last so that it isn't considered the primary output. |
18 |
| -list(APPEND outputs "${output_dir}") |
| 7 | +# Set correct paths to glibc headers |
| 8 | +set(GLIBC_INCLUDE_PATH "/usr/include") |
| 9 | +if(CMAKE_LIBRARY_ARCHITECTURE) |
| 10 | + set(GLIBC_ARCH_INCLUDE_PATH "${GLIBC_INCLUDE_PATH}/${CMAKE_LIBRARY_ARCHITECTURE}") |
| 11 | +else() |
| 12 | + set(GLIBC_ARCH_INCLUDE_PATH "${GLIBC_INCLUDE_PATH}") |
| 13 | +endif() |
| 14 | +if (NOT EXISTS "${GLIBC_ARCH_INCLUDE_PATH}/sys") |
| 15 | + message(FATAL_ERROR "Glibc headers were not found.") |
| 16 | +endif() |
| 17 | + |
| 18 | +# Generate module.map |
| 19 | +configure_file(module.map.in "${CMAKE_CURRENT_BINARY_DIR}/module.map" @ONLY) |
| 20 | + |
19 | 21 | add_custom_command_target(unused_var
|
20 |
| - ${commands} |
| 22 | + COMMAND |
| 23 | + "${CMAKE_COMMAND}" "-E" "make_directory" "${output_dir}" |
| 24 | + COMMAND |
| 25 | + "${CMAKE_COMMAND}" "-E" "copy_if_different" |
| 26 | + "${CMAKE_CURRENT_BINARY_DIR}/module.map" |
| 27 | + "${output_dir}/module.map" |
21 | 28 | CUSTOM_TARGET_NAME "copy_glibc_module"
|
22 |
| - OUTPUT "${outputs}" |
23 |
| - DEPENDS "${sources}" |
| 29 | + OUTPUT "${output_dir}/module.map" "${output_dir}" |
| 30 | + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/module.map" |
24 | 31 | COMMENT "Copying Glibc module to ${output_dir}")
|
25 | 32 |
|
26 | 33 | swift_install_in_component(stdlib
|
27 |
| - FILES ${sources} |
| 34 | + FILES "${output_dir}/module.map" |
28 | 35 | DESTINATION "lib/swift/glibc")
|
29 | 36 |
|
30 | 37 | add_swift_library(swiftGlibc IS_SDK_OVERLAY
|
31 |
| - Glibc.swift |
32 |
| - FILE_DEPENDS copy_glibc_module "${SWIFTLIB_DIR}/glibc" |
33 |
| - INSTALL_IN_COMPONENT stdlib-experimental) |
34 |
| - |
| 38 | + ${sources} |
| 39 | + FILE_DEPENDS copy_glibc_module "${output_dir}" |
| 40 | + INSTALL_IN_COMPONENT stdlib-experimental) |
0 commit comments