bug #348: fixed OS X deployment

just enable CMake option "OPENMW_OSX_DEPLOYMENT" and it will search
plugins inside application bundle instead of Ogre prefix
actorid
Nikolay Kasyanov 13 years ago
parent 94ce95c679
commit fbe9a94568

@ -37,6 +37,9 @@ option(USE_FFMPEG "use ffmpeg for sound" OFF)
option(USE_AUDIERE "use audiere for sound" OFF)
option(USE_MPG123 "use mpg123 + libsndfile for sound" ON)
# OS X deployment
option(OPENMW_OSX_DEPLOYMENT OFF)
find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems")
# Location of morrowind data files
@ -241,12 +244,8 @@ if (APPLE)
else ()
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG})
endif ()
set(OGRE_PLUGIN_DIR "${OGRE_PLUGIN_DIR}/")
# set(OGRE_PLUGIN_DIR_2 ${OGRE_PLUGIN_DIR})
# set(OGRE_PLUGIN_DIR "")
# set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_2})
#set(OGRE_PLUGIN_DIR "${OGRE_PLUGIN_DIR}/")
configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist
"${APP_BUNDLE_DIR}/Contents/Info.plist")
@ -270,7 +269,11 @@ if (DEFINED CMAKE_BUILD_TYPE)
endif()
add_definitions(-DOGRE_PLUGIN_DIR_REL="${OGRE_PLUGIN_DIR_REL}")
add_definitions(-DOGRE_PLUGIN_DIR_DBG="${OGRE_PLUGIN_DIR_DBG}")
add_definitions(-DOGRE_PLUGIN_DIR="${OGRE_PLUGIN_DIR}")
if (APPLE AND OPENMW_OSX_DEPLOYMENT)
add_definitions(-DOGRE_PLUGIN_DIR="${APP_BUNDLE_NAME}/Contents/Plugins")
else()
add_definitions(-DOGRE_PLUGIN_DIR="${OGRE_PLUGIN_DIR}")
endif()
add_subdirectory(files/)

@ -7,6 +7,7 @@
#include <components/files/configurationmanager.hpp>
#include <components/settings/settings.hpp>
#include <components/ogreplugin/ogreplugin.h>
#include "graphicspage.hpp"
#include "naturalsort.hpp"
@ -115,17 +116,13 @@ bool GraphicsPage::setupOgre()
#endif
}
std::string glPlugin = std::string(pluginDir) + "/RenderSystem_GL" + OGRE_PLUGIN_DEBUG_SUFFIX;
if (boost::filesystem::exists(glPlugin + ".so") ||
boost::filesystem::exists(glPlugin + ".dll") ||
boost::filesystem::exists(glPlugin + ".dylib"))
mOgre->loadPlugin (glPlugin);
std::string dxPlugin = std::string(pluginDir) + "/RenderSystem_Direct3D9" + OGRE_PLUGIN_DEBUG_SUFFIX;
if (boost::filesystem::exists(dxPlugin + ".so") ||
boost::filesystem::exists(dxPlugin + ".dll") ||
boost::filesystem::exists(dxPlugin + ".dylib"))
mOgre->loadPlugin (dxPlugin);
boost::filesystem::path absPluginPath = boost::filesystem::absolute(boost::filesystem::path(pluginDir));
pluginDir = absPluginPath.string();
loadOgrePlugin(pluginDir, "RenderSystem_GL", *mOgre);
loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mOgre);
loadOgrePlugin(pluginDir, "RenderSystem_GL", *mOgre);
#ifdef ENABLE_PLUGIN_GL
mGLPlugin = new Ogre::GLPlugin();

@ -66,6 +66,10 @@ add_component_dir (interpreter
miscopcodes opcodes runtime scriptopcodes spatialopcodes types
)
add_component_dir (ogreplugin
ogreplugin
)
include_directories(${BULLET_INCLUDE_DIRS})
add_library(components STATIC ${COMPONENT_FILES})

@ -0,0 +1,37 @@
#include "ogreplugin.h"
#include <OgrePrerequisites.h>
#include <OgreRoot.h>
#include <boost/filesystem.hpp>
bool loadOgrePlugin(std::string pluginDir, std::string pluginName, Ogre::Root &ogreRoot) {
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
std::ostringstream verStream;
verStream << "." << OGRE_VERSION_MAJOR << "." << OGRE_VERSION_MINOR << "." << OGRE_VERSION_PATCH;
pluginName = pluginName + OGRE_PLUGIN_DEBUG_SUFFIX + verStream.str();
#endif
std::string pluginExt;
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
pluginExt = ".dll";
#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
pluginExt = ".dylib";
#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
pluginExt = ".so";
#endif
std::string pluginPath = pluginDir + "/" + pluginName + pluginExt;
std::cout << "loading plugin: " << pluginPath << std::endl;
if (boost::filesystem::exists(pluginPath)) {
ogreRoot.loadPlugin(pluginPath);
return true;
}
else {
return false;
}
}

@ -0,0 +1,12 @@
#ifndef OGREPLUGIN_H
#define OGREPLUGIN_H
#include <string>
namespace Ogre {
class Root;
}
extern bool loadOgrePlugin(std::string pluginDir, std::string pluginName, Ogre::Root &ogreRoot);
#endif

@ -11,6 +11,8 @@
#include <boost/filesystem.hpp>
#include <components/ogreplugin/ogreplugin.h>
#include <cassert>
#include <cstdlib>
#include <stdexcept>
@ -94,6 +96,7 @@ void OgreRenderer::configure(const std::string &logPath,
loadPlugins();
#endif
std::cout << "current path is: " << boost::filesystem::current_path() << std::endl;
std::string pluginDir;
const char* pluginEnv = getenv("OPENMW_OGRE_PLUGIN_DIR");
if (pluginEnv)
@ -111,23 +114,13 @@ void OgreRenderer::configure(const std::string &logPath,
#endif
}
std::string glPlugin = std::string(pluginDir) + "/RenderSystem_GL" + OGRE_PLUGIN_DEBUG_SUFFIX;
if (boost::filesystem::exists(glPlugin + ".so") ||
boost::filesystem::exists(glPlugin + ".dll") ||
boost::filesystem::exists(glPlugin + ".dylib"))
mRoot->loadPlugin (glPlugin);
std::string dxPlugin = std::string(pluginDir) + "/RenderSystem_Direct3D9" + OGRE_PLUGIN_DEBUG_SUFFIX;
if (boost::filesystem::exists(dxPlugin + ".so") ||
boost::filesystem::exists(dxPlugin + ".dll") ||
boost::filesystem::exists(dxPlugin + ".dylib"))
mRoot->loadPlugin (dxPlugin);
std::string cgPlugin = std::string(pluginDir) + "/Plugin_CgProgramManager" + OGRE_PLUGIN_DEBUG_SUFFIX;
if (boost::filesystem::exists(cgPlugin + ".so") ||
boost::filesystem::exists(cgPlugin + ".dll") ||
boost::filesystem::exists(cgPlugin + ".dylib"))
mRoot->loadPlugin (cgPlugin);
boost::filesystem::path absPluginPath = boost::filesystem::absolute(boost::filesystem::path(pluginDir));
pluginDir = absPluginPath.string();
loadOgrePlugin(pluginDir, "RenderSystem_GL", *mRoot);
loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mRoot);
loadOgrePlugin(pluginDir, "Plugin_CgProgramManager", *mRoot);
RenderSystem* rs = mRoot->getRenderSystemByName(renderSystem);
if (rs == 0)

Loading…
Cancel
Save