Create Mac OS Bundle with VTK and Qt

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Create Mac OS Bundle with VTK and Qt

Romain LEGUAY
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!


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

CMakeLists.txt (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Create Mac OS Bundle with VTK and Qt

CMake mailing list
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!
>
>
>
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Create Mac OS Bundle with VTK and Qt

Romain LEGUAY
Hello,

Sorry for this late answer!

After using DeployQt5.cmake script I succeed to resolve my problem. 

The icon problem was due to some mistake during the creation of my icns file.

Thanks again.

Romain

Le 8 sept. 2017 à 21:42, Oleksii Vilchanskyi via CMake <[hidden email]> a écrit :

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!



-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake