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") SET(OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC")
ENDIF(DYNAMIC_OPENSCENEGRAPH) 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) INCLUDE(OsgMacroUtils)
# OSG Core # OSG Core
ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(src)

View File

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