Enabling OS X Retina Support with CMake

January 3, 2015


Getting CMake set up to build a QT app on OSX was easy enough. The tough part came when I realized the compiled app was not retina ready. I found the fix to this was adding the property to the Info.plst file for the bundle. But first, I had to get my custom plist recognized by CMake. This way the plist would be the same for a makefile or Xcode generated project.

I first tried to add the plist like this (NOTE: Info.plist.in is just a copy of the default CMake plist generator which can be found in the modules directory of your CMake installation).

set(MACOSX_BUNDLE_INFO_FILE Resources/Info.plist.in)
There are two problems with this line. The first is easy to fix, this command takes the path from the current directory, not the directory of CMakeLists.txt. The second is more important, MACOSX_BUNDLE_INFO_FILE is NOT a setting, but a property. The fix is to add the property to the target in CMakeLists.txt.
if (APPLE)
    set_target_properties(flowing_goo PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Info.plist.in)
endif ()
Lastly, the high Resolution key has to be added to the plist to make the app retina ready. Now regenerate with cmake and the app should build ready for retina displays!

comments powered by Disqus
  • Copyright 2013, Matthew Iannucci
  • Site created with web.py, version 0.3
  • Updated January 2015