[CMake] fixup bundle vs Qy 5.5.1 and rpaths
Gregory Van Vooren
gregoryvv at packz.com
Fri Dec 18 08:12:37 EST 2015
I have a project containing several applications (which are sub projects), each of which links against some Qt libraries which are built as dylibs, but are not part of the project. Qt libraries and headers are found using find-package which is working perfectly.
I’m currently trying to switch from Qt 5.3.1 to Qt 5.5.1, but am experiencing problems with fixup_bundle on OS X (everything else seems to work fine).
As far as I’ve gathered Qt has introduced support for rpaths between those two version and this seems to be the cause of my problems.
Building a single application works and said application starts up correctly, but building the install target will give me the following output:
-- fixup_bundle: preparing...
--
warning: cannot resolve item 'libQt5Core_debug.5.dylib'
possible problems:
need more directories?
need to use InstallRequiredSystemLibraries?
run in install tree instead of build tree?
-- warning: gp_resolved_file_type non-absolute file 'libQt5Core_debug.5.dylib' returning type 'other' -- possibly incorrect
--
warning: cannot resolve item 'libQt5Core_debug.5.dylib'
possible problems:
need more directories?
need to use InstallRequiredSystemLibraries?
run in install tree instead of build tree?
warning: target 'libQt5Core_debug.5.dylib' is not absolute...
warning: target 'libQt5Core_debug.5.dylib' does not exist...
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.4/Modules/GetPrerequisites.cmake:800 (message):
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool
failed: 1
error:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
can't open file: libQt5Core_debug.5.dylib (No such file or directory)
Call Stack (most recent call first):
/Applications/CMake.app/Contents/share/cmake-3.4/Modules/GetPrerequisites.cmake:925 (get_prerequisites)
/Applications/CMake.app/Contents/share/cmake-3.4/Modules/BundleUtilities.cmake:555 (get_prerequisites)
/Applications/CMake.app/Contents/share/cmake-3.4/Modules/BundleUtilities.cmake:804 (get_bundle_keys)
someApplication/someApplication/cmake_install.cmake:115 (fixup_bundle)
I’ll try to provide sufficient yet minimal information to pinpoint the root cause of the problem.
In my top CMakeLists.txt I have the following:
set (
QT_REQUIRED_PACKAGES
Core
Gui
Widgets
)
set( QT_ROOT_PATH "/usr/local/Qt-5.5.1" )
set( QT_REQUIRED_PACKAGES ${QT_REQUIRED_PACKAGES} MacExtras )
set(
QT_PLUGINS_DIR
"${QT_ROOT_PATH}/plugins"
)
set ( CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "${QT_ROOT_PATH}/bin/" )
FOREACH(QT_PACKAGE ${QT_REQUIRED_PACKAGES})
set( QT_PACKAGE_WITH_PREFIX "Qt5${QT_PACKAGE}" )
set( "${QT_PACKAGE_WITH_PREFIX}_DIR" "${QT_ROOT_PATH}/lib/cmake/${QT_PACKAGE_WITH_PREFIX}" )
find_package( "${QT_PACKAGE_WITH_PREFIX}" REQUIRED )
include_directories( ${${QT_PACKAGE_WITH_PREFIX}_INCLUDE_DIRS} )
set_target_properties( "Qt5::${QT_PACKAGE}" PROPERTIES MAP_IMPORTED_CONFIG_DEBUG "DEBUG")
set_target_properties( "Qt5::${QT_PACKAGE}" PROPERTIES MAP_IMPORTED_CONFIG_RELEASE "RELEASE")
set_target_properties( "Qt5::${QT_PACKAGE}" PROPERTIES MAP_IMPORTED_CONFIG_RELWITHDEBINFO "RELEASE")
ENDFOREACH(QT_PACKAGE)
add_definitions( ${QT_DEFINITIONS} )
set( CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR} )
set( CMAKE_MACOSX_RPATH “" )
set_property( GLOBAL PROPERTY USE_FOLDERS ON )
add_subdirectory( someApplication )
in the someApplication CMakeLists.txt I have the following:
set(
someApplication_Qt_LIBRARIES
${Qt5Core_LIBRARIES}
${Qt5Widgets_LIBRARIES}
)
set_target_properties( someApplication PROPERTIES INSTALL_RPATH "${QT_ROOT_PATH}/lib" )
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
install( TARGETS someApplication DESTINATION bin/${OUTPUTCONFIG} CONFIGURATIONS ${OUTPUTCONFIG} )
endforeach()
add_custom_command( TARGET someApplication POST_BUILD COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX}/LocalizationTools/someApplication/Debug/plugins/platforms/ )
add_custom_command( TARGET someApplication POST_BUILD COMMAND cp -Rf "${QT_PLUGINS_DIR}/platforms/libqcocoa_debug.dylib" ${CMAKE_INSTALL_PREFIX}/LocalizationTools/someApplication/Debug/plugins/platforms/ )
add_custom_command( TARGET someApplication POST_BUILD COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX}/LocalizationTools/someApplication/Release/plugins/platforms/ )
add_custom_command( TARGET someApplication POST_BUILD COMMAND cp -Rf "${QT_PLUGINS_DIR}/platforms/libqcocoa.dylib" ${CMAKE_INSTALL_PREFIX}/LocalizationTools/someApplication/Release/plugins/platforms/ )
add_custom_command( TARGET someApplication POST_BUILD COMMAND mkdir -p `dirname $<TARGET_FILE: someApplication >`/../plugins )
add_custom_command( TARGET someApplication POST_BUILD COMMAND cp -Rf ${CMAKE_INSTALL_PREFIX}/LocalizationTools/someApplication/$<$<CONFIG:Debug>:Debug>$<$<NOT:$<CONFIG:Debug>>:Release>/plugins/ `dirname $<TARGET_FILE: someApplication >`/../plugins/ )
add_custom_command( TARGET someApplication POST_BUILD COMMAND chmod -R +w `dirname $<TARGET_FILE: someApplication >` )
set( APP "${CMAKE_INSTALL_PREFIX}/bin/\${CMAKE_INSTALL_CONFIG_NAME}/someApplication.app" )
set( DIRS
${APP}/Contents/plugins/platforms
)
install( CODE "
file( WRITE \"${APP}/Contents/Resources/qt.conf\" \"[Paths]\\nPlugins = plugins\\n\" )
" COMPONENT Runtime
)
foreach( DYNAMIC_LIBRARY ${someApplication_DYNAMIC_LIBRARIES} )
add_custom_command( TARGET someApplication POST_BUILD COMMAND cp -Rf $<TARGET_FILE:${DYNAMIC_LIBRARY}> `dirname $<TARGET_FILE: someApplication >` )
endforeach()
install( CODE "
file( GLOB_RECURSE QT_PLATFORM_PLUGINS \"${APP}/Contents/plugins/platforms/*${CMAKE_SHARED_LIBRARY_SUFFIX}\" )
include( BundleUtilities )
fixup_bundle( \"${APP}\" \"\${QT_PLATFORM_PLUGINS}\" \"${DIRS}\" )
" COMPONENT Runtime
)
Any help is greatly appreciated.
Kind regards,
Greg.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151218/70611dbd/attachment-0001.html>
More information about the CMake
mailing list