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!
cmake_minimum_required(VERSION 3.1)
project (GUI CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
find_package(VTK COMPONENTS vtkGUISupportQt NO_MODULE)
find_package(Qt5 COMPONENTS Core Widgets Network WebSockets REQUIRED)
if(${ENABLE_MPI})
find_package(MPI REQUIRED)
endif(${ENABLE_MPI})
include(${VTK_USE_FILE})
get_target_property(QtCore_location Qt5::Core LOCATION)
get_target_property(QtWidgets_location Qt5::Widgets LOCATION)
get_target_property(QtNetwork_location Qt5::Network LOCATION)
get_target_property(QtWebSockets_location Qt5::WebSockets LOCATION)
get_target_property(QT5_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
get_filename_component(QT5_WINDEPLOYQT_PATH ${QT5_QMAKE_EXECUTABLE} PATH)
set(QT5_WINDEPLOYQT_EXECUTABLE "${QT5_WINDEPLOYQT_PATH}/windeployqt.exe")
set(QT5_MACDEPLOYQT_EXECUTABLE "${QT5_WINDEPLOYQT_PATH}/macdeployqt")
include_directories("${COMMON_INCLUDE_DIR}"
services/include
include
resources
${QtCore_location}
${QtWidgets_location}
${QtNetwork_location}
${QtWebSockets_location})
include_directories(${VKT_INCLUDE_DIR} ${MPI_INCLUDE_PATH})
file(GLOB_RECURSE headers
include/*.hpp
include/*.tpp)
file(GLOB_RECURSE sources
src/*.cpp)
file(GLOB_RECURSE services_headers
services/include/*.h*
services/include/*.tpp)
file(GLOB_RECURSE services_sources
services/src/*.c*)
file(GLOB_RECURSE ui_files
resources/ui/*.ui)
file(GLOB_RECURSE qrc_files
resources/*.qrc)
if (APPLE)
set(ICON_NAME "appIcon")
set(ICON_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/resources/icons/${ICON_NAME}.icns")
endif()
qt5_wrap_ui(ui_sources "${ui_files}")
qt5_add_resources(qrc_resources "${qrc_files}")
if (APPLE)
set_source_files_properties("${ICON_PATH}" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources)
set_source_files_properties("${VTK_LIBRARIES}" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources/vtk)
endif()
add_executable(GUI MACOSX_BUNDLE ${headers} ${sources} ${services_headers}
${services_sources}
${ui_sources} ${qrc_resources} ${ICON_PATH})
set_target_properties(GUI PROPERTIES
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
MACOSX_BUNDLE_ICON_FILE ${ICON_NAME}
MACOSX_BUNDLE_GUI_IDENTIFIER "crafpack.TISSU"
MACOSX_BUNDLE_BUNDLE_NAME "TISSU"
BUILD_WITH_INSTALL_RPATH 1)
target_link_libraries(GUI
Qt5::Widgets Qt5::Network Qt5::WebSockets
${VTK_LIBRARIES} ${MPI_LIBRARIES})
if(${ENABLE_MPI})
target_compile_definitions(GUI PRIVATE "-DENABLE_MPI")
endif()
add_custom_command(TARGET GUI
POST_BUILD
COMMAND ${QT5_MACDEPLOYQT_EXECUTABLE} ARGS ${CMAKE_CURRENT_BINARY_DIR}/GUI.app
)
--
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