[CMake] cmake and high-dpi support on Mac

René J.V. Bertin rjvbertin at gmail.com
Wed Mar 13 11:51:42 EDT 2019


Hi,

CMake had hardcoded default support for high-dpi screens in the applications it generated for Apple's desktop OS at some point, but that was removed very quickly in 286c75f7f034c5fdcd43bcb755da74d09c809642.

It is my understanding that you don't actually need to set the high-dpi key explicitly, but that it defaults to on for the desktop OS. IOW, it's enough to set the NSPrincipalClass property to NSApplication.

I cannot check this myself, and I have no idea if and how NSPrincipalClass can be set for Apple's other OS variants.
But maybe one could use this property in a minimal-change change to enable high-dpi support automatically in applications that do not provide their own Info.plist: add this to the bundle plist template:

+	<key>NSPrincipalClass</key>
+	<${MACOSX_BUNDLE_PRINCIPALCLASS}/>

If the target OS is known when the MACOSX_BUNDLE_* variables get their default, MACOSX_BUNDLE_PRINCIPALCLASS could default to whatever class is appropriate for the target OS, otherwise it would just be set to NSApplication (and users targetting other OS variants would have to set the property explicitly, which is still less cumbersome than providing a custom template).

Thoughts please?
Thanks,
R.




More information about the CMake mailing list