[CMake] Qt 5, macOS, bundle install

Romain LEGUAY romain.leguay at gmail.com
Tue Oct 9 07:31:18 EDT 2018


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20181009/7ee780f0/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SimpleProject.zip
Type: application/zip
Size: 6419 bytes
Desc: not available
URL: <https://cmake.org/pipermail/cmake/attachments/20181009/7ee780f0/attachment-0001.zip>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: installed_app.png
Type: image/png
Size: 8007 bytes
Desc: not available
URL: <https://cmake.org/pipermail/cmake/attachments/20181009/7ee780f0/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: build_app.png
Type: image/png
Size: 7934 bytes
Desc: not available
URL: <https://cmake.org/pipermail/cmake/attachments/20181009/7ee780f0/attachment-0003.png>


More information about the CMake mailing list