Progress Report
TL;DR - Took the long road back to where I was. Will try again next weekend. My main ask is where the "Swift module directory structure" is documented. I feel I must have missed some obvious place to look.
Searches that are helping
I made ANOTHER repo, this one duplicates of the same project built several different ways so I can compare build outputs: GitHub - carlynorama/SoManyWaysToInclude
- swiftc - build static then build main exe
- Package - all the same project but exe target and lib target
- CMAKE
add_subdirectory
- CMAKE
add_library(${EXAMPLE_LIBRARY_NAME} STATIC IMPORTED)
These all work fine. (Although I'm sure I'm ignoring about 1001 conventions)
Moving into find_pacakge
territory is proving to be stricter about what it will recognize, but I have more than one thing going wrong, I suspect.
Problems with the installed package files & layout
But a big problem is I'm not sure where to find out how the files should be kept and what files/directories I should verify are there.
There appear to be changes going on headed into 4.1 for CMake, but CMP0195 mentions "Swift module directory structure". Where is that convention documented? Does it mention where relative to the .swiftmodule
directory the .a
file should live?
So I looked at examples I assumed should be "correct"
find /Users/carlynorama/Library/Developer/ -type d -name "*.swiftmodule"
And found they lived in folders like
# DerivedData
/Build/Products/Debug-iphonesimulator/
/Build/Products/Debug/
/Debug-xrsimulator/
# Toolchains
/usr/lib/swift/iphonesimulator/
/usr/lib/swift_static/macosx/
Inside those folders the list can look something like
rm64-apple-tvos-simulator.abi.json
arm64-apple-tvos-simulator.private.swiftinterface
arm64-apple-tvos-simulator.swiftdoc
arm64-apple-tvos-simulator.swiftinterface
arm64-apple-tvos-simulator.swiftmodule
Synchronization.opt.bitstream
x86_64-apple-tvos-simulator.abi.json
x86_64-apple-tvos-simulator.private.swiftinterface
x86_64-apple-tvos-simulator.swiftdoc
x86_64-apple-tvos-simulator.swiftinterface
x86_64-apple-tvos-simulator.swiftmodule
Then I looked for the file types
find /Users/carlynorama/Library/Developer/ -type f -name "*.swiftmodule"
Thats where the actual the architecture references rather than just platform
/usr/lib/swift/watchsimulator/Synchronization.swiftmodule/x86_64-apple-watchos-simulator.swiftmodule
/Build/Intermediates.noindex/Doable.build/Debug-iphonesimulator/StringLoggable.build/Objects-normal/arm64/StringLoggable.swiftmodule
/Build/Products/Debug/Markdown.swiftmodule/arm64-apple-macos.swiftmodule
Sometimes the arch is in a folder anme, some times it's in a file name. I would guess some build products folders might have some of their own conventions as they aren't really emitted for consumption by something else so I should focus on the matching patters that show up in the toolchains
Problems with my {ModuleName}Targets.cmake
While I focus on getting the library layout right I have made a tmp_build.sh to focus on the MainProject build errors working with the existing layout. It is a call to swiftc based on the most recent one that failed according to the Ninja error.
These are problems I think come from my {ModuleName}Targets.cmake file generation not being swift specific enough.
-
generated build script -I
s a /include
folder instead of lib
for module files. There are no C headers, so everything should be in lib, including the interface files. In tmp_build I just corrected it to lib by hand.
-
missing dir name in MainProject build, but based on Library information? Seeing not sure which CMake var isn't set correctly.
-
/hello.dir//output-file-map.json
in both generated path name and build structure
-
/hello.dir//hello.swiftdeps
in that file
-
fixing these by hand to run the tmp_build.sh for now.
Next Steps
Keep poking around the swiftlang repo for .cmake files that generate modules!