From Mathias Froehlich, added support for search in the installed directories for plugins

This commit is contained in:
Robert Osfield 2008-09-19 12:49:22 +00:00
parent a961b880bb
commit f388d6a938
2 changed files with 26 additions and 1 deletions

View File

@ -532,6 +532,11 @@ ELSE (DYNAMIC_OPENSCENEGRAPH)
SET(OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC")
ENDIF(DYNAMIC_OPENSCENEGRAPH)
# Add a default plugin search path component
IF (DYNAMIC_OPENSCENEGRAPH)
ADD_DEFINITIONS(-DOSG_DEFAULT_LIBRARY_PATH="${CMAKE_INSTALL_PREFIX}/lib${LIB_POSTFIX}/${OSG_PLUGINS}")
ENDIF(DYNAMIC_OPENSCENEGRAPH)
INCLUDE(OsgMacroUtils)
# OSG Core
ADD_SUBDIRECTORY(src)

View File

@ -364,6 +364,14 @@ std::string osgDB::findFileInDirectory(const std::string& fileName,const std::st
return "";
}
static void appendInstallationLibraryFilePaths(osgDB::FilePathList& filepath)
{
#ifdef OSG_DEFAULT_LIBRARY_PATH
// Append the install prefix path to the library search path if configured
filepath.push_back(OSG_DEFAULT_LIBRARY_PATH);
#endif
}
#if defined(WIN32) && !defined(__CYGWIN__)
#include <io.h>
#include <direct.h>
@ -450,6 +458,8 @@ std::string osgDB::findFileInDirectory(const std::string& fileName,const std::st
convertStringPathIntoFilePathList(ptr,filepath);
}
#endif
appendInstallationLibraryFilePaths(filepath);
}
@ -463,8 +473,9 @@ std::string osgDB::findFileInDirectory(const std::string& fileName,const std::st
convertStringPathIntoFilePathList(ptr,filepath);
}
convertStringPathIntoFilePathList("/usr/bin/:/usr/local/bin/",filepath);
appendInstallationLibraryFilePaths(filepath);
convertStringPathIntoFilePathList("/usr/bin/:/usr/local/bin/",filepath);
}
#elif defined(WIN32)
@ -554,6 +565,8 @@ std::string osgDB::findFileInDirectory(const std::string& fileName,const std::st
// when a DLL is found, so I see no point in removing duplicates.
convertStringPathIntoFilePathList(ptr, filepath);
}
appendInstallationLibraryFilePaths(filepath);
}
#elif defined(__APPLE__)
@ -692,6 +705,8 @@ std::string osgDB::findFileInDirectory(const std::string& fileName,const std::st
convertStringPathIntoFilePathList(ptr, filepath);
}
appendInstallationLibraryFilePaths(filepath);
// Since this is currently the only Objective-C code in the
// library, we need an autoreleasepool for obj-c memory management.
// If more Obj-C is added, we might move this pool to another
@ -762,6 +777,8 @@ std::string osgDB::findFileInDirectory(const std::string& fileName,const std::st
convertStringPathIntoFilePathList(ptr, filepath);
}
appendInstallationLibraryFilePaths(filepath);
const std::string OSG_PLUGIN_PATH("/OpenSceneGraph/PlugIns");
CFURLRef url;
CFBundleRef myBundle;
@ -865,6 +882,8 @@ std::string osgDB::findFileInDirectory(const std::string& fileName,const std::st
{
convertStringPathIntoFilePathList(ptr, filepath);
}
appendInstallationLibraryFilePaths(filepath);
}
#endif
@ -879,6 +898,7 @@ std::string osgDB::findFileInDirectory(const std::string& fileName,const std::st
convertStringPathIntoFilePathList(ptr,filepath);
}
appendInstallationLibraryFilePaths(filepath);
#if defined(__ia64__) || defined(__x86_64__)
convertStringPathIntoFilePathList("/usr/lib/:/usr/lib64/:/usr/local/lib/:/usr/local/lib64/",filepath);