CMake install(IMPORTED_RUNTIME_ARTIFACTS ?
-
I added this to my CMakeLists.txt on Linux to get the Qt6 libraries copied to my install directory
install(IMPORTED_RUNTIME_ARTIFACTS
Qt6::Core
Qt6::Gui
Qt6::Widgets
Qt6::Network
Qt6::DBus
Qt6::OpenGLWidgets
)
That indeed copies the libraries into the install directory and modifies the application rpath:-- Install configuration: "Debug" -- Up-to-date: /home/amonra/.vs/DSS/Linux/x64/Debug/./libQt6Core.so.6.8.0 -- Up-to-date: /home/amonra/.vs/DSS/Linux/x64/Debug/./libQt6Core.so.6 -- Up-to-date: /home/amonra/.vs/DSS/Linux/x64/Debug/./libQt6Gui.so.6.8.0 -- Up-to-date: /home/amonra/.vs/DSS/Linux/x64/Debug/./libQt6Gui.so.6 -- Up-to-date: /home/amonra/.vs/DSS/Linux/x64/Debug/./libQt6Widgets.so.6.8.0 -- Up-to-date: /home/amonra/.vs/DSS/Linux/x64/Debug/./libQt6Widgets.so.6 -- Up-to-date: /home/amonra/.vs/DSS/Linux/x64/Debug/./libQt6Network.so.6.8.0 -- Up-to-date: /home/amonra/.vs/DSS/Linux/x64/Debug/./libQt6Network.so.6 -- Up-to-date: /home/amonra/.vs/DSS/Linux/x64/Debug/./libQt6DBus.so.6.8.0 -- Up-to-date: /home/amonra/.vs/DSS/Linux/x64/Debug/./libQt6DBus.so.6 -- Up-to-date: /home/amonra/.vs/DSS/Linux/x64/Debug/./libQt6OpenGLWidgets.so.6.8.0 -- Up-to-date: /home/amonra/.vs/DSS/Linux/x64/Debug/./libQt6OpenGLWidgets.so.6 -- Installing: /home/amonra/.vs/DSS/Linux/x64/Debug/./DeepSkyStacker -- Set non-toolchain portion of runtime path of "/home/amonra/.vs/DSS/Linux/x64/Debug/./DeepSkyStacker" to "$ORIGIN:$ORIGIN/"
Unfortunately it didn't copy (at least) libicui18n.so.73 which is also in the Qt libs directory, and probably some others as well, so I get:
error while loading shared libraries: libicui18n.so.73: cannot open shared object file
How should I do this please? I'm not planning to use linuxdeployqt ATM.
Thanks
David -
If found a recent addition to Qt that does pretty much what I want (though it adds more Qt libraries than are necessary - I think it just copies them all :( ). It is qt_generate_deploy_app_script
Here's the complete code from my CMakeLists.txt file showing the both the non-Linux and the Linux path:
if(NOT LINUX) set (deploy_tool_options_arg "") if(APPLE) set(deploy_tool_options_arg "${deploy_tool_options_arg} --hardened-runtime") elseif(WIN32) set(deploy_tool_options_arg "${deploy_tool_options_arg} --pdb") endif() # Generate a deployment script to be executed at install time # App bundles on macOS have an .app suffix if(APPLE) set(executable_path "$<TARGET_FILE_NAME:DeepSkyStacker>.app") else() message ("Target filename:" $<TARGET_FILE_NAME:DeepSkyStacker>) set(executable_path "${CMAKE_INSTALL_BINDIR}/$<TARGET_FILE_NAME:DeepSkyStacker>") endif() message ("executable_path: " ${executable_path}) message ("deploy tools options arg: " ${deploy_tool_options_arg}) qt_generate_deploy_script( TARGET DeepSkyStacker OUTPUT_SCRIPT deploy_script CONTENT " qt_deploy_runtime_dependencies( EXECUTABLE \"${executable_path}\" DEPLOY_TOOL_OPTIONS ${deploy_tool_options_arg} )" ) else() qt_generate_deploy_app_script( TARGET ${PROJECT_NAME} OUTPUT_SCRIPT deploy_script DEPLOY_TOOL_OPTIONS ${deploy_tool_options_arg} ) endif() install (SCRIPT ${deploy_script}) install(TARGETS ${PROJECT_NAME})
Be warned if you are using the Visual Studio Linux workload: It invokes CMake on Linux with
-DCMAKE_SYSTEM_NAME:STRING=“Linux”
which is a big "no-no". It results in CMAKE_CROSSCOMPILING being set to TRUE which results in qt_generate_deploy_app_script refusing to play.
See: https://developercommunity.visualstudio.com/t/Using-CMake-with-Linux-Workload-the-bui/10813104
David