目标包时未设置 qt 的 CMake DragNDrop 框架 rpath
CMake DragNDrop framework rpath for qt not set when targeting package
当使用 brew qt5.13.0 提供的 qt 框架为我的项目创建 DragNDrop 包时,尽管我将其设置为将框架复制到我的包中的路径,但 rpath 似乎并没有被接受。
我已经尝试了 set(MACOSX_RPATH ON)
和 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
但结果仍然使用静态路径而不是 rpath 并且无法在其他机器上找到捆绑的框架 brew qt 5.13.0
在 5.9.5 中,我的 cmake 按预期工作所需的全部是
set (CMAKE_INSTALL_RPATH "@executable_path/../Frameworks")
再往下进行包装
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)
在开源安装程序的 qt 5.9.5 上,我使用 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)
而当使用 brew 的 qt 5.13.0 时,我得到以下结果
/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)
经过大量挖掘,我终于弄清楚发生了什么。
正如 benlau here when brew builds qt they use the -no-rpath
option. So rather than go through and use install_name_tool on the frameworks I needed I discovered a neat trick about the qt-online-installer. It was script-able and I found a repo with that in it, see qtci 所见。
然后添加后
- git clone https://github.com/benlau/qtci.git;
- source qtci/path.env;
- install-qt-online qt.qt5.5130.clang_64 ~/
到 -travis.yml 我可以用预期的 rpaths
设置我的 Qt_DIR="~/qt/5.13.0/clang_64/lib/cmake/Qt5"
和 link
/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)
@rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.13.0, current version 5.13.0)
@rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.13.0, current version 5.13.0)
@rpath/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)
当使用 brew qt5.13.0 提供的 qt 框架为我的项目创建 DragNDrop 包时,尽管我将其设置为将框架复制到我的包中的路径,但 rpath 似乎并没有被接受。
我已经尝试了 set(MACOSX_RPATH ON)
和 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
但结果仍然使用静态路径而不是 rpath 并且无法在其他机器上找到捆绑的框架 brew qt 5.13.0
在 5.9.5 中,我的 cmake 按预期工作所需的全部是
set (CMAKE_INSTALL_RPATH "@executable_path/../Frameworks")
再往下进行包装
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)
在开源安装程序的 qt 5.9.5 上,我使用 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)
而当使用 brew 的 qt 5.13.0 时,我得到以下结果
/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)
经过大量挖掘,我终于弄清楚发生了什么。
正如 benlau here when brew builds qt they use the -no-rpath
option. So rather than go through and use install_name_tool on the frameworks I needed I discovered a neat trick about the qt-online-installer. It was script-able and I found a repo with that in it, see qtci 所见。
然后添加后
- git clone https://github.com/benlau/qtci.git;
- source qtci/path.env;
- install-qt-online qt.qt5.5130.clang_64 ~/
到 -travis.yml 我可以用预期的 rpaths
设置我的Qt_DIR="~/qt/5.13.0/clang_64/lib/cmake/Qt5"
和 link
/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)
@rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.13.0, current version 5.13.0)
@rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.13.0, current version 5.13.0)
@rpath/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)