Feature #162 - Need to create app bundle using CMake, not by hand. Almost complete

actorid
Nikolay Kasyanov 13 years ago
parent 5a42c6c6f5
commit 57a4b19880

@ -384,9 +384,6 @@ endif()
if (APPLE)
set(INSTALL_SUBDIR OpenMW)
#install(FILES ${MISC_FILES} DESTINATION ../MacOS)
#install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Plugins" DESTINATION ..)
#install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Resources/resources" DESTINATION ../Resources)
install(DIRECTORY "${APP_BUNDLE_DIR}" USE_SOURCE_PERMISSIONS DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" RENAME "openmw.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
@ -394,9 +391,6 @@ if (APPLE)
install(FILES "${OpenMW_BINARY_DIR}/plugins.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(FILES "${OpenMW_BINARY_DIR}/launcher.qss" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
set(CPACK_GENERATOR "DragNDrop")
# set(CPACK_BUNDLE_PLIST "${CMAKE_SOURCE_DIR}/files/mac/Info.plist")
# set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/files/mac/openmw.icns")
# set(CPACK_BUNDLE_NAME "OpenMW")
set(CPACK_PACKAGE_VERSION ${OPENMW_VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR ${OPENMW_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${OPENMW_VERSION_MINO})
@ -406,11 +400,13 @@ if (APPLE)
set(PLUGINS "")
# Scan Plugins dir for *.dylibs
file(GLOB ALL_PLUGINS "${APP_BUNDLE_DIR}/Contents/Plugins/*.dylib")
set(PLUGIN_SEARCH_ROOT "${APP_BUNDLE_DIR}/Contents/Plugins")
file(GLOB_RECURSE ALL_PLUGINS "${PLUGIN_SEARCH_ROOT}/*.dylib")
set(PLUGIN_INSTALL_BASE "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}/Contents/Plugins")
foreach(PLUGIN ${ALL_PLUGINS})
get_filename_component(PLUGIN_FILENAME ${PLUGIN} NAME)
set(PLUGINS ${PLUGINS} "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}/Contents/Plugins/${PLUGIN_FILENAME}")
string(REPLACE "${PLUGIN_SEARCH_ROOT}/" "" PLUGIN_RELATIVE "${PLUGIN}")
set(PLUGINS ${PLUGINS} "${PLUGIN_INSTALL_BASE}/${PLUGIN_RELATIVE}")
endforeach()
#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

@ -41,8 +41,10 @@ source_group(launcher FILES ${LAUNCHER} ${LAUNCHER_HEADER} ${LAUNCHER_HEADER_MOC
find_package(Qt4 REQUIRED)
set(QT_USE_QTGUI 1)
#find_package(PNG REQUIRED)
#include_directories(${PNG_INCLUDE_DIR})
if (NOT APPLE) # this dependency can be completely removed, but now it only tested on OS X
find_package(PNG REQUIRED)
include_directories(${PNG_INCLUDE_DIR})
endif()
QT4_ADD_RESOURCES(RCC_SRCS resources.qrc)
QT4_WRAP_CPP(MOC_SRCS ${LAUNCHER_HEADER_MOC})
@ -51,14 +53,14 @@ 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
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 if they exists
# Main executable
add_executable(omwlauncher
@ -71,7 +73,7 @@ target_link_libraries(omwlauncher
${Boost_LIBRARIES}
${OGRE_LIBRARIES}
${QT_LIBRARIES}
# ${PNG_LIBRARY}
${PNG_LIBRARY}
components
)
@ -86,10 +88,10 @@ if (APPLE)
"${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()
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}.dylib" COPYONLY)
endforeach()
else()
configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss

@ -1,6 +1,7 @@
#include <QApplication>
#include <QDir>
#include <QFile>
#include <QtDebug>
#include "maindialog.hpp"
@ -17,6 +18,14 @@ int main(int argc, char *argv[])
dir.cdUp();
dir.cdUp();
}
QDir pluginsPath(QCoreApplication::applicationDirPath());
pluginsPath.cdUp();
pluginsPath.cd("Plugins");
QStringList libraryPaths;
libraryPaths << pluginsPath.path() << QCoreApplication::applicationDirPath();
app.setLibraryPaths(libraryPaths);
#endif
QDir::setCurrent(dir.absolutePath());

Loading…
Cancel
Save