lost with getting CPack to make a macOS Bundle

I am having trouble getting CPack working to build a bundle on macOS using fixup_bundle. I can’t figure out how to get fixup_bundle to recognize the installation path as a bundle. If I comment out fixup_bundle, cpack builds a bundle but of course the binary does not run because it fails to find linked libraries. I think either I’m missing something obvious or the documentation is not explaining something clearly. Here is the CMakeLists.txt and the pull request I am working on.

cpack -G Bundle -V --trace-expand fails with:

CPack Verbose: fixup_bundle
CPack Verbose:   app='/Users/be/mixxx/cmake_build/_CPack_Packages/Darwin/Bundle/mixxx-2.3.0-Darwin/Mixxx.app/Contents/Resources/../../../Mixxx.app'
CPack Verbose:   libs=''
CPack Verbose:   dirs='/Users/be/mixxx/cmake_build;/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/bin;/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib;/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/Qt-5.12.3/lib/cmake/Qt5Widgets/../..'
CPack Verbose:   ignoreItems=''
CPack Verbose: warning: *NOT* handled - .app directory case...
CPack Verbose: fixup_bundle: done

the full output is attached to a comment in the pull request linked above (I cannot attach files or add more than two links as a new Discourse user).

Running cpack -G Bundle in the CMake build directory creates a subdirectory _CPack_Packages/Darwin/Bundle/mixxx-2.3.0-Darwin/Mixxx.app and apparently CMAKE_INSTALL_PREFIX is set to _CPack_Packages/Darwin/Bundle/mixxx-2.3.0-Darwin/Mixxx.app/Contents/Resources. I don’t know where this path comes from; it doesn’t seem to be documented anywhere. The binary is installed to _CPack_Packages/Darwin/Bundle/mixxx-2.3.0-Darwin/Mixxx.app/Contents/MacOS/mixxx with an ugly hack (../MacOS) that doesn’t seem right but I can’t figure out how else to do it.

The plist file does not get copied to _CPack_Packages/Darwin/Bundle/mixxx-2.3.0-Darwin/Mixxx.app/Contents before cpack fails on the fixup_bundle line. Maybe that is why fixup_bundle fails to detect a bundle? But that doesn’t seem right because a bundle is made if I comment out fixup_bundle.

AFAICS, mixxx is not built as a bundle:

You need to pass MACOSX_BUNDLE to add_executable, or set the MACOSX_BUNDLE property on the target using set_property/set_target_properties.

That will result in a application bundle at build time.

1 Like

I thought I saw somewhere to not use MACOSX_BUNDLE with the Bundle generator… anyway, I tried changing add_executable(mixxx WIN32 src/main.cpp) to add_executable(mixxx MACOSX_BUNDLE src/main.cpp) and changed install(TARGETS mixxx RUNTIME DESTINATION ${MIXXX_INSTALL_BINDIR}) to install(TARGETS mixxx BUNDLE DESTINATION .) but I got the same error with fixup_bundle.

I found that wiki page again and now I understand I should be using the DragNDrop generator, not the Bundle generator. I am baffled why I have to scour the web for this unofficial (semiofficial?) wiki page to understand that rather than reading the official documentation.

I am finally getting somewhere with fixup_bundle, but somehow it is copying system libraries – even if I explicitly exclude them with the IGNORE_ITEM parameter – and failing on libmacho. Here is the code and the error message is below:

