[CMake] Create Mac OS Bundle with VTK and Qt

Oleksii Vilchanskyi alexvilchansky at yahoo.com
Fri Sep 8 15:42:31 EDT 2017


Hello,

> 1) I try to add an icon without success
> When I launch my app, the default icon is used and not my icon.

Can you elaborate on this? You say that the .icns file is under
Resources and the final Info.plist contains the proper key with the
proper value and that a non-default icon is used when the application is
launched. If you do actually see the icon on the application [for
example] in Launchpad, then the bundle is correctly built and macOS can
recognize the icon. If instead you see something like this[0], then the
bundle is built incorrectly.

However, you also say "when I launch my app", which, if you mean
application's runtime in particular, is unrelated to CMake or bundling.
If the tray icon is broken etc. it's something your application is not
doing (for example, we use RCC and /image for the icon).

So, if this is the former, then the bundling part is incorrect, if it's
the latter, the program's behaviour is incorrect.

As a side note, I don't rely on MACOSX_PACKAGE_LOCATION property and
install() the icon where it belongs.

> 2) For the libraries of VTK I tried to use macdeployqt (found using
find_program) but it doesn’t found the libraries (installed in a custom
directories)
> Is there a simple way to copy all found libraries/framework?

I would recommend using DeployQt5.cmake module[1] instead of
macdeployqt. Initially found on this list and later edited by Marcus D.
Hanwell, the module (I believe) is distributed under BSD 3-clause.

Usage example[2], also under BSD 3-clause (I believe).

[0]: <https://doc.qt.io/archives/qq/qq09-demo-icon.png>
[1]:
<https://github.com/OpenChemistry/avogadroapp/blob/master/cmake/DeployQt5.cmake>
[2]:
<https://github.com/OpenChemistry/avogadroapp/blob/master/avogadro/lastinstall/CMakeLists.txt>

Regards,
Oleksii Vilchanskyi

On 8.9.2017 18:11, Romain LEGUAY wrote:
> Hello everyone,
> 
> Since this morning, I try to create a Bundle Application using CMake (3.9.1).
> 
> My application use VTK (8.x) and Qt (5.x). The find_package of those two libraries works greats (no problem to build and run the application).
> 
> I have many problems:
> 
> 1) I try to add an icon without success.
> 2) I don’t know how (and where) to copy VTK dynamic libraries.
> ( Optional / not really related ) 3) When I try to use only some components of VTK, my application is linking to all VTK modules
> 
> I’m going to details each points:
> 
> 1) For the icon issue, I proceed this way:
> 
>  
> set(ICON_NAME "appIcon.icns") # I try without the icns extension without success.
> set(ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/resources/icons/${ICON_NAME}")
> set_source_files_properties("${ICON_PATH}" PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
> 
> add_executable(MYAPP MACOSX_BUNDLE ${ICON_PATH} ${other_sources})
> 
> set_target_properties(CRAFPACK_GUI PROPERTIES
> 		                    MACOSX_BUNDLE_ICON_FILE ${ICON_NAME})
> 
> 
> The icon is copied inside the Resources folder of my bundle and the Info.plist is well updated (the CFBundleIconFile key is set to "appIcon.icns").
> 
> When I launch my app, the default icon is used and not my icon.
> 
> 
> 2) For the libraries of VTK I tried to use macdeployqt (found using find_program) but it doesn’t found the libraries (installed in a custom directories)
> 
> I tried to use BundleUtilities without any success (except to tell me that cmake doesn’t found the libraries).
> 
> I attach you my CMakeLists.
> 
> Is there a simple way to copy all found libraries/framework?
> 
> Thank you!
> 
> 
> 


More information about the CMake mailing list