Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add bundling of osg/osgEarth for OS X app
  • Loading branch information
kyngchaos committed Apr 7, 2012
1 parent 48be08b commit 4ecd568
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Expand Up @@ -367,6 +367,9 @@ ELSE (WIN32)
SET (DEFAULT_INCLUDE_SUBDIR include/qgis)
# path for framework references
SET (CMAKE_INSTALL_NAME_DIR @executable_path/${QGIS_FW_SUBDIR})
IF (WITH_GLOBE)
SET (OSG_PLUGINS_PATH "" CACHE PATH "Path to OSG plugins for bundling")
ENDIF (WITH_GLOBE)

ELSE (APPLE)
# UNIX
Expand Down
2 changes: 2 additions & 0 deletions mac/CMakeLists.txt
Expand Up @@ -10,6 +10,8 @@ IF (APPLE)
# start with Qt
CONFIGURE_FILE (cmake/1qt.cmake.in 1qt.cmake @ONLY)
INSTALL (SCRIPT ${CMAKE_BINARY_DIR}/mac/1qt.cmake)
CONFIGURE_FILE (cmake/1osg.cmake.in 1osg.cmake @ONLY)
INSTALL (SCRIPT ${CMAKE_BINARY_DIR}/mac/1osg.cmake)
IF (QGIS_MACAPP_BUNDLE GREATER 1)
# next - libs
CONFIGURE_FILE (cmake/2lib.cmake.in 2lib.cmake @ONLY)
Expand Down
79 changes: 79 additions & 0 deletions mac/cmake/1osg.cmake.in
@@ -0,0 +1,79 @@
# 1osg - bundle OSG & osgEarth frameworks
# ! cmakecache vars not available to external scripts
# so we configure it first to do substitutions
# make sure to use @varname@

# kill boolean warnings
CMAKE_POLICY (SET CMP0012 NEW)

IF (@OSGEARTH_FOUND@)

INCLUDE (@CMAKE_BINARY_DIR@/mac/0vars.cmake)
INCLUDE (@CMAKE_SOURCE_DIR@/cmake/MacBundleMacros.cmake)

SET (OSG_PLUGINS_PATH "@OSG_PLUGINS_PATH@")

# list of osg frameworks to bundle

SET (OSGLIST OpenThreads osg osgDB osgGA osgViewer osgEarth osgEarthAnnotation osgEarthFeatures osgEarthSymbology osgEarthUtil osgFX osgManipulator osgShadow osgSim osgTerrain osgText osgUtil osgWidget)
#SET (PYOSGLIST future python bindings?)
MYMESSAGE ("OSG list: ${OSGLIST}")

# extract OSG framework path from OSGEARTH_LIBRARY, assume all in same prefix

STRING (REPLACE "/osgEarth.framework" "" OSG_FW_DIR "@OSGEARTH_LIBRARY@")

### copy OSG

MESSAGE (STATUS "Copying OSG and osgEarth...")

# osg frameworks
FOREACH (OFW ${OSGLIST})
IF (NOT IS_DIRECTORY "${QFWDIR}/${OFW}.framework")
COPY_FRAMEWORK("${OSG_FW_DIR}" ${OFW} "${QFWDIR}")
ENDIF ()
ENDFOREACH (OFW)

# osg plugins

IF (OSG_PLUGINS_PATH)
FILE (GLOB OSGPLUGLIST RELATIVE ${OSG_PLUGINS_PATH} ${OSG_PLUGINS_PATH}/*.so)
EXECUTE_PROCESS (COMMAND mkdir -p "${QPLUGDIR}/../osgPlugins")
FOREACH (OP ${OSGPLUGLIST})
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "${OSG_PLUGINS_PATH}/${OP}" "${QPLUGDIR}/../osgPlugins/${OP}")
ENDFOREACH (OP)
ENDIF ()

# update lib paths

MESSAGE (STATUS "Updating OSG library paths...")

FOREACH (OFW ${OSGLIST})
# get install names from installed in case bundled copy already changed
# from a previous install attempt
GET_INSTALL_NAME ("${OSG_FW_DIR}/${OFW}.framework/${OFW}" ${OFW}.framework OO)
SET (OFW_CHG "${OO}")
SET (OFW_CHG_TO "${ATEXECUTABLE}/@QGIS_FW_SUBDIR@/${OFW}.framework/${OFW}")
# qgis app
INSTALLNAMETOOL_CHANGE ("${OFW_CHG}" "${OFW_CHG_TO}" "${QAPPDIR}/${QGIS_APP_NAME}")

SET (LIBPOST "${OFW}.framework/${OFW}")
# osg frameworks
IF (@OSX_HAVE_LOADERPATH@)
SET (OFW_CHG_TO "${ATLOADER}/../../../${LIBPOST}")
ENDIF ()
FOREACH (OF ${OSGLIST})
INSTALLNAMETOOL_CHANGE ("${OFW_CHG}" "${OFW_CHG_TO}" "${QFWDIR}/${OF}.framework/${OF}")
ENDFOREACH (OF)
# osg plugins
IF (@OSX_HAVE_LOADERPATH@)
SET (OFW_CHG_TO "${ATLOADER}/@QGIS_PLUGIN_SUBDIR_REV@/@QGIS_FW_SUBDIR@/${LIBPOST}")
ENDIF ()
FOREACH (OP ${OSGPLUGLIST})
INSTALLNAMETOOL_CHANGE ("${OFW_CHG}" "${OFW_CHG_TO}" "${QPLUGDIR}/../osgPlugins/${OP}")
ENDFOREACH (OP)
# globe plugin
INSTALLNAMETOOL_CHANGE ("${OFW_CHG}" "${OFW_CHG_TO}" "${QPLUGDIR}/libglobeplugin.so")
ENDFOREACH (OFW)

ENDIF (@OSGEARTH_FOUND@)
8 changes: 8 additions & 0 deletions src/plugins/globe/globe_plugin.cpp
Expand Up @@ -38,6 +38,7 @@

#include <osgGA/TrackballManipulator>
#include <osgDB/ReadFile>
#include <osgDB/Registry>

#include <osgGA/StateSetManipulator>
#include <osgGA/GUIEventHandler>
Expand Down Expand Up @@ -86,6 +87,13 @@ GlobePlugin::GlobePlugin( QgisInterface* theQgisInterface )
setObjectName( "globePlugin" );
setParent( theQgisInterface->mainWindow() );

// add internal osg plugin path if bundled osg on OS X
#ifdef QGIS_MACAPP_BUNDLE
#if QGIS_MACAPP_BUNDLE > 0
setLibraryFilePathList( QgsApplication::prefixPath() + "/QGIS_PLUGIN_SUBDIR/../osgPlugins" );
#endif
#endif

mSettingsDialog = new QgsGlobePluginDialog( &viewer, theQgisInterface->mainWindow(), QgisGui::ModalDialogFlags );
mQDockWidget = new QDockWidgetGlobe( tr( "Globe" ), theQgisInterface->mainWindow() );
}
Expand Down

0 comments on commit 4ecd568

Please sign in to comment.