CPack Verbose: fixup_bundle
CPack Verbose:   app='/Users/be/mixxx/cmake_build/Mixxx.app'
CPack Verbose:   libs=''
CPack Verbose:   dirs='/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib;/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/Qt-5.12.3/lib/cmake/Qt5Widgets/../..'
CPack Verbose:   ignoreItems='/usr/lib/PN548_API.dylib;/usr/lib/PN548_HAL_OSX.dylib;/usr/lib/PN548_OSX.dylib;/usr/lib/closure/libclosured.dylib;/usr/lib/libATCommandStudioDynamic.dylib;/usr/lib/libAccountPolicyTranslation.dylib;/usr/lib/libAudioIssueDetector.dylib;/usr/lib/libBSDPClient.A.dylib;/usr/lib/libBSDPClient.dylib;/usr/lib/libCRFSuite.dylib;/usr/lib/libCRFSuite0.12.dylib;/usr/lib/libChineseTokenizer.dylib;/usr/lib/libCoreStorage.dylib;/usr/lib/libDHCPServer.A.dylib;/usr/lib/libDHCPServer.dylib;/usr/lib/libDiagnosticMessagesClient.dylib;/usr/lib/libFDR_osx.dylib;/usr/lib/libFosl_dynamic.dylib;/usr/lib/libIASAuthReboot.dylib;/usr/lib/libIASUnifiedProgress.dylib;/usr/lib/libMatch.1.dylib;/usr/lib/libMatch.dylib;/usr/lib/libMaxEnt.dylib;/usr/lib/libOpenScriptingUtil.dylib;/usr/lib/libParallelCompression.dylib;/usr/lib/libQMIParserDynamic.dylib;/usr/lib/libSMC.dylib;/usr/lib/libScreenReader.dylib;/usr/lib/libSystem.B.dylib;/usr/lib/libSystem.dylib;/usr/lib/libTelephonyUtilDynamic.dylib;/usr/lib/libThaiTokenizer.dylib;/usr/lib/libUniversalAccess.dylib;/usr/lib/libXSEvent.dylib;/usr/lib/libXplugin.1.dylib;/usr/lib/libXplugin.dylib;/usr/lib/libapple_crypto.dylib;/usr/lib/libapple_nghttp2.dylib;/usr/lib/libapr-1.0.dylib;/usr/lib/libapr-1.dylib;/usr/lib/libaprutil-1.0.dylib;/usr/lib/libaprutil-1.dylib;/usr/lib/libarchive.2.dylib;/usr/lib/libarchive.dylib;/usr/lib/libate.dylib;/usr/lib/libauditd.0.dylib;/usr/lib/libauditd.dylib;/usr/lib/libauto.dylib;/usr/lib/libblas.dylib;/usr/lib/libboringssl.dylib;/usr/lib/libbsm.0.dylib;/usr/lib/libbsm.dylib;/usr/lib/libbz2.1.0.5.dylib;/usr/lib/libbz2.1.0.dylib;/usr/lib/libbz2.dylib;/usr/lib/libc++.1.dylib;/usr/lib/libc++.dylib;/usr/lib/libc++abi.dylib;/usr/lib/libc.dylib;/usr/lib/libcblas.dylib;/usr/lib/libcharset.1.0.0.dylib;/usr/lib/libcharset.1.dylib;/usr/lib/libcharset.dylib;/usr/lib/libclapack.dylib;/usr/lib/libcmph.dylib;/usr/lib/libcom_err.dylib;/usr/lib/libcompression.dylib;/usr/lib/libcoreroutine.dylib;/usr/lib/libcoretls.dylib;/usr/lib/libcoretls_cfhelpers.dylib;/usr/lib/libcrypto.0.9.7.dylib;/usr/lib/libcrypto.0.9.8.dylib;/usr/lib/libcrypto.35.dylib;/usr/lib/libcrypto.41.dylib;/usr/lib/libcrypto.dylib;/usr/lib/libcsfde.dylib;/usr/lib/libcups.2.dylib;/usr/lib/libcups.dylib;/usr/lib/libcupscgi.1.dylib;/usr/lib/libcupscgi.dylib;/usr/lib/libcupsimage.2.dylib;/usr/lib/libcupsimage.dylib;/usr/lib/libcupsmime.1.dylib;/usr/lib/libcupsmime.dylib;/usr/lib/libcupsppdc.1.dylib;/usr/lib/libcupsppdc.dylib;/usr/lib/libcurl.3.dylib;/usr/lib/libcurl.4.dylib;/usr/lib/libcurl.dylib;/usr/lib/libcurses.dylib;/usr/lib/libdbm.dylib;/usr/lib/libdes425.dylib;/usr/lib/libdl.dylib;/usr/lib/libdns_services.dylib;/usr/lib/libdscsym.dylib;/usr/lib/libdtrace.dylib;/usr/lib/libdz.dylib;/usr/lib/libeasyperf.dylib;/usr/lib/libecpg.6.5.dylib;/usr/lib/libecpg.6.dylib;/usr/lib/libecpg.dylib;/usr/lib/libecpg_compat.3.5.dylib;/usr/lib/libecpg_compat.3.dylib;/usr/lib/libecpg_compat.dylib;/usr/lib/libedit.2.dylib;/usr/lib/libedit.3.0.dylib;/usr/lib/libedit.3.dylib;/usr/lib/libedit.dylib;/usr/lib/libenergytrace.dylib;/usr/lib/libexpat.1.dylib;/usr/lib/libexpat.dylib;/usr/lib/libexslt.0.dylib;/usr/lib/libexslt.dylib;/usr/lib/libextension.dylib;/usr/lib/libf77lapack.dylib;/usr/lib/libffi.dylib;/usr/lib/libform.5.4.dylib;/usr/lib/libform.dylib;/usr/lib/libgcc_s.1.dylib;/usr/lib/libgcc_s.10.4.dylib;/usr/lib/libgcc_s.10.5.dylib;/usr/lib/libgermantok.dylib;/usr/lib/libgmalloc.dylib;/usr/lib/libgssapi_krb5.dylib;/usr/lib/libgutenprint.2.dylib;/usr/lib/libheimdal-asn1.dylib;/usr/lib/libhunspell-1.2.0.0.0.dylib;/usr/lib/libhunspell-1.2.0.dylib;/usr/lib/libhunspell-1.2.dylib;/usr/lib/libiconv.2.4.0.dylib;/usr/lib/libiconv.2.dylib;/usr/lib/libiconv.dylib;/usr/lib/libicucore.A.dylib;/usr/lib/libicucore.dylib;/usr/lib/libinfo.dylib;/usr/lib/libiodbc.2.1.18.dylib;/usr/lib/libiodbc.2.dylib;/usr/lib/libiodbc.dylib;/usr/lib/libiodbcinst.2.1.18.dylib;/usr/lib/libiodbcinst.2.dylib;/usr/lib/libiodbcinst.dylib;/usr/lib/libipconfig.dylib;/usr/lib/libipsec.A.dylib;/usr/lib/libipsec.dylib;/usr/lib/libk5crypto.dylib;/usr/lib/libkrb4.dylib;/usr/lib/libkrb5.dylib;/usr/lib/libkrb524.dylib;/usr/lib/libkrb5support.dylib;/usr/lib/libktrace.dylib;/usr/lib/liblangid.dylib;/usr/lib/liblapack.dylib;/usr/lib/liblber.dylib;/usr/lib/libldap.dylib;/usr/lib/libldap_r.dylib;/usr/lib/liblzma.5.dylib;/usr/lib/liblzma.dylib;/usr/lib/libm.dylib;/usr/lib/libmarisa.dylib;/usr/lib/libmecab.1.0.0.dylib;/usr/lib/libmecab.dylib;/usr/lib/libmecabra.dylib;/usr/lib/libmenu.5.4.dylib;/usr/lib/libmenu.dylib;/usr/lib/libmx.A.dylib;/usr/lib/libmx.dylib;/usr/lib/libncurses.5.4.dylib;/usr/lib/libncurses.5.dylib;/usr/lib/libncurses.dylib;/usr/lib/libnetsnmp.15.1.2.dylib;/usr/lib/libnetsnmp.15.dylib;/usr/lib/libnetsnmp.25.dylib;/usr/lib/libnetsnmp.5.2.1.dylib;/usr/lib/libnetsnmp.5.dylib;/usr/lib/libnetsnmp.dylib;/usr/lib/libnetsnmpagent.25.dylib;/usr/lib/libnetsnmpagent.dylib;/usr/lib/libnetsnmphelpers.25.dylib;/usr/lib/libnetsnmphelpers.dylib;/usr/lib/libnetsnmpmibs.25.dylib;/usr/lib/libnetsnmpmibs.dylib;/usr/lib/libnetsnmptrapd.25.dylib;/usr/lib/libnetsnmptrapd.dylib;/usr/lib/libnetwork.dylib;/usr/lib/libnetworkextension.dylib;/usr/lib/libnfrestore.dylib;/usr/lib/libnfshared.dylib;/usr/lib/libobjc.A.dylib;/usr/lib/libobjc.dylib;/usr/lib/libodfde.dylib;/usr/lib/libodmodule.dylib;/usr/lib/libpam.1.dylib;/usr/lib/libpam.2.dylib;/usr/lib/libpam.dylib;/usr/lib/libpanel.5.4.dylib;/usr/lib/libpanel.dylib;/usr/lib/libpcap.A.dylib;/usr/lib/libpcap.dylib;/usr/lib/libpcre.0.dylib;/usr/lib/libpcre.dylib;/usr/lib/libpcreposix.0.dylib;/usr/lib/libpcreposix.dylib;/usr/lib/libpgtypes.3.4.dylib;/usr/lib/libpgtypes.3.dylib;/usr/lib/libpgtypes.dylib;/usr/lib/libpmenergy.dylib;/usr/lib/libpmsample.dylib;/usr/lib/libpoll.dylib;/usr/lib/libpq.5.6.dylib;/usr/lib/libpq.5.dylib;/usr/lib/libpq.dylib;/usr/lib/libprequelite.dylib;/usr/lib/libproc.dylib;/usr/lib/libpthread.dylib;/usr/lib/libpython.dylib;/usr/lib/libpython2.7.dylib;/usr/lib/libquit.dylib;/usr/lib/libreadline.dylib;/usr/lib/libresolv.9.dylib;/usr/lib/libresolv.dylib;/usr/lib/librpcsvc.dylib;/usr/lib/libruby.2.3.0.dylib;/usr/lib/libruby.2.3.dylib;/usr/lib/libruby.dylib;/usr/lib/libsandbox.1.dylib;/usr/lib/libsandbox.dylib;/usr/lib/libsasl2.2.0.1.dylib;/usr/lib/libsasl2.2.0.15.dylib;/usr/lib/libsasl2.2.0.21.dylib;/usr/lib/libsasl2.2.0.22.dylib;/usr/lib/libsasl2.2.dylib;/usr/lib/libsasl2.dylib;/usr/lib/libspindump.dylib;/usr/lib/libsqlite3.0.dylib;/usr/lib/libsqlite3.dylib;/usr/lib/libssl.0.9.7.dylib;/usr/lib/libssl.0.9.8.dylib;/usr/lib/libssl.35.dylib;/usr/lib/libssl.43.dylib;/usr/lib/libssl.dylib;/usr/lib/libstdc++.6.0.9.dylib;/usr/lib/libstdc++.6.dylib;/usr/lib/libstdc++.dylib;/usr/lib/libsysdiagnose.dylib;/usr/lib/libsysmon.dylib;/usr/lib/libsystemstats.dylib;/usr/lib/libtailspin.dylib;/usr/lib/libtcl.dylib;/usr/lib/libtcl8.5.dylib;/usr/lib/libtermcap.dylib;/usr/lib/libtidy.A.dylib;/usr/lib/libtidy.dylib;/usr/lib/libtk.dylib;/usr/lib/libtk8.5.dylib;/usr/lib/libtls.15.dylib;/usr/lib/libtls.6.dylib;/usr/lib/libtls.dylib;/usr/lib/libtzupdate.dylib;/usr/lib/libusrtcp.dylib;/usr/lib/libutil.dylib;/usr/lib/libutil1.0.dylib;/usr/lib/libxar.1.dylib;/usr/lib/libxar.dylib;/usr/lib/libxcselect.dylib;/usr/lib/libxml2.2.dylib;/usr/lib/libxml2.dylib;/usr/lib/libxslt.1.dylib;/usr/lib/libxslt.dylib;/usr/lib/libz.1.1.3.dylib;/usr/lib/libz.1.2.11.dylib;/usr/lib/libz.1.2.5.dylib;/usr/lib/libz.1.2.8.dylib;/usr/lib/libz.1.dylib;/usr/lib/libz.dylib;/usr/lib/log/liblog_AppleLDAPTypes.dylib;/usr/lib/log/liblog_SystemConfiguration.dylib;/usr/lib/log/liblog_audio.dylib;/usr/lib/log/liblog_coreacc.dylib;/usr/lib/log/liblog_cu.dylib;/usr/lib/log/liblog_geo.dylib;/usr/lib/log/liblog_location.dylib;/usr/lib/log/liblog_mediaremote.dylib;/usr/lib/log/liblog_network.dylib;/usr/lib/log/liblog_odtypes.dylib;/usr/lib/log/liblog_signpost.description.dylib;/usr/lib/log/liblog_signpost.telemetry.dylib;/usr/lib/ssh-keychain.dylib;/usr/lib/system/introspection/libdispatch.dylib;/usr/lib/system/introspection/libsystem_pthread.dylib;/usr/lib/system/libcache.dylib;/usr/lib/system/libcommonCrypto.dylib;/usr/lib/system/libcompiler_rt.dylib;/usr/lib/system/libcopyfile.dylib;/usr/lib/system/libcorecrypto.dylib;/usr/lib/system/libcorecrypto_trace.dylib;/usr/lib/system/libdispatch.dylib;/usr/lib/system/libdyld.dylib;/usr/lib/system/libkeymgr.dylib;/usr/lib/system/libkxld.dylib;/usr/lib/system/liblaunch.dylib;/usr/lib/system/libmacho.dylib;/usr/lib/system/libmathCommon.A.dylib;/usr/lib/system/libmathCommon.dylib;/usr/lib/system/libquarantine.dylib;/usr/lib/system/libremovefile.dylib;/usr/lib/system/libsystem_asl.dylib;/usr/lib/system/libsystem_blocks.dylib;/usr/lib/system/libsystem_c.dylib;/usr/lib/system/libsystem_configuration.dylib;/usr/lib/system/libsystem_coreservices.dylib;/usr/lib/system/libsystem_darwin.dylib;/usr/lib/system/libsystem_dnssd.dylib;/usr/lib/system/libsystem_info.dylib;/usr/lib/system/libsystem_kernel.dylib;/usr/lib/system/libsystem_m.dylib;/usr/lib/system/libsystem_malloc.dylib;/usr/lib/system/libsystem_network.dylib;/usr/lib/system/libsystem_networkextension.dylib;/usr/lib/system/libsystem_notify.dylib;/usr/lib/system/libsystem_platform.dylib;/usr/lib/system/libsystem_pthread.dylib;/usr/lib/system/libsystem_sandbox.dylib;/usr/lib/system/libsystem_secinit.dylib;/usr/lib/system/libsystem_symptoms.dylib;/usr/lib/system/libsystem_trace.dylib;/usr/lib/system/libunc.dylib;/usr/lib/system/libunwind.dylib;/usr/lib/system/libxpc.dylib'
CPack Verbose: fixup_bundle: preparing...
CPack Verbose: fixup_bundle: copying...
CPack Verbose: 1/164: *NOT* copying '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/MacOS/Mixxx'
CPack Verbose: 2/164: copying '/usr/lib/closure/libclosured.dylib'
CPack Verbose: 3/164: copying '/usr/lib/libSystem.B.dylib'
CPack Verbose: 4/164: copying '/usr/lib/libc++.1.dylib'
CPack Verbose: 5/164: copying '/usr/lib/libc++abi.dylib'
CPack Verbose: 6/164: copying '/usr/lib/libobjc.A.dylib'
CPack Verbose: 7/164: copying '/usr/lib/libz.1.dylib'
CPack Verbose: 8/164: copying '/usr/lib/system/libcache.dylib'
CPack Verbose: 9/164: copying '/usr/lib/system/libcommonCrypto.dylib'
CPack Verbose: 10/164: copying '/usr/lib/system/libcompiler_rt.dylib'
CPack Verbose: 11/164: copying '/usr/lib/system/libcopyfile.dylib'
CPack Verbose: 12/164: copying '/usr/lib/system/libcorecrypto.dylib'
CPack Verbose: 13/164: copying '/usr/lib/system/libdispatch.dylib'
CPack Verbose: 14/164: copying '/usr/lib/system/libdyld.dylib'
CPack Verbose: 15/164: copying '/usr/lib/system/libkeymgr.dylib'
CPack Verbose: 16/164: copying '/usr/lib/system/liblaunch.dylib'
CPack Verbose: 17/164: copying '/usr/lib/system/libmacho.dylib'
CPack Verbose: 18/164: copying '/usr/lib/system/libquarantine.dylib'
CPack Verbose: 19/164: copying '/usr/lib/system/libremovefile.dylib'
CPack Verbose: 20/164: copying '/usr/lib/system/libsystem_asl.dylib'
CPack Verbose: 21/164: copying '/usr/lib/system/libsystem_blocks.dylib'
CPack Verbose: 22/164: copying '/usr/lib/system/libsystem_c.dylib'
CPack Verbose: 23/164: copying '/usr/lib/system/libsystem_configuration.dylib'
CPack Verbose: 24/164: copying '/usr/lib/system/libsystem_coreservices.dylib'
CPack Verbose: 25/164: copying '/usr/lib/system/libsystem_darwin.dylib'
CPack Verbose: 26/164: copying '/usr/lib/system/libsystem_dnssd.dylib'
CPack Verbose: 27/164: copying '/usr/lib/system/libsystem_info.dylib'
CPack Verbose: 28/164: copying '/usr/lib/system/libsystem_kernel.dylib'
CPack Verbose: 29/164: copying '/usr/lib/system/libsystem_m.dylib'
CPack Verbose: 30/164: copying '/usr/lib/system/libsystem_malloc.dylib'
CPack Verbose: 31/164: copying '/usr/lib/system/libsystem_network.dylib'
CPack Verbose: 32/164: copying '/usr/lib/system/libsystem_networkextension.dylib'
CPack Verbose: 33/164: copying '/usr/lib/system/libsystem_notify.dylib'
CPack Verbose: 34/164: copying '/usr/lib/system/libsystem_platform.dylib'
CPack Verbose: 35/164: copying '/usr/lib/system/libsystem_pthread.dylib'
CPack Verbose: 36/164: copying '/usr/lib/system/libsystem_sandbox.dylib'
CPack Verbose: 37/164: copying '/usr/lib/system/libsystem_secinit.dylib'
CPack Verbose: 38/164: copying '/usr/lib/system/libsystem_symptoms.dylib'
CPack Verbose: 39/164: copying '/usr/lib/system/libsystem_trace.dylib'
CPack Verbose: 40/164: copying '/usr/lib/system/libunwind.dylib'
CPack Verbose: 41/164: copying '/usr/lib/system/libxpc.dylib'
CPack Verbose: 42/164: linking '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libchromaprint.1.4.3.dylib' -> '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libchromaprint.1.dylib'
CPack Verbose: 43/164: copying '/usr/local/opt/flac/lib/libFLAC.8.dylib'
CPack Verbose: 44/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/Qt-5.12.3/lib/QtConcurrent.framework/Versions/5/QtConcurrent'
CPack Verbose: 45/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/Qt-5.12.3/lib/QtCore.framework/Versions/5/QtCore'
CPack Verbose: 46/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/Qt-5.12.3/lib/QtGui.framework/Versions/5/QtGui'
CPack Verbose: 47/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/Qt-5.12.3/lib/QtNetwork.framework/Versions/5/QtNetwork'
CPack Verbose: 48/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/Qt-5.12.3/lib/QtOpenGL.framework/Versions/5/QtOpenGL'
CPack Verbose: 49/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/Qt-5.12.3/lib/QtScript.framework/Versions/5/QtScript'
CPack Verbose: 50/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/Qt-5.12.3/lib/QtScriptTools.framework/Versions/5/QtScriptTools'
CPack Verbose: 51/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/Qt-5.12.3/lib/QtSql.framework/Versions/5/QtSql'
CPack Verbose: 52/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/Qt-5.12.3/lib/QtSvg.framework/Versions/5/QtSvg'
CPack Verbose: 53/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/Qt-5.12.3/lib/QtTest.framework/Versions/5/QtTest'
CPack Verbose: 54/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/Qt-5.12.3/lib/QtWidgets.framework/Versions/5/QtWidgets'
CPack Verbose: 55/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/Qt-5.12.3/lib/QtXml.framework/Versions/5/QtXml'
CPack Verbose: 56/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libcrypto.1.0.0.dylib'
CPack Verbose: 57/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libhss1394.dylib'
CPack Verbose: 58/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/liblilv-0.0.24.2.dylib'
CPack Verbose: 59/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libmp3lame.0.dylib'
CPack Verbose: 60/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libogg.0.dylib'
CPack Verbose: 61/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libopus.0.dylib'
CPack Verbose: 62/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libopusfile.0.dylib'
CPack Verbose: 63/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libportaudio.2.dylib'
CPack Verbose: 64/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libportmidi.dylib'
CPack Verbose: 65/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libprotobuf.9.dylib'
CPack Verbose: 66/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libqt5keychain.0.9.1.dylib'
CPack Verbose: 67/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/librubberband.dylib'
CPack Verbose: 68/164: linking '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libserd-0.0.28.0.dylib' -> '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libserd-0.0.dylib'
CPack Verbose: 69/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libshout.3.dylib'
CPack Verbose: 70/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libsndfile.1.dylib'
CPack Verbose: 71/164: linking '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libsord-0.0.16.0.dylib' -> '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libsord-0.0.dylib'
CPack Verbose: 72/164: linking '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libsratom-0.0.6.0.dylib' -> '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libsratom-0.0.dylib'
CPack Verbose: 73/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libssl.1.0.0.dylib'
CPack Verbose: 74/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libtag.1.17.0.dylib'
CPack Verbose: 75/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libusb-1.0.0.dylib'
CPack Verbose: 76/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libvorbis.0.dylib'
CPack Verbose: 77/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libvorbisenc.2.dylib'
CPack Verbose: 78/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libvorbisfile.3.dylib'
CPack Verbose: 79/164: copying '/usr/local/Cellar/chromaprint/1.4.3/lib/libchromaprint.1.4.3.dylib'
CPack Verbose: 80/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libserd-0.0.28.0.dylib'
CPack Verbose: 81/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libsord-0.0.16.0.dylib'
CPack Verbose: 82/164: copying '/Users/be/2.3-j00004-497fe02e-osx10.11-x86_64-release/lib/libsratom-0.0.6.0.dylib'
CPack Verbose: fixup_bundle: fixing...
CPack Verbose: 83/164: fixing up '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/MacOS/Mixxx'
CPack Verbose: 84/164: fixing up '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libclosured.dylib'
CPack Verbose: 85/164: fixing up '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libSystem.B.dylib'
CPack Verbose: 86/164: fixing up '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libc++.1.dylib'
CPack Verbose: 87/164: fixing up '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libc++abi.dylib'
CPack Verbose: 88/164: fixing up '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libobjc.A.dylib'
CPack Verbose: 89/164: fixing up '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libz.1.dylib'
CPack Verbose: 90/164: fixing up '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libcache.dylib'
CPack Verbose: 91/164: fixing up '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libcommonCrypto.dylib'
CPack Verbose: 92/164: fixing up '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libcompiler_rt.dylib'
CPack Verbose: 93/164: fixing up '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libcopyfile.dylib'
CPack Verbose: 94/164: fixing up '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libcorecrypto.dylib'
CPack Verbose: 95/164: fixing up '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libdispatch.dylib'
CPack Verbose: 96/164: fixing up '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libdyld.dylib'
CPack Verbose: 97/164: fixing up '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libkeymgr.dylib'
CPack Verbose: 98/164: fixing up '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/liblaunch.dylib'
CPack Verbose: 99/164: fixing up '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libmacho.dylib'
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: changing install names or rpaths can't be redone for: /Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libmacho.dylib (for architecture x86_64) because larger updated load commands do not fit (the program must be relinked, and you may need to use -headerpad or -headerpad_max_install_names)
CMake Error at /nix/store/z7qvx6wbvmjvs767g06h03pkzr5aqn6i-cmake-3.18.2/share/cmake-3.18/Modules/BundleUtilities.cmake:901 (message):
  Command failed:

   '/usr/bin/install_name_tool' '-change' '/usr/lib/system/libcompiler_rt.dylib' '@executable_path/../Frameworks/libcompiler_rt.dylib' '-change' '/usr/lib/system/libdyld.dylib' '@executable_path/../Frameworks/libdyld.dylib' '-change' '/usr/lib/system/libsystem_c.dylib' '@executable_path/../Frameworks/libsystem_c.dylib' '-change' '/usr/lib/system/libsystem_kernel.dylib' '@executable_path/../Frameworks/libsystem_kernel.dylib' '-change' '/usr/lib/system/libsystem_malloc.dylib' '@executable_path/../Frameworks/libsystem_malloc.dylib' '-id' '@executable_path/../Frameworks/libmacho.dylib' '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libmacho.dylib'
