Files
swift-mirror/Runtimes/Overlay/Linux/glibc/clang/CMakeLists.txt
Evan Wilde e7a8bf7288 CMake: Add GlibC Clang Overlay to export set
Adding the Glibc Clang Overlay interface target to the installed export
set. The interface library exists to plumb the appropriate flags through
the build graph and ensure that the modulemap and header file are
generated when depended on.

Interface libraries need to be in the export set when depended on by a
public library to ensure that the appropriate install interface flags
are exposed to targets importing the library from outside of the build
system, regardless of whether the interface library actually installs
any files.

This fixes the configuration-time error:

Export called with target "swiftGlibc" which requires
"SwiftGlibcClangOverlay" that is not in any export set.
2025-12-01 15:27:48 -08:00

39 lines
1.1 KiB
CMake

gyb_expand(glibc.modulemap.gyb glibc.modulemap
FLAGS -DCMAKE_SDK="LINUX")
gyb_expand(SwiftGlibc.h.gyb SwiftGlibc.h)
file(CONFIGURE
OUTPUT glibc-overlay.yml
CONTENT [==[
---
version: 0
case-sensitive: false
use-external-names: false
roots:
- name: "/usr/include"
type: directory
contents:
- name: module.modulemap
type: file
external-contents: "@CMAKE_CURRENT_BINARY_DIR@/glibc.modulemap"
- name: SwiftGlibc.h
type: file
external-contents: "@CMAKE_CURRENT_BINARY_DIR@/SwiftGlibc.h"
]==]
ESCAPE_QUOTES @ONLY NEWLINE_STYLE LF)
add_library(SwiftGlibcClangOverlay INTERFACE
SwiftGlibc.h
glibc.modulemap)
target_compile_options(SwiftGlibcClangOverlay INTERFACE
"$<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:Swift>:SHELL:-vfsoverlay ${CMAKE_CURRENT_BINARY_DIR}/glibc-overlay.yml>>")
install(TARGETS SwiftGlibcClangOverlay EXPORT SwiftOverlayTargets)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/glibc.modulemap"
"${CMAKE_CURRENT_BINARY_DIR}/SwiftGlibc.h"
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/swift/${SwiftOverlay_PLATFORM_SUBDIR}/${SwiftOverlay_ARCH_SUBDIR}")