Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Problem with adding executable to macOS bundle
Forum Updated to NodeBB v4.3 + New Features

Problem with adding executable to macOS bundle

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
2 Posts 1 Posters 120 Views 1 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.
  • P Offline
    P Offline
    Perdrix
    wrote 12 days ago last edited by
    #1

    I have an executable on macOS that's built externally to my projects (uchmviewer).

    When I get to the post-build stage in CMake, I copy the executable into my .app bundle. Which is OK, and I can run the built code just fine including the invocation of that executable.

    However the installation of the bundle doesn't do all that's needed to the added executable so, when I try to run it from the installed and signed bundle I get:

    Last login: Mon Jun  9 03:45:59 on ttys000
    /Users/amonra/build/Darwin/arm64/Debug/DeepSkyStacker.app/Contents/MacOS/uchmviewer ; exit;
    amonra@Saturn ~ % /Users/amonra/build/Darwin/arm64/Debug/DeepSkyStacker.app/Contents/MacOS/uchmviewer ; exit;
    dyld[14425]: Library not loaded: @rpath/QtXml.framework/Versions/A/QtXml
      Referenced from: <3BF2E20B-AF0D-3DDA-BB86-17F4A0C1DC34> /Users/amonra/build/Darwin/arm64/Debug/DeepSkyStacker.app/Contents/MacOS/uchmviewer
      Reason: tried: '/opt/Qt/6.9.0/macos/lib/QtXml.framework/Versions/A/QtXml' (code signature in <FA6FE8B6-96D4-3274-8275-554B7D9A5BB0> '/opt/Qt/6.9.0/macos/lib/QtXml.framework/Versions/A/QtXml' not valid for use in process: mapping process and mapped file (non-platform) have different Team IDs), '/System/Volumes/Preboot/Cryptexes/OS/opt/Qt/6.9.0/macos/lib/QtXml.framework/Versions/A/QtXml' (no such file), '/usr/local/lib/QtXml.framework/Versions/A/QtXml' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/QtXml.framework/Versions/A/QtXml' (no such file), '/opt/Qt/6.9.0/macos/lib/QtXml.framework/Versions/A/QtXml' (code signature in <FA6FE8B6-96D4-3274-8275-554B7D9A5BB0> '/opt/Qt/6.9.0/macos/lib/QtXml.framework/Versions/A/QtXml' not valid for use in process: mapping process and mapped file (non-platform) have different Team IDs), '/System/Volumes/Preboot/Cryptexes/OS/opt/Qt/6.9.0/macos/lib/QtXml.framework/Versions/A/QtXml' (no such file), '/usr/local/lib/QtXml.framework/Versions/A/QtXml' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/QtXml.framework/Versions/A/QtXml' (no such file)
    zsh: abort      
    
    Saving session...
    ...copying shared history...
    ...saving history...truncating history files...
    ...completed.
    
    [Process completed]
    

    How can I get the install step in my CMake file to process this in the same way as the executables I build (so that it's rpath is adjusted and all necessary dylibs are added to the bundle)?

    Here's what I have in my CMakeLists.txt file:

    if(APPLE)
        set_target_properties(DeepSkyStacker PROPERTIES
            MACOSX_BUNDLE ON
            MACOSX_BUNDLE_BUNDLE_NAME "DeepSkyStacker"
            MACOSX_BUNDLE_ICON_FILE "DeepSkyStacker.icns"
            MACOSX_BUNDLE_GUI_IDENTIFIER "com.github.deepskystacker.deepskystacker"
            MACOSX_BUNDLE_COPYRIGHT "Copyright © 2018-2025, David C. Partridge; Copyright © 2006-2019, Luc Coiffier"
    		MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/MacOSXBundleInfo.plist.in"
            INSTALL_RPATH "@executable_path/../Frameworks"
    )
    endif()
    
    if(APPLE)
        add_custom_command(TARGET DeepSkyStacker
            POST_BUILD
            #
            # Now we've built the DSS .app bundle, copy the DSSCL binary into the bundle
            # The use of $<TARGET_FILE:DeepSkyStackerCL> in add_custom_command also adds
            # a dependency on the target, so that the DSSCL binary is built before this.
            #
            COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:DeepSkyStackerCL> $<TARGET_BUNDLE_CONTENT_DIR:DeepSkyStacker>/MacOS/
        	COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_BUNDLE_CONTENT_DIR:DeepSkyStacker>/MacOS/ $ENV{HOME}/Downloads/uChmViewer/build/src/uchmviewer
        	COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_BUNDLE_CONTENT_DIR:DeepSkyStacker>/Resources ${Help_Files}
            COMMAND "$ENV{HOME}/.unlock_keychain"
        )
    endif()
    
    if(NOT LINUX)
        set (deploy_tool_options_arg "-verbose=1")
        if(APPLE)
            set(deploy_tool_options_arg "${deploy_tool_options_arg} -hardened-runtime -timestamp -no-strip")
            set(deploy_tool_options_arg "${deploy_tool_options_arg} \"-executable=$<TARGET_BUNDLE_CONTENT_DIR:DeepSkyStacker>/MacOS/DeepSkyStackerCL\"")
            set(deploy_tool_options_arg "${deploy_tool_options_arg} \"-codesign=Developer ID Application: David Partridge (VH8AYT3C7Y)\"")
        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 "${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_FILE_NAME:DeepSkyStacker>.app")
        else()
            message ("Target filename:"  $<TARGET_FILE_NAME:DeepSkyStacker>)
            set(executable_path "${CMAKE_CURRENT_BINARY_DIR}/$<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} BUNDLE DESTINATION .)
    
    1 Reply Last reply
    0
    • P Offline
      P Offline
      Perdrix
      wrote 12 days ago last edited by
      #2

      I tried this:

      if(NOT LINUX)
          set (deploy_tool_options_arg "-verbose=1")
          if(APPLE)
              set(deploy_tool_options_arg "${deploy_tool_options_arg} -hardened-runtime -timestamp -no-strip")
              set(deploy_tool_options_arg "${deploy_tool_options_arg} \"-executable=$<TARGET_BUNDLE_CONTENT_DIR:DeepSkyStacker>/MacOS/DeepSkyStackerCL\"")
              set(deploy_tool_options_arg "${deploy_tool_options_arg} \"-executable=$<TARGET_BUNDLE_CONTENT_DIR:DeepSkyStacker>/MacOS/uchmviewer\"")
              set(deploy_tool_options_arg "${deploy_tool_options_arg} \"-codesign=Developer ID Application: David Partridge (VH8AYT3C7Y)\"")
      

      and it seems to have worked ...

      Was that the best way to do it?

      1 Reply Last reply
      0

      1/2

      9 Jun 2025, 03:07

      • Login

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