Qt 5, macOS, bundle install

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

Qt 5, macOS, bundle install

Romain LEGUAY
Hello everyone,

I try to install a bundle application on macOS.

I successfully create the bundle and add all dependencies to Qt event the plugin platform libqcocoa.dylib.

Unfortunately, when I launch the installed app, the window style is not the same as the build app style (macOS) as you can see on the joined screenshots.

The CMakeLists.txt script is (too?) simple:

cmake_minimum_required(VERSION 3.2 FATAL_ERROR)

project(testProj)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/ui)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)

get_target_property(QtCore_location Qt5::Core LOCATION)
get_target_property(QtWidgets_location Qt5::Widgets LOCATION)

include_directories(${QtCore_location} ${QtWidgets_location})

add_executable(${PROJECT_NAME} MACOSX_BUNDLE main.cpp MainWindow.cpp MainWindow.hpp MainWindow.ui)
set_target_properties(${PROJECT_NAME} PROPERTIES
        CXX_STANDARD 14
        CXX_STANDARD_REQUIRED YES
        CXX_EXTENSIONS NO)

install(TARGETS ${PROJECT_NAME} DESTINATION ".")

target_link_libraries(${PROJECT_NAME} Qt5::Widgets)

set_target_properties(${PROJECT_NAME}
PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME "${PROJECT_NAME}"
)

include(InstallRequiredSystemLibraries)
include(DeployQt5)

get_target_property(build_dir ${PROJECT_NAME} BINARY_DIR)
get_target_property(target_name ${PROJECT_NAME} NAME)
get_target_property(isbundle ${PROJECT_NAME} MACOSX_BUNDLE)

get_filename_component(qt_dlls_dir "${QtWidgets_location}" PATH)
get_filename_component(qt_dlls_dir "${qt_dlls_dir}" PATH)
set(dirs "${qt_dlls_dir}")

if(WIN32)
    set(suffix ".exe")
endif()

if (${isbundle})
    set(exe ${target_name}.app)
else()
    set(exe ${target_name}${suffix})
endif()

install_qt5_executable(${exe} "" "" "${dirs}" "" "")

I don't understand why the plugin libqcocoa.dylib is not used for the installed app.

I try to read the CMake script available (such as Paraview or Slicer3D), but it's a little too much time consuming. 

Is there some simple example available?

Thank you,

Romain


--

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:
https://cmake.org/mailman/listinfo/cmake

SimpleProject.zip (8K) Download Attachment
installed_app.png (10K) Download Attachment
build_app.png (10K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Qt 5, macOS, bundle install

Romain LEGUAY
I found the solution!!

I just add the plugins attached to the Qt Component (in my case Qt5Widgets) and install it:

set(qtplugins)
foreach(plugin ${Qt5Widgets_PLUGINS})
    get_target_property(_loc ${plugin} LOCATION)
    list(APPEND qtplugins ${_loc})
endforeach()

install_qt5_executable("${exe}" "${qtplugins}" "" "${dirs}" "")

I found a part of the solution in the Qt documentation (http://doc.qt.io/qt-5/cmake-manual.html#imported-targets).

How can I add this simple example inside the CMake example/tutorial?

Romain

--

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:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Qt 5, macOS, bundle install

Jean-Christophe Fillion-Robin-2
Hi Romain,

> How can I add this simple example inside the CMake example/tutorial?

I suggest to add them to the cmake community wiki.

Jc

On Tue, Oct 9, 2018 at 11:27 AM Romain LEGUAY <[hidden email]> wrote:
I found the solution!!

I just add the plugins attached to the Qt Component (in my case Qt5Widgets) and install it:

set(qtplugins)
foreach(plugin ${Qt5Widgets_PLUGINS})
    get_target_property(_loc ${plugin} LOCATION)
    list(APPEND qtplugins ${_loc})
endforeach()

install_qt5_executable("${exe}" "${qtplugins}" "" "${dirs}" "")

I found a part of the solution in the Qt documentation (http://doc.qt.io/qt-5/cmake-manual.html#imported-targets).

How can I add this simple example inside the CMake example/tutorial?

Romain
--

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:
https://cmake.org/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:
https://cmake.org/mailman/listinfo/cmake