[CMake] Running OSX Bundle via open after creation with CMake/CPack
Juan Carlos Prieto
juanprietob at gmail.com
Wed Jun 1 11:36:33 EDT 2016
Dear all,
I have generated a bundle for MacOS as follows:
if(APPLE)
set(OS_BUNDLE MACOSX_BUNDLE)
elseif(WIN32)
set(OS_BUNDLE WIN32)
endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable(FADTTSter ${OS_BUNDLE}
${FADTTS_src}
)
target_link_libraries(FADTTSter ${QT_LIBRARIES} ${VTK_LIBRARIES})
#--------------------------------------------------------------------------------
# Install the QtTest application, on Apple, the bundle is at the root of
the
# install tree, and on other platforms it'll go into the bin directory.
INSTALL(TARGETS FADTTSter
DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION bin COMPONENT Runtime
)
macro(install_qt5_plugin _qt_plugin_name _qt_plugins_var)
get_target_property(_qt_plugin_path "${_qt_plugin_name}" LOCATION)
if(EXISTS "${_qt_plugin_path}")
get_filename_component(_qt_plugin_file "${_qt_plugin_path}" NAME)
get_filename_component(_qt_plugin_type "${_qt_plugin_path}" PATH)
get_filename_component(_qt_plugin_type "${_qt_plugin_type}" NAME)
set(_qt_plugin_dest
"${CMAKE_INSTALL_PREFIX}/FADTTSter.app/Contents/PlugIns/${_qt_plugin_type}")
install(FILES "${_qt_plugin_path}"
DESTINATION "${_qt_plugin_dest}"
COMPONENT Runtime)
set(${_qt_plugins_var}
"${${_qt_plugins_var}};${_qt_plugin_dest}/${_qt_plugin_file}")
else()
message(FATAL_ERROR "QT plugin ${_qt_plugin_name} not found")
endif()
endmacro()
install_qt5_plugin("Qt5::QCocoaIntegrationPlugin" QT_PLUGINS)
#--------------------------------------------------------------------------------
# install a qt.conf file
# this inserts some cmake code into the install script to write the file
INSTALL(CODE "
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\"
\"[Paths]\nPlugins = PlugIns\n\")
" COMPONENT Runtime)
install(CODE "
include(BundleUtilities)
fixup_bundle(\"${APPS}\" \"${QT_PLUGINS};\"
\"${QT_LIBRARY_DIR};${QT_BINARY_DIR};\")
"
COMPONENT Runtime)
The bundle will not run if executed through finder or in command line as
$ open FADTTSter.app.
LSOpenURLsWithRole() failed with error -10810 for the file
/path/to/FADTTSter.app
However, if the executable inside FADTTSter.app/Contents/MacOS/FADTTSter is
executed, the application works fine.
Does any body knows how to solve this issue?
Any help will be greatly appreciated.
Best regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160601/5dabb4c8/attachment.html>
More information about the CMake
mailing list