Call Stack (most recent call first):
  /nix/store/z7qvx6wbvmjvs767g06h03pkzr5aqn6i-cmake-3.18.2/share/cmake-3.18/Modules/BundleUtilities.cmake:975 (fixup_bundle_item)
  /Users/be/mixxx/cmake_build/cmake_install.cmake:94 (fixup_bundle)


CPack Error: Error when generating package: mixxx
CPack Verbose: 42/164: linking '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libchromaprint.1.4.3.dylib' -> '/Users/be/mixxx/cmake_build/Mixxx.app/Contents/Frameworks/libchromaprint.1.dylib'
...
CPack Verbose: 79/164: copying '/usr/local/Cellar/chromaprint/1.4.3/lib/libchromaprint.1.4.3.dylib'

Huh? Why is it working with two different versions of libchromaprint?

It looks like gp_resolved_file_type doesn’t consider /usr/lib system libraries. Isn’t this a bug?

    if(UNIX)
      if(resolved_file MATCHES "^(/lib/|/lib32/|/libx32/|/lib64/|/var/empty/lib/|/var/empty/lib32/|/var/empty/libx32/|/var/empty/lib64/|/var/empty/X11R6/|/var/empty/bin/)")
        set(is_system 1)
      endif()
    endif()

    if(APPLE)
      if(resolved_file MATCHES "^(/System/Library/|/var/empty/lib/)")
        set(is_system 1)
      endif()
    endif()

