title: How to create a MacOS app bundle with cmake
body: <p>This can be considered as a follow-up to <a href="https://stackoverflow.com/questions/35612687/cmake-macos-x-bundle-with-bundleutiliies-for-qt-application">CMake MacOS X bundle with BundleUtiliies for Qt application</a></p>
  
  <p>I want to create a MACOS bundle on CI which can be used by users for an open source project.</p>
  
  <p>What I have:</p>
  
  <ul>
  <li>Main executable</li>
  <li>Updater executable</li>
  <li>icon file</li>
  <li>helper script calling updater then main</li>
  <li>data files in a folder (translations etc, some generated at build time)</li>
  <li>plugin shared libs</li>
  </ul>
  
  <p>What I've done so far:</p>
  
  <ul>
  <li>add <code>MACOSX_BUNDLE</code> to the executable</li>
  <li>add icon to its sources and to <code>RESOURCE</code> property</li>
  <li>set <code>MACOSX_BUNDLE_*</code> properties </li>
  <li>install everything in a cross-platform way (regular <code>install(TARGETS</code> calls and <code>install(FILES</code> for the resources)</li>
  </ul>
  
  <p>But now I'm stuck on how to get those into the bundle w/o to much manual work.</p>
  
  <p>From the linked question I got something like this:</p>
  
  <pre><code>set(APPS "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app")
  set(LIBS )
  set(DIRS "${CMAKE_BINARY_DIR}")
  # Path used for searching by FIND_XXX(), with appropriate suffixes added
  if(CMAKE_PREFIX_PATH)
          foreach(dir ${CMAKE_PREFIX_PATH})
                  list(APPEND DIRS "${dir}/bin" "${dir}/lib")
          endforeach()
  endif()
  install(CODE "include(BundleUtilities)
    fixup_bundle(\"${APPS}\" \"${LIBS}\" \"${DIRS}\")")
  </code></pre>
  
  <p>But:</p>
  
  <ul>
  <li>Why do I need to pass the <code>*.app</code> path manually? CMake does already know it, doesn't it?</li>
  <li><code>LIBS</code> should contain my plugins, shouldn't it? But what? Paths? Target names?</li>
  <li><code>DIRS</code> is also a mystery to me. No documentation even in CMake 3.12 (I'm still using 2.8.12 though :( )</li>
  <li>How to add my generated and regular data files? Probably same or similar to the icon? But what about the generated ones?</li>
  </ul>
  
  <p>Help, pointers to examples, full CMakeLists doing that etc. very welcome.</p>
  
  <p>Note: I'm cross-compiling from linux on the CI and NOT using Qt so e.g. <code>macdeployqt</code> or so is out of question.</p>