Skip to content

Commit 3d0b286

Browse files
committed
[globe] Make OSG_PLUGINS_PATH CMake option functional on Mac
1 parent e882e47 commit 3d0b286

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

cmake_templates/qgsconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
//used by Mac to find system Qt plugins when bundle is run from build directory
3333
#define QTPLUGINSDIR "${QT_PLUGINS_DIR}"
3434

35+
//used by Mac to find system Open Scene Graph plugins when bundle is run from build directory
36+
#define OSG_PLUGINS_PATH "${OSG_PLUGINS_PATH}"
37+
3538
#cmakedefine USING_NMAKE
3639

3740
#cmakedefine HAVE_POSTGRESQL

src/plugins/globe/globe_plugin.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <qgsdistancearea.h>
3939

4040
#include <QAction>
41+
#include <QDir>
4142
#include <QToolBar>
4243
#include <QMessageBox>
4344

@@ -96,11 +97,23 @@ GlobePlugin::GlobePlugin( QgisInterface* theQgisInterface )
9697
setObjectName( "globePlugin" );
9798
setParent( theQgisInterface->mainWindow() );
9899

99-
// add internal osg plugin path if bundled osg on OS X
100-
#ifdef HAVE_MACAPP_BUNDLED_OSG
101-
if ( !QgsApplication::isRunningFromBuildDir() )
100+
// update path to osg plugins on Mac OS X
101+
#ifdef Q_OS_MACX
102+
if ( !getenv( "OSG_LIBRARY_PATH" ) )
102103
{
103-
osgDB::Registry::instance()->setLibraryFilePathList( QDir::cleanPath( QgsApplication::pluginPath() + "/../osgPlugins" ).toStdString() );
104+
// OSG_PLUGINS_PATH value set by CMake option
105+
QString ogsPlugins( OSG_PLUGINS_PATH );
106+
#ifdef HAVE_MACAPP_BUNDLED_OSG
107+
if ( !QgsApplication::isRunningFromBuildDir() )
108+
{
109+
// add internal osg plugin path if bundled osg
110+
ogsPlugins = QgsApplication::pluginPath() + "/../osgPlugins";
111+
}
112+
#endif
113+
if ( QFile::exists( ogsPlugins ) )
114+
{
115+
osgDB::Registry::instance()->setLibraryFilePathList( QDir::cleanPath( ogsPlugins ).toStdString() );
116+
}
104117
}
105118
#endif
106119

0 commit comments

Comments
 (0)