Building a Swift only .app bundle doesn't add rpath (mixed Swift/C works)
I sent an email to the mailing list but I think I explained myself badly.
We are building an .app bundle on Xcode with Swift sources (and trying to use CMake). Swift sources require a shared library which Xcode helpfully puts in the .app for you. Our CMakeLists looks somthing like this (shortened significantly):
enable_language(Swift)
set(CMAKE_Swift_LANGUAGE_VERSION 4.0)
set(sourceFiles
AboutWindow.swift
AppDelegate.swift
Device.swift
DeviceMenuController.swift
# test.c
)
add_executable(hardwareui
MACOSX_BUNDLE
${sourceFiles}
)
set_target_properties(hardwareui PROPERTIES
INSTALL_RPATH "@loader_path/../Frameworks"
BUILD_RPATH "@loader_path/../Frameworks"
)
If I debug cmake while making the Xcode project I can see that this->RuntimeFlag
in cmComputeLinkInformation::cmComputeLinkInformation
is false. This means that the rpath is not added and then the program doesn't run. If I add in the test.c file (commented out above) then this->LinkLanguage
is different so this->RuntimeFlag
is set and everything works. I am not really sure of the best way to fix this.