Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. CMake install(IMPORTED_RUNTIME_ARTIFACTS ?
Forum Updated to NodeBB v4.3 + New Features

CMake install(IMPORTED_RUNTIME_ARTIFACTS ?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 355 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    1
    • PerdrixP Offline
      PerdrixP Offline
      Perdrix
      wrote on last edited by Perdrix
      #3

      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

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SamiV123
        wrote on last edited by
        #2

        How about just using cp either directly or in a script ?

        1 Reply Last reply
        0
        • PerdrixP Offline
          PerdrixP Offline
          Perdrix
          wrote on last edited by Perdrix
          #3

          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

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Redman
            wrote on last edited by
            #4

            First do in root cmakelists

            set(CMAKE_INSTALL_BINDIR ${CMAKE_BINARY_DIR}/deploy)
            set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_BINDIR})
            

            then in target specific cmakelists do

                install(TARGETS ${target}
                    RUNTIME DESTINATION  ${CMAKE_INSTALL_BINDIR}
                )
            

            followed by the one that suits your needs
            1.

            	qt_generate_deploy_qml_app_script(
            		TARGET ${target}
            		OUTPUT_SCRIPT deploy_script
            	)
            	install(SCRIPT ${deploy_script})
            

            or
            2.

            	qt_generate_deploy_app_script(
            		TARGET ${target}
            		OUTPUT_SCRIPT deploy_script
            	)
            	install(SCRIPT ${deploy_script})
            

            If you are using ninja, like me, you can add a custom build step

            image.png
            And your app will be deployed into your bindir/deploy

            Really convenient.

            I wrapped all this in some cmake functions so in the end I only do this for each target.

            # Define install and deploy sequence
            f_install(${PROJECT_NAME})
            f_deploy_qml_app(${PROJECT_NAME})
            
            1 Reply Last reply
            0
            • PerdrixP Perdrix has marked this topic as solved on

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved