forked from mirror/openmw-tes3mp
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
This commit is contained in:
parent
94ce95c679
commit
fbe9a94568
6 changed files with 78 additions and 32 deletions
|
@ -37,6 +37,9 @@ option(USE_FFMPEG "use ffmpeg for sound" OFF)
|
||||||
option(USE_AUDIERE "use audiere for sound" OFF)
|
option(USE_AUDIERE "use audiere for sound" OFF)
|
||||||
option(USE_MPG123 "use mpg123 + libsndfile for sound" ON)
|
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")
|
find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems")
|
||||||
|
|
||||||
# Location of morrowind data files
|
# Location of morrowind data files
|
||||||
|
@ -241,12 +244,8 @@ if (APPLE)
|
||||||
else ()
|
else ()
|
||||||
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG})
|
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set(OGRE_PLUGIN_DIR "${OGRE_PLUGIN_DIR}/")
|
#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})
|
|
||||||
|
|
||||||
configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist
|
configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist
|
||||||
"${APP_BUNDLE_DIR}/Contents/Info.plist")
|
"${APP_BUNDLE_DIR}/Contents/Info.plist")
|
||||||
|
@ -270,7 +269,11 @@ if (DEFINED CMAKE_BUILD_TYPE)
|
||||||
endif()
|
endif()
|
||||||
add_definitions(-DOGRE_PLUGIN_DIR_REL="${OGRE_PLUGIN_DIR_REL}")
|
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_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/)
|
add_subdirectory(files/)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/settings.hpp>
|
||||||
|
#include <components/ogreplugin/ogreplugin.h>
|
||||||
|
|
||||||
#include "graphicspage.hpp"
|
#include "graphicspage.hpp"
|
||||||
#include "naturalsort.hpp"
|
#include "naturalsort.hpp"
|
||||||
|
@ -115,17 +116,13 @@ bool GraphicsPage::setupOgre()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string glPlugin = std::string(pluginDir) + "/RenderSystem_GL" + OGRE_PLUGIN_DEBUG_SUFFIX;
|
boost::filesystem::path absPluginPath = boost::filesystem::absolute(boost::filesystem::path(pluginDir));
|
||||||
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;
|
pluginDir = absPluginPath.string();
|
||||||
if (boost::filesystem::exists(dxPlugin + ".so") ||
|
|
||||||
boost::filesystem::exists(dxPlugin + ".dll") ||
|
loadOgrePlugin(pluginDir, "RenderSystem_GL", *mOgre);
|
||||||
boost::filesystem::exists(dxPlugin + ".dylib"))
|
loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mOgre);
|
||||||
mOgre->loadPlugin (dxPlugin);
|
loadOgrePlugin(pluginDir, "RenderSystem_GL", *mOgre);
|
||||||
|
|
||||||
#ifdef ENABLE_PLUGIN_GL
|
#ifdef ENABLE_PLUGIN_GL
|
||||||
mGLPlugin = new Ogre::GLPlugin();
|
mGLPlugin = new Ogre::GLPlugin();
|
||||||
|
|
|
@ -66,6 +66,10 @@ add_component_dir (interpreter
|
||||||
miscopcodes opcodes runtime scriptopcodes spatialopcodes types
|
miscopcodes opcodes runtime scriptopcodes spatialopcodes types
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_component_dir (ogreplugin
|
||||||
|
ogreplugin
|
||||||
|
)
|
||||||
|
|
||||||
include_directories(${BULLET_INCLUDE_DIRS})
|
include_directories(${BULLET_INCLUDE_DIRS})
|
||||||
|
|
||||||
add_library(components STATIC ${COMPONENT_FILES})
|
add_library(components STATIC ${COMPONENT_FILES})
|
||||||
|
|
37
components/ogreplugin/ogreplugin.cpp
Normal file
37
components/ogreplugin/ogreplugin.cpp
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
12
components/ogreplugin/ogreplugin.h
Normal file
12
components/ogreplugin/ogreplugin.h
Normal file
|
@ -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 <boost/filesystem.hpp>
|
||||||
|
|
||||||
|
#include <components/ogreplugin/ogreplugin.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
@ -94,6 +96,7 @@ void OgreRenderer::configure(const std::string &logPath,
|
||||||
loadPlugins();
|
loadPlugins();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::cout << "current path is: " << boost::filesystem::current_path() << std::endl;
|
||||||
std::string pluginDir;
|
std::string pluginDir;
|
||||||
const char* pluginEnv = getenv("OPENMW_OGRE_PLUGIN_DIR");
|
const char* pluginEnv = getenv("OPENMW_OGRE_PLUGIN_DIR");
|
||||||
if (pluginEnv)
|
if (pluginEnv)
|
||||||
|
@ -111,23 +114,13 @@ void OgreRenderer::configure(const std::string &logPath,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string glPlugin = std::string(pluginDir) + "/RenderSystem_GL" + OGRE_PLUGIN_DEBUG_SUFFIX;
|
boost::filesystem::path absPluginPath = boost::filesystem::absolute(boost::filesystem::path(pluginDir));
|
||||||
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;
|
pluginDir = absPluginPath.string();
|
||||||
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;
|
loadOgrePlugin(pluginDir, "RenderSystem_GL", *mRoot);
|
||||||
if (boost::filesystem::exists(cgPlugin + ".so") ||
|
loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mRoot);
|
||||||
boost::filesystem::exists(cgPlugin + ".dll") ||
|
loadOgrePlugin(pluginDir, "Plugin_CgProgramManager", *mRoot);
|
||||||
boost::filesystem::exists(cgPlugin + ".dylib"))
|
|
||||||
mRoot->loadPlugin (cgPlugin);
|
|
||||||
|
|
||||||
RenderSystem* rs = mRoot->getRenderSystemByName(renderSystem);
|
RenderSystem* rs = mRoot->getRenderSystemByName(renderSystem);
|
||||||
if (rs == 0)
|
if (rs == 0)
|
||||||
|
|
Loading…
Reference in a new issue