Skip to content

Commit 4ecd568

Browse files
committed
Add bundling of osg/osgEarth for OS X app
1 parent 48be08b commit 4ecd568

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ ELSE (WIN32)
367367
SET (DEFAULT_INCLUDE_SUBDIR include/qgis)
368368
# path for framework references
369369
SET (CMAKE_INSTALL_NAME_DIR @executable_path/${QGIS_FW_SUBDIR})
370+
IF (WITH_GLOBE)
371+
SET (OSG_PLUGINS_PATH "" CACHE PATH "Path to OSG plugins for bundling")
372+
ENDIF (WITH_GLOBE)
370373

371374
ELSE (APPLE)
372375
# UNIX

mac/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ IF (APPLE)
1010
# start with Qt
1111
CONFIGURE_FILE (cmake/1qt.cmake.in 1qt.cmake @ONLY)
1212
INSTALL (SCRIPT ${CMAKE_BINARY_DIR}/mac/1qt.cmake)
13+
CONFIGURE_FILE (cmake/1osg.cmake.in 1osg.cmake @ONLY)
14+
INSTALL (SCRIPT ${CMAKE_BINARY_DIR}/mac/1osg.cmake)
1315
IF (QGIS_MACAPP_BUNDLE GREATER 1)
1416
# next - libs
1517
CONFIGURE_FILE (cmake/2lib.cmake.in 2lib.cmake @ONLY)

mac/cmake/1osg.cmake.in

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# 1osg - bundle OSG & osgEarth frameworks
2+
# ! cmakecache vars not available to external scripts
3+
# so we configure it first to do substitutions
4+
# make sure to use @varname@
5+
6+
# kill boolean warnings
7+
CMAKE_POLICY (SET CMP0012 NEW)
8+
9+
IF (@OSGEARTH_FOUND@)
10+
11+
INCLUDE (@CMAKE_BINARY_DIR@/mac/0vars.cmake)
12+
INCLUDE (@CMAKE_SOURCE_DIR@/cmake/MacBundleMacros.cmake)
13+
14+
SET (OSG_PLUGINS_PATH "@OSG_PLUGINS_PATH@")
15+
16+
# list of osg frameworks to bundle
17+
18+
SET (OSGLIST OpenThreads osg osgDB osgGA osgViewer osgEarth osgEarthAnnotation osgEarthFeatures osgEarthSymbology osgEarthUtil osgFX osgManipulator osgShadow osgSim osgTerrain osgText osgUtil osgWidget)
19+
#SET (PYOSGLIST future python bindings?)
20+
MYMESSAGE ("OSG list: ${OSGLIST}")
21+
22+
# extract OSG framework path from OSGEARTH_LIBRARY, assume all in same prefix
23+
24+
STRING (REPLACE "/osgEarth.framework" "" OSG_FW_DIR "@OSGEARTH_LIBRARY@")
25+
26+
### copy OSG
27+
28+
MESSAGE (STATUS "Copying OSG and osgEarth...")
29+
30+
# osg frameworks
31+
FOREACH (OFW ${OSGLIST})
32+
IF (NOT IS_DIRECTORY "${QFWDIR}/${OFW}.framework")
33+
COPY_FRAMEWORK("${OSG_FW_DIR}" ${OFW} "${QFWDIR}")
34+
ENDIF ()
35+
ENDFOREACH (OFW)
36+
37+
# osg plugins
38+
39+
IF (OSG_PLUGINS_PATH)
40+
FILE (GLOB OSGPLUGLIST RELATIVE ${OSG_PLUGINS_PATH} ${OSG_PLUGINS_PATH}/*.so)
41+
EXECUTE_PROCESS (COMMAND mkdir -p "${QPLUGDIR}/../osgPlugins")
42+
FOREACH (OP ${OSGPLUGLIST})
43+
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "${OSG_PLUGINS_PATH}/${OP}" "${QPLUGDIR}/../osgPlugins/${OP}")
44+
ENDFOREACH (OP)
45+
ENDIF ()
46+
47+
# update lib paths
48+
49+
MESSAGE (STATUS "Updating OSG library paths...")
50+
51+
FOREACH (OFW ${OSGLIST})
52+
# get install names from installed in case bundled copy already changed
53+
# from a previous install attempt
54+
GET_INSTALL_NAME ("${OSG_FW_DIR}/${OFW}.framework/${OFW}" ${OFW}.framework OO)
55+
SET (OFW_CHG "${OO}")
56+
SET (OFW_CHG_TO "${ATEXECUTABLE}/@QGIS_FW_SUBDIR@/${OFW}.framework/${OFW}")
57+
# qgis app
58+
INSTALLNAMETOOL_CHANGE ("${OFW_CHG}" "${OFW_CHG_TO}" "${QAPPDIR}/${QGIS_APP_NAME}")
59+
60+
SET (LIBPOST "${OFW}.framework/${OFW}")
61+
# osg frameworks
62+
IF (@OSX_HAVE_LOADERPATH@)
63+
SET (OFW_CHG_TO "${ATLOADER}/../../../${LIBPOST}")
64+
ENDIF ()
65+
FOREACH (OF ${OSGLIST})
66+
INSTALLNAMETOOL_CHANGE ("${OFW_CHG}" "${OFW_CHG_TO}" "${QFWDIR}/${OF}.framework/${OF}")
67+
ENDFOREACH (OF)
68+
# osg plugins
69+
IF (@OSX_HAVE_LOADERPATH@)
70+
SET (OFW_CHG_TO "${ATLOADER}/@QGIS_PLUGIN_SUBDIR_REV@/@QGIS_FW_SUBDIR@/${LIBPOST}")
71+
ENDIF ()
72+
FOREACH (OP ${OSGPLUGLIST})
73+
INSTALLNAMETOOL_CHANGE ("${OFW_CHG}" "${OFW_CHG_TO}" "${QPLUGDIR}/../osgPlugins/${OP}")
74+
ENDFOREACH (OP)
75+
# globe plugin
76+
INSTALLNAMETOOL_CHANGE ("${OFW_CHG}" "${OFW_CHG_TO}" "${QPLUGDIR}/libglobeplugin.so")
77+
ENDFOREACH (OFW)
78+
79+
ENDIF (@OSGEARTH_FOUND@)

src/plugins/globe/globe_plugin.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
#include <osgGA/TrackballManipulator>
4040
#include <osgDB/ReadFile>
41+
#include <osgDB/Registry>
4142

4243
#include <osgGA/StateSetManipulator>
4344
#include <osgGA/GUIEventHandler>
@@ -86,6 +87,13 @@ GlobePlugin::GlobePlugin( QgisInterface* theQgisInterface )
8687
setObjectName( "globePlugin" );
8788
setParent( theQgisInterface->mainWindow() );
8889

90+
// add internal osg plugin path if bundled osg on OS X
91+
#ifdef QGIS_MACAPP_BUNDLE
92+
#if QGIS_MACAPP_BUNDLE > 0
93+
setLibraryFilePathList( QgsApplication::prefixPath() + "/QGIS_PLUGIN_SUBDIR/../osgPlugins" );
94+
#endif
95+
#endif
96+
8997
mSettingsDialog = new QgsGlobePluginDialog( &viewer, theQgisInterface->mainWindow(), QgisGui::ModalDialogFlags );
9098
mQDockWidget = new QDockWidgetGlobe( tr( "Globe" ), theQgisInterface->mainWindow() );
9199
}

0 commit comments

Comments
 (0)