Merge branch 'osx_fix'

actorid
Marc Zinnschlag 13 years ago
commit f6d657a5f4

@ -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
@ -230,13 +233,34 @@ if (APPLE)
${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL} ${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL}
${OGRE_Plugin_CgProgramManager_LIBRARY_REL} ${OGRE_Plugin_CgProgramManager_LIBRARY_REL}
${OGRE_Plugin_ParticleFX_LIBRARY_REL}) ${OGRE_Plugin_ParticleFX_LIBRARY_REL})
if (${OGRE_PLUGIN_DIR_REL}})
set(OGRE_PLUGINS_REL_FOUND TRUE)
endif ()
if (${OGRE_PLUGIN_DIR_DBG})
set(OGRE_PLUGINS_DBG_FOUND TRUE)
endif ()
if (${OGRE_PLUGINS_REL_FOUND})
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL})
else ()
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG})
endif ()
#set(OGRE_PLUGIN_DIR "${OGRE_PLUGIN_DIR}/")
configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist
"${APP_BUNDLE_DIR}/Contents/Info.plist")
configure_file(${OpenMW_SOURCE_DIR}/files/mac/openmw.icns
"${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY)
endif (APPLE) endif (APPLE)
# Set up Ogre plugin folder & debug suffix # Set up Ogre plugin folder & debug suffix
set(DEBUG_SUFFIX "") # Ogre on OS X doesn't use "_d" suffix (see Ogre's CMakeLists.txt)
if (DEFINED CMAKE_BUILD_TYPE AND CMAKE_BUILD_TYPE STREQUAL "Debug") if (DEFINED CMAKE_BUILD_TYPE AND CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT APPLE)
set(DEBUG_SUFFIX "_d")
add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="_d") add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="_d")
else() else()
add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="") add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="")
@ -244,7 +268,11 @@ 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/)
@ -277,35 +305,6 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
"${OpenMW_BINARY_DIR}/openmw.desktop") "${OpenMW_BINARY_DIR}/openmw.desktop")
endif() endif()
if (APPLE)
if (${OGRE_PLUGIN_DIR_REL}})
set(OGRE_PLUGINS_REL_FOUND TRUE)
endif ()
if (${OGRE_PLUGIN_DIR_DBG})
set(OGRE_PLUGINS_DBG_FOUND TRUE)
endif ()
if (${OGRE_PLUGINS_REL_FOUND})
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL})
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})
configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist
"${APP_BUNDLE_DIR}/Contents/Info.plist")
configure_file(${OpenMW_SOURCE_DIR}/files/mac/openmw.icns
"${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY)
endif (APPLE)
# Compiler settings # Compiler settings
if (CMAKE_COMPILER_IS_GNUCC) if (CMAKE_COMPILER_IS_GNUCC)
add_definitions (-Wall -Wextra -Wno-unused-parameter -Wno-reorder) add_definitions (-Wall -Wextra -Wno-unused-parameter -Wno-reorder)

@ -6,6 +6,7 @@
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <components/files/configurationmanager.hpp> #include <components/files/configurationmanager.hpp>
#include <components/files/ogreplugin.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include "graphicspage.hpp" #include "graphicspage.hpp"
@ -115,13 +116,12 @@ 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"))
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"))
mOgre->loadPlugin (dxPlugin); Files::loadOgrePlugin(pluginDir, "RenderSystem_GL", *mOgre);
Files::loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mOgre);
#ifdef ENABLE_PLUGIN_GL #ifdef ENABLE_PLUGIN_GL
mGLPlugin = new Ogre::GLPlugin(); mGLPlugin = new Ogre::GLPlugin();

@ -52,7 +52,7 @@ add_component_dir (misc
add_component_dir (files add_component_dir (files
linuxpath windowspath macospath fixedpath multidircollection collections fileops configurationmanager linuxpath windowspath macospath fixedpath multidircollection collections fileops configurationmanager
filelibrary filelibrary ogreplugin
) )
add_component_dir (compiler add_component_dir (compiler

@ -0,0 +1,37 @@
#include "ogreplugin.hpp"
#include <OgrePrerequisites.h>
#include <OgreRoot.h>
namespace Files {
bool loadOgrePlugin(const std::string &pluginDir, std::string pluginName, Ogre::Root &ogreRoot) {
pluginName = pluginName + OGRE_PLUGIN_DEBUG_SUFFIX;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
std::ostringstream verStream;
verStream << "." << OGRE_VERSION_MAJOR << "." << OGRE_VERSION_MINOR << "." << OGRE_VERSION_PATCH;
pluginName = pluginName + 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;
if (boost::filesystem::exists(pluginPath)) {
ogreRoot.loadPlugin(pluginPath);
return true;
}
else {
return false;
}
}
}

@ -0,0 +1,64 @@
/**
* Open Morrowind - an opensource Elder Scrolls III: Morrowind
* engine implementation.
*
* Copyright (C) 2011 Open Morrowind Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file components/files/ogreplugin.hpp */
#ifndef COMPONENTS_FILES_OGREPLUGIN_H
#define COMPONENTS_FILES_OGREPLUGIN_H
#include <string>
#include <boost/filesystem.hpp>
#include <boost/version.hpp>
namespace Ogre {
class Root;
}
#if (BOOST_VERSION <= 104300)
namespace boost {
namespace filesystem {
inline path absolute(const path& p, const path& base=current_path()) {
// call obsolete version of this function on older boost
return complete(p, base);
}
}
}
#endif /* (BOOST_VERSION <= 104300) */
/**
* \namespace Files
*/
namespace Files {
/**
* \brief Loads Ogre plugin with given name.
*
* \param pluginDir absolute path to plugins
* \param pluginName plugin name, for example "RenderSystem_GL"
* \param ogreRoot Ogre::Root instance
*
* \return whether plugin was located or not
*/
bool loadOgrePlugin(const std::string &pluginDir, std::string pluginName, Ogre::Root &ogreRoot);
}
#endif /* COMPONENTS_FILES_OGREPLUGIN_H */

@ -11,6 +11,8 @@
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <components/files/ogreplugin.hpp>
#include <cassert> #include <cassert>
#include <cstdlib> #include <cstdlib>
#include <stdexcept> #include <stdexcept>
@ -111,17 +113,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"))
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"))
mRoot->loadPlugin (dxPlugin);
std::string cgPlugin = std::string(pluginDir) + "/Plugin_CgProgramManager" + OGRE_PLUGIN_DEBUG_SUFFIX; Files::loadOgrePlugin(pluginDir, "RenderSystem_GL", *mRoot);
if (boost::filesystem::exists(cgPlugin + ".so") || boost::filesystem::exists(cgPlugin + ".dll")) Files::loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mRoot);
mRoot->loadPlugin (cgPlugin); Files::loadOgrePlugin(pluginDir, "Plugin_CgProgramManager", *mRoot);
RenderSystem* rs = mRoot->getRenderSystemByName(renderSystem); RenderSystem* rs = mRoot->getRenderSystemByName(renderSystem);
if (rs == 0) if (rs == 0)

Loading…
Cancel
Save