Page MenuHomePhabricator

Mac icons not copied and Info.plist has wrong value for icon location
Closed, ResolvedPublic

Description

Hi there,

a quick question. In FunctionCreateBlueBerryApplication.cmake there is:

  1. -----------------------------------------------------------------------
  2. Add executable icon (Mac)
  3. -----------------------------------------------------------------------

if(APPLE)

if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/icons/icon.icns")
  set_target_properties(${_APP_NAME} PROPERTIES MACOSX_BUNDLE_ICON_FILE "${CMAKE_CURRENT_SOURCE_DIR}/icons/icon.icns")
  file(COPY ${MACOSX_BUNDLE_ICON_FILE} DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_APP_NAME}.app/Contents/Resources/")
  file(INSTALL ${MACOSX_BUNDLE_ICON_FILE} DESTINATION "${_APP_NAME}.app/Contents/Resources/")
endif()

endif()

However, the COPY command and INSTALL command is passing in the name of a target property as the name of the file. As far as I can tell, these are empty, and hence the icon is not copied.
Also, in my Info.plist file within the final bundle, produced as a result of the packaging process, the location of the icon file is given as the location of the file within the build tree, which is wrong when copied to another machine.

Should it be something like this:

  1. -----------------------------------------------------------------------
  2. Add executable icon (Mac)
  3. -----------------------------------------------------------------------

if(APPLE)

set(icon_name "icon.icns")
set(icon_location ${CMAKE_CURRENT_SOURCE_DIR}/icons/${icon_name})
if(EXISTS "${icon_location}")
  set_target_properties(${_APP_NAME} PROPERTIES MACOSX_BUNDLE_ICON_FILE ${icon_name})
  set_target_properties(${_APP_NAME} PROPERTIES MACOSX_BUNDLE_ICON_FILE ${icon_location})
  file(COPY ${icon_location} DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_APP_NAME}.app/Contents/Resources/")
  file(INSTALL ${icon_location} DESTINATION "${_APP_NAME}.app/Contents/Resources/")
endif()

endif()

Also, for T13517, this was done for mitkWorkbench:

#Setting application icon for mac os x systems
set_target_properties(mitkWorkbench PROPERTIES MACOSX_BUNDLE_ICON_FILE "icon.icns")

if(APPLE)
         install(FILES "icons/icon.icns" DESTINATION "mitkWorkbench.app/Contents/Resources")
endif(APPLE)

which seems to agree with the above proposal.

Please can someone check this, as I am unfamiliar with this stuff.

Thanks

Matt

Event Timeline

Just to double-check I have understood the problem:

You are building an installer on MacOSX.
On the machine it is build one the icon is used.

If said installer is copied and installed to another machine, not featuring a MITK build (or at least not in the same path) the icon is not used.

Is this correct?

For this issue, when I run "make package", the resultant bundle is wrong.

Firstly, the icon is not copied.
Secondly, the generated Info.plist has the wrong path.

The supplied patches seem to fix both these issues.

Matt

New remote branch pushed: bug-15092-fix-mac-icon-system

[a92fe6]: Merge branch 'bug-15092-fix-mac-icon-system'

Merged commits:

2013-05-09 18:18:49 Matt Clarkson [cf2d2c]
Added missing DESTINATION to file copy

Signed-off-by: Caspar Goch <c.goch@dkfz-heidelberg.de>


2013-05-09 17:10:01 Matt Clarkson [3134b9]
Set MACOSX_BUNDLE_ICON_FILE to icon.icns and fix copying of file

Signed-off-by: Caspar Goch <c.goch@dkfz-heidelberg.de>