Index: KDE4Macros.cmake
===================================================================
--- KDE4Macros.cmake	(revision 750957)
+++ KDE4Macros.cmake	(working copy)
@@ -979,3 +979,51 @@
     endif(WIN32)
 endmacro (KDE4_ADD_WIN32_APP_ICON)
 
+# this macro adds the application icon to a Mac OS X bundle so that Finder and friends
+# show the right thing.
+#
+# _targetName is the name of the target application (note - the bundle must be _targetName.app/)
+# _appicon is the full path to the app icon (128x128 preferred)
+# _appsources is the list of sources passed to kde4_add_executable
+#
+# example usage (before kde4_add_executable or kde4_add_kdeinit_executable):
+# kde4_add_macosx_app_icon(konsole ${CMAKE_CURRENT_SOURCE_DIR}/../data/hi128-app-konsole.png konsole_KDEINIT_SRCS)
+# kde4_add_kdeinit_executable(konsole ${konsole_KDEINIT_SRCS})
+macro (KDE4_ADD_MACOSX_APP_ICON _targetName _appicon _appsources)
+
+    if (Q_WS_MAC)
+
+        # first, get the basename of our app icon
+        get_filename_component(_basename ${_appicon} NAME_WE)
+
+        # first convert image to a tiff using the Mac OS X "sips" utility,
+        # then use tiff2icns to convert to an icon
+        find_program(SIPS_EXECUTABLE NAMES sips)
+        find_program(TIFF2ICNS_EXECUTABLE NAMES tiff2icns)
+        if (SIPS_EXECUTABLE AND TIFF2ICNS_EXECUTABLE)
+
+            add_custom_command(OUTPUT ${_basename}.icns
+                               COMMAND sips -s format tiff ${_appicon} --out _tmp_appicon.tiff
+                               COMMAND tiff2icns _tmp_appicon.tiff ${_basename}.icns
+                               DEPENDS ${_appicon}
+                               )
+
+            macro_additional_clean_files(_tmp_appicon.tiff ${_basename}.icns)
+
+            # This will register the icon into the bundle
+            set(MACOSX_BUNDLE_ICON_FILE ${_basename}.icns)
+
+            # Append the icns file to the sources list so it will be a dependency to the
+            # main target
+            list(APPEND ${_appsources} ${_basename}.icns)
+
+#            this doesn't seem to work for me - Use manual "install" instead
+#            SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/${_basename}.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
+
+            install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.icns DESTINATION ${BIN_INSTALL_DIR}/${_targetName}.app/Contents/Resources/)
+
+        else(SIPS_EXECUTABLE AND TIFF2ICNS_EXECUTABLE)
+            message(STATUS "Unable to find the sips and tiff2icns utilities - application will not have an application icon!")
+        endif(SIPS_EXECUTABLE AND TIFF2ICNS_EXECUTABLE)
+    endif(Q_WS_MAC)
+endmacro (KDE4_ADD_MACOSX_APP_ICON)
