Hey all I am pretty new to using c++ interop. I am trying to import the system LLVM headers into a swift package for a project, but can't seem to find any instructions on how to do so. The official c++ / swift interop docs shows a very basic example of how to add a c++ library to the project, but I'm not sure how that would translate to a system library such as LLVM. I tried using a version installed LLVM via Homebrew, but I got the message
For compilers to find llvm you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"
Do these flags need to be in the package.swift manifest? Or should I not be using a Homebrew version of LLVM?
I'm still having some trouble, specifically getting SPM to automatically generate the module map. I think I'm doing something wrong. My package structure looks like this:
// swift-tools-version: 5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "MyProject",
targets: [
.executableTarget(
name: "MyTarget",
publicHeadersPath: "include"
)
]
)
And when I try to:
import llvm
In main.swift, I get:
No such module 'llvm'
Does this all look right? Do I need to set a path somewhere else because I am using the Homebrew LLVM headers?