When creating a DragNDrop bundle of my project using the qt framework provided by brew qt5.13.0 the rpath does not seem to be honored although I am setting it to the path I copy the Framework to in my bundle.
I have tried set(MACOSX_RPATH ON)
and set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
but the results remained using a static path instead of rpath and failing to find the bundled Framework on other machines brew qt 5.13.0
in 5.9.5 all that was needed for my cmake to work as expected was
set (CMAKE_INSTALL_RPATH "@executable_path/../Frameworks")
and further down for packaging
set (CPACK_GENERATOR "DragNDrop")
install (DIRECTORY ${Qt5_DIR}/../../QtCore.framework DESTINATION *.app/Contents/Frameworks)
install (DIRECTORY ${Qt5_DIR}/../../QtGui.framework DESTINATION *.app/Contents/Frameworks)
install (DIRECTORY ${Qt5_DIR}/../../QtPrintSupport.framework DESTINATION *.app/Contents/Frameworks)
install (DIRECTORY ${Qt5_DIR}/../../QtTest.framework DESTINATION *.app/Contents/Frameworks)
install (DIRECTORY ${Qt5_DIR}/../../QtWidgets.framework DESTINATION *.app/Contents/Frameworks)
install (FILES "${Qt5_DIR}/../../../plugins/platforms/libqcocoa.dylib" DESTINATION *.app/Contents/PlugIns/platforms)
On qt 5.9.5 from the opensource installer I see the following results with otool -L
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1570.15.0)
/System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL (compatibility version 1.0.0, current version 1.0.0)
@rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.9.0, current version 5.9.5)
@rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.9.0, current version 5.9.5)
@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.9.0, current version 5.9.5)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
whereas when using qt 5.13.0 from brew I get the following
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1575.17.0)
/System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL (compatibility version 1.0.0, current version 1.0.0)
/usr/local/opt/qt/lib/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.13.0, current version 5.13.0)
/usr/local/opt/qt/lib/QtGui.framework/Versions/5/QtGui (compatibility version 5.13.0, current version 5.13.0)
/usr/local/opt/qt/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.13.0, current version 5.13.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)