Swift + C/C++ Interop with CMake

I’m trying to setup CMake with Swift and running into issues when compiling cute .

Here’s the repo: GitHub - pusewicz/dungeon_loop_cute

And the command I use: cmake -Bbuild -G Ninja . && cmake --build build.

Unfortunately I’m getting:

$ cmake --build build
[1/1] Linking Swift executable dungeonloop
FAILED: dungeonloop CMakeFiles/dungeonloop.dir/src/main.swift.o
: && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -j 16 -num-threads 16 -emit-executable -o dungeonloop -emit-dependencies -DCF_STATIC -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -output-file-map CMakeFiles/dungeonloop.dir//output-file-map.json -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -I /Users/piotr/Work/Github/dungeon_loop_cute/src -I /Users/piotr/Work/Github/dungeon_loop_cute/build/_deps/cute-src/include -I /Users/piotr/Work/Github/dungeon_loop_cute/build/_deps/cute-src/libraries -I /Users/piotr/Work/Github/dungeon_loop_cute/build/_deps/cute-src/libraries/cimgui -I /Users/piotr/Work/Github/dungeon_loop_cute/build/_deps/cute-src/libraries/cimgui/imgui -I /Users/piotr/Work/Github/dungeon_loop_cute/build/_deps/sdl2-build/include -I /Users/piotr/Work/Github/dungeon_loop_cute/build/_deps/sdl2-build/include-config- -F /Users/piotr/Work/Github/dungeon_loop_cute/build/_deps/cute-build /Users/piotr/Work/Github/dungeon_loop_cute/src/main.swift  -F /Users/piotr/Work/Github/dungeon_loop_cute/build/_deps/cute-build  -L /Users/piotr/Work/Github/dungeon_loop_cute/build/_deps/cute-build  -L /Users/piotr/Work/Github/dungeon_loop_cute/build/_deps/cute-build  -L /Users/piotr/Work/Github/dungeon_loop_cute/build/_deps/sdl2-build  -L /Users/piotr/Work/Github/dungeon_loop_cute/build/_deps/sdl2-build   -L /opt/homebrew/lib   -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib/swift _deps/cute-build/cute.framework/Versions/1.0.0/cute  -Xlinker -framework -Xlinker IOKit  -Xlinker -framework -Xlinker Foundation  -Xlinker -framework -Xlinker Security  -Xlinker -framework -Xlinker QuartzCore  -Xlinker -framework -Xlinker Metal  -Xlinker -framework -Xlinker MetalKit  -Xlinker -framework -Xlinker Network  _deps/cute-build/libphysfs.a  _deps/sdl2-build/libSDL2main.a  _deps/sdl2-build/libSDL2.a  -lm  -liconv  -Wl,-framework,CoreVideo  -Wl,-framework,Cocoa  -Wl,-framework,IOKit  -Wl,-framework,ForceFeedback  -Wl,-framework,Carbon  -Wl,-framework,CoreAudio  -Wl,-framework,AudioToolbox  -Wl,-framework,AVFoundation  -Wl,-framework,Foundation  -Wl,-weak_framework,GameController  -Wl,-weak_framework,Metal  -Wl,-weak_framework,QuartzCore  -Wl,-weak_framework,CoreHaptics  -lc++ && :
error: unknown argument: '-Wl,-framework,CoreVideo'
ninja: build stopped: subcommand failed.

How would I go about resolving this issue? It seems like SDL2 is injecting extra flags and the swiftc compilers does not understand them. Is there a way to have like a 2-stage build, where the cute_framework dep is built into a static lib and then normal build that uses it?

I’m totally new to CMake, so please bear with me!