I hacked around this with:

    install(CODE "
        include(BundleUtilities)
          #fixup_bundle tries to copy system libraries without this. Wtf?
          function(gp_resolved_file_type_override file type)
            if(file MATCHES \"^(/usr/lib)\")
              set(type \"system\" PARENT_SCOPE)
            endif()
          endfunction()
        set(BU_CHMOD_BUNDLE_ITEMS ON)
        fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${MACOS_BUNDLE_NAME}.app\" \"${QT_PLUGINS}\" \"${LIB_DIRS}\")
    ")

I got the DMG image with a .app bundle inside including the libraries and Qt plugins with this commit. Now I am unsure how code signing should be done. I got the CI script to run codesign on the DMG after CPack creates it, but that does not sign the .app bundle inside (even with codesign --deep --force).

I attempted to run codesign inside the install(CODE block after fixup_bundle and before CPack creates the DMG. However, I could not figure out how to pass a variable for the signing identity from the CI script to the install(CODE block. I tried running cpack -G -DMAC_SIGNING_IDENTITY=foobar in the CI script but

install(CODE "
  message(STATUS \"signing identity: \${MAC_SIGNING_IDENTITY} ${MAC_SIGNING_IDENTITY}\"
")

did not print the value passed to cpack.

Alternatively, I could make the CI script mount the DMG with hdiutil after CPack finishes, copy the contents out of it, run codesign on the .app bundle, then create a new DMG with hdiutil and run codesign on the DMG. I’d like to avoid such an ugly hack, but if CMake can’t do this, I’m not sure what else to do.

I don’t understand why there is zero documentation about code signing with the DragNDrop generator. There is documentation about code signing with the Bundle generator, but according to this wiki page, the Bundle generator doesn’t support fixup_bundle

I figured out another way. The -DVARIABLE=VALUE needs to be passed to the initial call to cmake to configure the project, not cpack. In CMakeLists.txt, use configure_file to set variables inside a generated CMake script file which is then passed to install(SCRIPT (instead of using install(CODE and dealing with the hassles of escaping variables). Here is the code.

shame, looking at that wiki it looks the the author of that page never got it working with the install_name_tool :frowning: