Skip to content
Permalink
Browse files
Add bundling of osg/osgEarth for OS X app
  • Loading branch information
kyngchaos committed Apr 7, 2012
1 parent 48be08b commit 4ecd56886cd08ab96cebd8bf9a6a3edd1c55b822
Showing with 92 additions and 0 deletions.
  1. +3 −0 CMakeLists.txt
  2. +2 −0 mac/CMakeLists.txt
  3. +79 −0 mac/cmake/1osg.cmake.in
  4. +8 −0 src/plugins/globe/globe_plugin.cpp
@@ -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
@@ -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)
@@ -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@)
@@ -38,6 +38,7 @@

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

#include <osgGA/StateSetManipulator>
#include <osgGA/GUIEventHandler>
@@ -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() );
}

0 comments on commit 4ecd568

Please sign in to comment.