Feature #162 - Need to create app bundle using CMake, not by hand WIP

actorid
Nikolay Kasyanov 13 years ago
parent 705b2955a0
commit 472d88e2c5

@ -381,69 +381,77 @@ if (WIN32)
endif() endif()
# Apple bundling # Apple bundling
# TODO REWRITE!
if (APPLE) if (APPLE)
set(MISC_FILES set(MISC_FILES
${APP_BUNDLE_DIR}/Contents/MacOS/openmw.cfg ${APP_BUNDLE_DIR}/Contents/MacOS/openmw.cfg
${APP_BUNDLE_DIR}/Contents/MacOS/plugins.cfg) ${APP_BUNDLE_DIR}/Contents/MacOS/plugins.cfg)
set(OGRE_PLUGINS #install(FILES ${MISC_FILES} DESTINATION ../MacOS)
${APP_BUNDLE_DIR}/Contents/Plugins/*) #install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Plugins" DESTINATION ..)
#install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Resources/resources" DESTINATION ../Resources)
#install(FILES ${MISC_FILES} DESTINATION ../MacOS) install(DIRECTORY "${APP_BUNDLE_DIR}" USE_SOURCE_PERMISSIONS DESTINATION . COMPONENT Runtime)
#install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Plugins" DESTINATION ..) set(CPACK_GENERATOR "DragNDrop")
#install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Resources/resources" DESTINATION ../Resources) # set(CPACK_BUNDLE_PLIST "${CMAKE_SOURCE_DIR}/files/mac/Info.plist")
install(DIRECTORY "${APP_BUNDLE_DIR}" DESTINATION . COMPONENT Runtime) # set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/files/mac/openmw.icns")
set(CPACK_GENERATOR "DragNDrop") # set(CPACK_BUNDLE_NAME "OpenMW")
# set(CPACK_BUNDLE_PLIST "${CMAKE_SOURCE_DIR}/files/mac/Info.plist") set(CPACK_PACKAGE_VERSION ${OPENMW_VERSION})
# set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/files/mac/openmw.icns") set(CPACK_PACKAGE_VERSION_MAJOR ${OPENMW_VERSION_MAJOR})
# set(CPACK_BUNDLE_NAME "OpenMW") set(CPACK_PACKAGE_VERSION_MINOR ${OPENMW_VERSION_MINO})
set(CPACK_PACKAGE_VERSION ${OPENMW_VERSION}) set(CPACK_PACKAGE_VERSION_PATCH ${OPENMW_VERSION_RELEASE})
set(CPACK_PACKAGE_VERSION_MAJOR ${OPENMW_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${OPENMW_VERSION_MINO}) set(APPS "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_NAME}")
set(CPACK_PACKAGE_VERSION_PATCH ${OPENMW_VERSION_RELEASE}) set(PLUGINS "")
set(APPS "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_NAME}") # Scan Plugins dir for *.dylibs
set(PLUGINS "") file(GLOB ALL_PLUGINS "${APP_BUNDLE_DIR}/Contents/Plugins/*.dylib")
foreach(plugin ${USED_OGRE_PLUGINS}) foreach(PLUGIN ${ALL_PLUGINS})
set(PLUGINS ${PLUGINS} "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_NAME}/Contents/Plugins/${plugin}.dylib") get_filename_component(PLUGIN_FILENAME ${PLUGIN} NAME)
endforeach() set(PLUGINS ${PLUGINS} "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_NAME}/Contents/Plugins/${PLUGIN_FILENAME}")
endforeach()
set(DIRS "")
#For now, search unresolved dependencies only in default system paths, so if you put unresolveable (i.e. with @executable_path in id name) lib or framework somewhere else, it would fail
INSTALL(CODE " set(DIRS "")
set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) # Overriding item resolving during installation, it needed if
set(CMAKE_SYSTEM_FRAMEWORK_PATH ${CMAKE_SYSTEM_FRAMEWORK_PATH}) # some library already has be "fixed up", i.e. its id name contains @executable_path,
# but library is not embedded in bundle. For example, it's Ogre.framework from Ogre SDK.
set(OPENMW_RESOLVED_ITEMS \"\") # Current implementation of GetPrerequsities/BundleUtilities doesn't handle that case.
#
function(gp_resolve_item_override context item exepath dirs resolved_item_var resolved_var) # Current limitations:
if(item MATCHES \"@executable_path\" AND NOT \${\${resolved_var}}) # 1. Handles only frameworks, not simple libs
if (item MATCHES \"Frameworks\") # if it is a framework INSTALL(CODE "
# get last segment of path set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES})
get_filename_component(fname \"\${item}\" NAME_WE) set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
find_library(ri NAMES \${fname} PATHS \${exepath} \${dirs} /Library/Frameworks) set(CMAKE_SYSTEM_FRAMEWORK_PATH ${CMAKE_SYSTEM_FRAMEWORK_PATH})
if (ri)
message(STATUS \"found \${ri} for \${item}\") set(OPENMW_RESOLVED_ITEMS \"\")
string(REGEX REPLACE \"^.*/Frameworks/.*\\\\.framework\" \"\" item_part \${item})
set(ri \"\${ri}\${item_part}\") function(gp_resolve_item_override context item exepath dirs resolved_item_var resolved_var)
set(\${resolved_item_var} \${ri} PARENT_SCOPE) if(item MATCHES \"@executable_path\" AND NOT \${\${resolved_var}})
set(\${resolved_var} 1 PARENT_SCOPE) if (item MATCHES \"Frameworks\") # if it is a framework
set(OPENMW_RESOLVED_ITEMS \${_OPENMW_RESOLVED_ITEMS} \${ri}) # get last segment of path
get_filename_component(fname \"\${item}\" NAME_WE)
find_library(ri NAMES \${fname} PATHS \${exepath} \${dirs} /Library/Frameworks)
if (ri)
message(STATUS \"found \${ri} for \${item}\")
string(REGEX REPLACE \"^.*/Frameworks/.*\\\\.framework\" \"\" item_part \${item})
set(ri \"\${ri}\${item_part}\")
set(\${resolved_item_var} \${ri} PARENT_SCOPE)
set(\${resolved_var} 1 PARENT_SCOPE)
set(OPENMW_RESOLVED_ITEMS \${_OPENMW_RESOLVED_ITEMS} \${ri})
endif()
else()
# code path for standard (non-framework) libs (ogre & qt pugins)
endif() endif()
else()
# code path for standard (non-framework) libs (ogre & qt pugins)
endif() endif()
endif() endfunction(gp_resolve_item_override)
endfunction(gp_resolve_item_override)
cmake_policy(SET CMP0009 OLD)
cmake_policy(SET CMP0009 OLD) set(BU_CHMOD_BUNDLE_ITEMS ON)
set(BU_CHMOD_BUNDLE_ITEMS ON) include(BundleUtilities)
include(BundleUtilities) fixup_bundle(\"${APPS}\" \"${PLUGINS}\" \"${DIRS}\")
fixup_bundle(\"${APPS}\" \"${PLUGINS}\" \"${DIRS}\") " COMPONENT Runtime)
" COMPONENT Runtime)
include(CPack) include(CPack)

@ -49,6 +49,17 @@ QT4_WRAP_CPP(MOC_SRCS ${LAUNCHER_HEADER_MOC})
include(${QT_USE_FILE}) include(${QT_USE_FILE})
# list here plugins that can't be detected statically, but loaded in runtime
# it needed for packaging automatisation
#set(USED_QT_PLUGINS imageformats/libqgif
# imageformats/libqico
# imageformats/libqjpeg
# imageformats/libqmng
# imageformats/libqsvg
# imageformats/libqtga
# imageformats/libqtiff)
# It seems that launcher works without this plugins, but it loads them into memory if they exists
# Main executable # Main executable
add_executable(omwlauncher add_executable(omwlauncher
${LAUNCHER} ${LAUNCHER}
@ -73,6 +84,13 @@ if (APPLE)
"${APP_BUNDLE_DIR}/../launcher.qss") "${APP_BUNDLE_DIR}/../launcher.qss")
configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss
"${APP_BUNDLE_DIR}/../launcher.cfg") "${APP_BUNDLE_DIR}/../launcher.cfg")
# copy used QT plugins into ${APP_BUNDLE_DIR}/Contents/Plugins
#foreach(PLUGIN ${USED_QT_PLUGINS})
# get_filename_component(PLUGIN_FILENAME ${PLUGIN} NAME)
# configure_file("${QT_PLUGINS_DIR}/${PLUGIN}.dylib" "${APP_BUNDLE_DIR}/Contents/Plugins/${PLUGIN_FILENAME}.dylib" COPYONLY)
#endforeach()
else() else()
configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.qss") "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.qss")

Loading…
Cancel
Save