CMake on the Mac platform

318 views
Skip to first unread message

Manolo

unread,
Dec 26, 2015, 3:27:02 AM12/26/15
to fltk.coredev
FLTK applications (fluid and all test apps) created using CMake on the mac with
the present setup do not support retina displays. Thus, they appear quite ugly
on retina displays.

To fix that it is necessary and sufficient to add this
    <key>NSHighResolutionCapable</key>
    <true/>
to the Info.plist file within each app bundle. These files are built from a
template file called MacOSXBundleInfo.plist.in located within the CMake
Mac OS X application itself. This template still lacks the adequate
data described above as of today, which surprises me.
Google finds this solution for gaining retina support with CMake:

Even with CMake 2.x, you can make your own .plist.in copied from  
CMake/Modules/MacOSXBundleInfo.plist.in, then add your part in there.
     <key>NSHighResolutionCapable</key>
     <string>True</string>

Then add one more line to your set of target properties:

MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/MacOSXBundleInfo.plist.in"

(at https://cmake.org/pipermail/cmake/2014-August/058394.html)

My question is how to implement that in FLTK. I have one solution that works OK:

- copy file CMake/Modules/MacOSXBundleInfo.plist.in from the CMake bundle
to the CMake/ dir of the FLTK source code
- add the 2 necessary lines explained above
- add this in CMake/macros.cmake
      set ( MACOSX_BUNDLE_INFO_PLIST  "${CMAKE_CURRENT_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in" )
just after the if(APPLE)

Is this the correct CMake way?

Albrecht Schlosser

unread,
Dec 26, 2015, 7:49:56 AM12/26/15
to fltkc...@googlegroups.com
Yes, I think this is generally correct, if we can assume that the
statement we add ("set (MACOSX_BUNDLE_INFO_PLIST ...") and the contents
of the copied and modified file are correct even in CMake 2.6, which is
the minimal version we require, and in all later versions. Otherwise
we'd need to add some version checks, but that's likely not necessary.

Maybe we could check the CMake version later, so if we *know* that a
particular CMake version supports the Retina setup, then we can use the
CMake version of that file so we are future-proof in case this file is
changed in some way later.

I can't test your approach (lack of Mac OSX test equipment), but I
wonder if this works as expected. AFAICT the correct statement should read

set (MACOSX_BUNDLE_INFO_PLIST
"${CMAKE_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in")

unless you copied the template file into the (new) test/CMake folder
(note: CMAKE_SOURCE_DIR w/o "_CURRENT". CMAKE_SOURCE_DIR references the
root source directory, whereas CMAKE_CURRENT_SOURCE_DIR references the
_current_ source dir [1], i.e. in the case of fluid or the test
applications this would be fluid/ or test/, resp.. Note that the
proposal given in the cited link is generally correct, but in our (FLTK)
case it should be ${CMAKE_SOURCE_DIR}/CMake.

The macro in CMake/macros.cmake would only be used for all test
applications. As you know, fluid has its own CMake file, which should be
changed in a similar and obvious way. If we can use the same template
file, then I suggest to add the MacOSXBundleInfo.plist.in in our CMake
folder as you wrote above. This should work for both cases.


[1] https://cmake.org/Wiki/CMake_Useful_Variables

Manolo Gouy

unread,
Dec 26, 2015, 11:38:29 AM12/26/15
to <fltkcoredev@googlegroups.com>
I have committed (r10980) the addition of a new file CMake/MacOSXBundleInfo.plist.in
containing a template used to create Info.plist files of CMake-created Mac OS app bundles.
No other changes are necessary.

The CMake doc of MACOSX_BUNDLE_INFO_PLIST
(https://cmake.org/cmake/help/v3.0/prop_tgt/MACOSX_BUNDLE_INFO_PLIST.html)
states that the template file is searched for in dir CMAKE_MODULE_PATH.

File CMake/setup.cmake of the FLTK source contains

# Search for modules in the FLTK source dir first
set(CMAKE_MODULE_PATH "${FLTK_SOURCE_DIR}/CMake")

thus, I believe this commit is the correct way to support retina displays with FLTK+CMAKE.



Reply all
Reply to author
Forward
0 new messages